Commit Graph

85 Commits

Author SHA1 Message Date
Artturin
e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00
Martin Weinelt
0b0dd33e0a
python312Packages.setuptoolsCheckHook: remove
The hook relied on the `test` command passed to `setup.py`, which has
long been deprecated and finally removed in setuptools 72.0.
2024-08-06 18:18:40 +02:00
Vladimír Čunát
c76085b3a9
Merge branch 'master' into staging-next 2024-07-03 19:07:35 +02:00
Yueh-Shun Li
455314a3f0 buildPython*: make doCheck default less confusing
Modify the set pattern to hint developers that the doInstallCheck
attribute of Python packages, specified by the doCheck argument of
buildPythonPackage and buildPythonApplication, defaults to true instead
of false.
2024-07-03 02:42:59 +08:00
Martin Weinelt
3bfb20e638
mk-python-derivation: add pythonRelaxDepsHook
Configuring `pythonRelaxDeps` or `pythonRemoveDeps` does not require
adding `pythonRelaxDepsHook` into `nativeBuildInputs` anymore.

Co-Authored-By: superherointj <5861043+superherointj@users.noreply.github.com>
2024-06-14 14:51:23 +02:00
adisbladis
de402796a7 mk-python-derivation: Break out attribute set cleaning into a separate function
With precomputed static lists.
2024-03-06 14:22:43 +13:00
adisbladis
1656fe1bf6 mk-python-derivation: Precompute static lists 2024-03-06 14:22:09 +13:00
adisbladis
d77190aeaa mk-python-derivation: Refactor internal function validatePythonMatches
We can avoid recreating the same closure for every call by moving arguments around a little.
2024-03-04 16:04:50 +13:00
adisbladis
fb757e30fa mk-python-derivation: Refactor lib usage 2024-03-04 16:04:50 +13:00
adisbladis
4d0cca4654 mk-python-derivation: Add build-system argument
Much like the previous commit that adds dependencies &
optional-dependencies this aligns PEP-517 build systems with how they
are defined in PEP-518/PEP-621.

The naming `build-system` (singular) is aligned with upstream Python standards.
2024-02-18 17:40:42 +13:00
adisbladis
b9138b7c07 mk-python-derivation: Add dependencies & optional-dependencies arguments
Since https://github.com/NixOS/nixpkgs/pull/161835 we've had the
concept of `passthru.optional-dependencies` for Python optional deps.

Having to explicitly put optional-dependencies in the passthru attrset
is a bit strange API-wise, even though it semantically makes sense.

This change unifies the handling of non-optional & optional Python
dependencies using the names established from PEP-621 (standardized pyproject.toml project metadata).
2024-02-18 17:40:42 +13:00
Sandro
d5917b14b3
mk-python-derivation: fix passthru.updateScript being merged into the derivation (#241922)
Before updateScript was being merged to pdm.updateScript.
With this commit it is being moved to the expected location pdm.passthru.updateScript
2024-02-07 08:14:34 +01:00
Martin Weinelt
8f3162f83f
python3.pkgs.pythonRuntimeDepsCheckHook: init
Implements a hook, that checks whether all dependencies, as specified by
the wheel manifest, are present in the current environment.

Complains about missing packages, as well as version specifier
mismatches.
2023-12-20 20:10:22 +01:00
Adam Joseph
ba2ed469c2
Merge branch 'master' into staging-next 2023-11-08 06:15:46 +00:00
Adam Joseph
bc2d598878 treewide: change pythonForBuild to pythonOnBuildForHost 2023-11-05 17:42:12 -08:00
Frederik Rietdijk
7a0d080298 python3.pkgs.buildPython*: allow overriding of the stdenv
With this change it is possible to pass in `stdenv` directly to
`buildPython*` or override it using e.g.

```
numpy.overridePythonAttrs(_: {
  stdenv = clangStdenv;
})
```
2023-10-19 18:56:47 +02:00
Peder Bergebakken Sundt
bdda7b0a53 python3Packages.flitBuildHook: remove 2023-09-22 21:11:24 +02:00
figsoda
6893201945 python310Packages.buildPythonPackage: introduce pyproject option 2023-09-12 19:54:03 -04:00
Theodore Ni
4e7188c39a python3.pkgs.buildPythonPackage: disable conflict check for setuptools and wheel
We can do this automatically for packages we know cannot use the
conflict check hook when it would lead to infinite recursion.
2023-08-20 10:59:47 +02:00
Theodore Ni
6c85fff302 python3.pkgs.buildPythonPackage: switch to PyPA build and installer 2023-08-20 10:59:47 +02:00
Felix Buehler
f3719756b5 treewide: use optionalString instead of 'then ""' 2023-06-24 20:19:19 +02:00
Artturin
d44390ab18 mkPythonDerivation: validate propagatedBuildInputs use a matching python
mkPythonDerivation: apply checks to buildInputs as well

fixup: add a suggestion about nativeBuildInputs

Clean up the wording, add reasons for the suggestions

switch to throw

Adjust error to clarify build-time vs. run-time
2023-04-28 17:59:20 +03:00
Alyssa Ross
d608fbb9f6 buildPython*: allow overriding disabled packages
Previously:

	nix-repl> python3.pkgs.WSME
	error: WSME-0.11.0 not supported for interpreter python3.10

	nix-repl> python3.pkgs.WSME.overridePythonAttrs (_: { disabled = false; })
	error: WSME-0.11.0 not supported for interpreter python3.10

Now:

	nix-repl> python3.pkgs.WSME
	error: WSME-0.11.0 not supported for interpreter python3.10
	«derivation

	nix-repl> python3.pkgs.WSME.overridePythonAttrs (_: { disabled = false; })
	«derivation /nix/store/cxkiwdfm146zvl573s2hahlbjd1wfrrp-python3.10-WSME-0.11.0.drv»
2023-02-02 16:49:27 +01:00
Guillaume Girol
339a5491bb buildPythonPackage: support nativeCheckInputs 2023-01-21 16:42:09 +01:00
Frederik Rietdijk
69ea4c8696 pythonPackages.buildPython*: also output dist when using wheel
Typically the actual wheel will be unchanged, but it is possible we use
the relax deps hook modifying the wheel.
2022-10-04 15:34:46 +02:00
Frederik Rietdijk
86ab83260f Revert "Revert "buildPython*: store dist (wheel/sdist) in dist output""
Most packages were fixed on python-unstable.

This reverts commit 0a4898c21a.
2022-09-20 09:49:55 +02:00
Frederik Rietdijk
8895944c57 Revert "Revert "buildPython*: wrap setuptools in hook for catching conflicts""
Most packages were fixed up on python-unstable branch.

This reverts commit 3ff2d9362c.
2022-09-20 09:49:27 +02:00
Frederik Rietdijk
3ff2d9362c Revert "buildPython*: wrap setuptools in hook for catching conflicts"
Revert for now and fix on python-unstable branch.

This reverts commit 13bb0f49f7.
2022-09-19 10:01:25 +02:00
Frederik Rietdijk
0a4898c21a Revert "buildPython*: store dist (wheel/sdist) in dist output"
Revert for now and fix on python-unstable branch.

This reverts commit adbc59c9d3.
2022-09-19 10:00:42 +02:00
Frederik Rietdijk
13bb0f49f7 buildPython*: wrap setuptools in hook for catching conflicts
By default buildPython* runs a hook for detecting conflicting packages.
This hook needs pkg_resources which is part of setuptools.

Before this commit, setuptools was simply added to the build. This meant
that when setuptools was forgotten to be added to the build, the build
and installation would still succeed because of this package from the
hook. During runtime (and cross-compilation) one would notice the
missing package.
2022-09-13 18:48:08 +02:00
Frederik Rietdijk
adbc59c9d3 buildPython*: store dist (wheel/sdist) in dist output
Store the intermediate artifacts. In time, we should build, install and
test in separate derivations as that reduces circular dependencies,
avoids rebuilds when fixing tests, and makes it possible to use the
wheels for creating say virtualenv's.
2022-09-12 22:15:39 +02:00
Matthieu Coudron
de50d08d73 buildPythonPackage: document why we always propagate python
python applications should not propagate python in PATH but we do it
nevertheless to avoid rebuilds see https://github.com/NixOS/nixpkgs/issues/170887
for an explanation.
2022-06-27 21:02:27 +02:00
Malo Bourgon
44d5d31d98 Revert "pythonPackages: set mainProgram to pname by default"
It's now the case that `nix run` checks `pname` as well as `name`, so
this is no longer needed. See:
a2473823d7

This reverts commit baf91ea7d9.
2022-05-10 11:51:54 -07:00
Matthieu Coudron
baf91ea7d9 pythonPackages: set mainProgram to pname by default
Calling `nix run poetry` or another python package usually fails
because of the "pythonX" prefix in name.
Adjust mainProgram to ignore that prefix.
2021-06-12 23:23:35 +02:00
Robert T. McGibbon
2e55b7301b pytestCheckHook: improve disabledTestPaths whitespace handling 2021-05-14 21:59:55 -07:00
Frederik Rietdijk
09147517ea buildPythonPackage: avoid recursion
Sometimes an infinite recursion error shows up.
2021-04-03 17:56:14 +02:00
volth
bc0d605cf1 treewide: fix double quoted strings in meta.description
Signed-off-by: Ben Siraphob <bensiraphob@gmail.com>
2021-01-24 19:56:59 +07:00
Frederik Rietdijk
27d3a18ac7 buildPython*: don't catch conflicts when cross-compiling
Hack until we fix PYTHONPATH.
2020-11-19 20:59:16 +01:00
Frederik Rietdijk
3fceafce1e buildPython*: remove pythonRecompileBytecodeHook as dependency
This hook was added to get reproducible bytecode. Because it was causing
issues it was disabled, but still kept as a dependency. Now the main
issue with bytecode reproducibility has been resolved by updating pip to
20.2.4, we remove this hook as a dependency.

If a package with Python code is not yet reproducible, one could add
this hook to `nativeBuildInputs`.
2020-11-12 19:32:30 +01:00
Drew Risinger
60df61b67e mk-python-derivation: document pyproject format
Optional setting of format == "pyproject", "egg" had been documented
in the manual, but they weren't listed in the function header for
``mk-python-derivation.nix``.
2020-09-16 17:38:41 +02:00
DavHau
d1c1a0c656 fix indentation in mk-python-derivation.nix 2020-06-27 14:26:03 +00:00
Frederik Rietdijk
b7aec77a7b buildPythonPackage: don't recompile bytecode
There are too many regressions. Instead of reverting all the work that has been
done on this so far, let's just disable it Python-wide. That way we can
investigate and fix it easier.
2020-06-17 14:54:03 +02:00
Jonathan Ringer
b6654d9d6c python2Packages: default to dontUsePythonRecompileBytecode = true; 2020-06-16 13:02:50 -07:00
Frederik Rietdijk
818cf7827b buildPythonPackage: recompile bytecode for reproducibility
Due to a change in pip the unpacked wheels are no longer reproducible.
We recompile the bytecode to cleanup this error.
https://github.com/NixOS/nixpkgs/issues/81441
2020-06-13 10:36:28 +02:00
Jonathan Ringer
a9c994ad0b python: add pythonNamespacesHook 2020-03-18 12:20:51 -07:00
Jonathan Ringer
3973a3c79c python: add pythonRemoveTestsDirHook
This will automatically remove a top-level "tests"
directory from being installed.
2020-03-03 20:01:00 +01:00
adisbladis
2d6f1ff4dd
python: Add support for installing Python eggs 2020-01-08 13:59:04 +00:00
Frederik Rietdijk
f7e28bf5d8 Split buildPythonPackage into setup hooks
This commit splits the `buildPythonPackage` into multiple setup hooks.

Generally, Python packages are built from source to wheels using `setuptools`.
The wheels are then installed with `pip`. Tests were often called with
`python setup.py test` but this is less common nowadays. Most projects
now use a different entry point for running tests, typically `pytest`
or `nosetests`.

Since the wheel format was introduced more tools were built to generate these,
e.g. `flit`. Since PEP 517 is provisionally accepted, defining a build-system
independent format (`pyproject.toml`), `pip` can now use that format to
execute the correct build-system.

In the past I've added support for PEP 517 (`pyproject`) to the Python
builder, resulting in a now rather large builder. Furthermore, it was not possible
to reuse components elsewhere. Therefore, the builder is now split into multiple
setup hooks.

The `setuptoolsCheckHook` is included now by default but in time it should
be removed from `buildPythonPackage` to make it easier to use another hook
(curently one has to pass in `dontUseSetuptoolsCheck`).
2019-09-06 15:18:45 +02:00
volth
f3282c8d1e treewide: remove unused variables (#63177)
* treewide: remove unused variables

* making ofborg happy
2019-06-16 19:59:05 +00:00
Frederik Rietdijk
d801204fdd
Merge pull request #51641 from codedownio/nousersite-master
Allow skipping the use of the PYTHONNOUSERSITE variable
2019-05-13 12:39:25 +02:00