Commit Graph

66 Commits

Author SHA1 Message Date
Frederik Rietdijk
de5951f3c2 pythonPackages.pythonRelaxDepsHook: cleanup unpacked folder
or it will end up in the dist output.
2022-10-04 15:34:46 +02:00
Martin Weinelt
68c0ca4416 Merge remote-tracking branch 'origin/master' into staging-next 2022-09-25 21:36:31 +02:00
Frederik Rietdijk
7a41be7b2a Python hooks: use spliced packages in hooks
This fixes issues when cross-compiling.
2022-09-23 22:19:52 +03: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
Martin Weinelt
19f4e14dcf
python3Packages.sphinxHook: run install phase in predist
Run the installSphinxPhase earlier, so install errors are caught early,
before long and expensive test are started.
2022-08-24 23:02:27 +02:00
Martin Weinelt
caf2d010ed
python3Packages.sphinxHook: Rename loop var in source root detection
The loop variable to find the documentation source root was
unnecessarily short, rename it to something meaningful.
2022-08-24 23:02:26 +02:00
Martin Weinelt
8a26deba06
doc/python: integrate sphinxHook docs
Improve the documentation by moving it from the hook script into the
Python section in the manual and adding code examples.
2022-08-24 23:02:24 +02:00
Martin Weinelt
1ee5fcaf0c
python3Packages.sphinxHook: Add support for multiple builders
Removes the up until now unused option to specify a `sphinxOutdir` in
favor of allowing to specify multiple builders, which is for example
useful for generating both documentation and manpages using the hook.

Since the output path cannot be determined from within the package we
automatically generate it and add a diversion for manpages, so they land
in the correct output and path.
2022-08-24 23:00:41 +02:00
Winter
e8fbb38a51 pythonPackages.unittestCheckHook: init 2022-08-13 14:09:43 -04:00
Martin Weinelt
c7dbac1666 python3Packages.sphinxHook: run post install
This allows importing and inspecting the build result, which is required
for the psycopg (3.x) package.
2022-07-21 22:35:25 +02:00
Thiago Kenji Okada
15491e727d pythonRelaxDepsHook: correct handles multiple wheels 2022-06-12 11:48:52 +01:00
Thiago Kenji Okada
61223d51de pythonRelaxDepsHook: fix usage in packages with - in pname 2022-06-07 21:24:48 +01:00
github-actions[bot]
ee7e3f30f3
Merge staging-next into staging 2022-05-04 00:02:57 +00:00
Frederik Rietdijk
ab62fad9d5
Merge pull request #136100 from KAction/sphinx-hook
New hook: sphinxHook to build documentation into different formats/outputs
2022-05-03 20:07:37 +02:00
Thiago Kenji Okada
e19019fe32 pythonRelaxDepsHook: init
We have a common pattern here in nixpkgs for Python applications: when a
Python package ships with either a requirements.txt or setup.py file, we
generally end up having to modify its version restriction, otherwise we have
build failures since we package only one specific version of each package
normally.

However, this end up being done in a completely ad-hoc way: some people
use substituteInPlace, some others use sed, others uses patches, etc.
In many cases, the code ends up being buggy, so it may work in one
version and breaks on the next one. We can instead implement one
standard way of doing this, and trying to be a correct as possible.

So this is what this commit does: it implements a new build hook, that
when called will automatically patch the wheel file. This is one of the
most generic ways to patch Python dependencies, and should work in
multiple cases.
2022-04-30 13:19:30 +01:00
Dmitry Bogatov
6b8b02cef7
python3.pkgs.sphinxHook: new package
This hook takes care of building and installing html documentation from Sphinx
sources.
2022-04-29 08:45:38 -04:00
Sergei Trofimovich
a649d4f038 python: use whitespace to split possible existing options
Noticed option globbing when tried to enable parallelism by default
locally for most packages by default. python3Packages.yt-dlp failed as:

    python3.9-yt-dlp> /nix/store/5mywvxdjkk1q6srwwwgdkzc37ibla801-python3.9-setuptools-61.2.0/lib/python3.9/site-packages/setuptools/dist.py:516: UserWarning: Normalizing '2022.04.08' to '2022.4.8'
    python3.9-yt-dlp>   warnings.warn(tmpl.format(**locals()))
    python3.9-yt-dlp> invalid command name 'build_lazy_extractors--parallel'

The change adds leading whitespace everywhere where options might
already be present.
2022-04-24 14:28:26 +02:00
Phillip Cloud
52248e4466 python: enable opt-in parallel build_ext builds for setuptools 2022-04-22 18:25:12 +02:00
Jonathan Ringer
ae418d54d3 python.pkgs.pythonNamespacesHook: check parent directory exists before removing child 2021-12-02 17:38:40 -08:00
Jonathan Ringer
a06fe88f75 python/pythonNamespacesSetupHook: add to addtional files to remove 2021-11-29 22:50:15 -08:00
Drew Risinger
30097aeabc
python: pythonRemoveTestsDirHook removes /test
Some packages have their tests installed at ./test, not just ./tests.
This covers that use case by removing both.
2021-06-21 16:48:39 -07:00
github-actions[bot]
f2a2e8f5e9
Merge master into staging-next 2021-05-28 12:48:40 +00:00
DavHau
6c0b85cf3a buildPythonPackage: add support for conda 2021-05-28 14:31:40 +02:00
Eduardo Sánchez Muñoz
4aee58ec96 pythonPackages.buildPythonPackage: enable verbose output with pyproject
This makes the build log more useful
2021-05-19 12:16:15 -07:00
Robert T. McGibbon
2e55b7301b pytestCheckHook: improve disabledTestPaths whitespace handling 2021-05-14 21:59:55 -07:00
Frederik Rietdijk
7a65bb76f1 pythonPackages: fix editable setuptools installations 2021-03-23 11:27:27 +01:00
Martin Weinelt
d6d63aef7d
pytestCheckHook: add support for disabling arbitrary paths
Renames `disabledTestFiles` to the more genereric `disabledTestPaths` to
reflect that change.
2021-02-15 00:34:35 +01:00
Martin Weinelt
0f5743bee2 pytestCheckHook: Fix support for multiple files.
Quoting here will lead to the shell treating them as a single item.
2021-01-24 15:44:45 -08:00
Martin Weinelt
45e5ebfad8 pytestCheckHook: Fix support for spaces in disabled file paths 2021-01-24 15:44:45 -08:00
Sandro Jäckel
6f7f01a244 pytestCheckHook: Add disabledTestFiles option 2021-01-16 09:09:26 -08:00
Frederik Rietdijk
76966f8ddd pythonPackages.pip-install-hook: remove --build option
Pip had the option --build to build in a custom or temporary directory.
Nowadays, pip just listens to TMPDIR, which we already set.

This option was deprecated and is removed in pip 20.3.
2020-12-01 14:44:26 +01:00
Jonathan Ringer
0a4575a1da python/hooks/pythonNamespaces: fix __pycache__ being empty, or not existing 2020-11-26 13:51:05 -08:00
Jonathan Ringer
f5d9dd3050 python/hooks/pythonNamespaces: fix __pycache__ logic 2020-11-23 08:33:04 -08:00
Jonathan Ringer
8d210e2ea4 python3.pkgs.pipInstallHook: don't warn on script installation 2020-11-20 12:25:52 -08:00
John Ericson
330d468002 python: Use packages from previous stage in setup-hooks
This makes sense as these are tools we want to run at build time.
2020-11-19 11:58:03 -05:00
Frederik Rietdijk
61a04f735a python3.pkgs.pip: 20.1.1 -> 20.2.4
Reproducible builds of pyproject projects using pip is resolved.

Fixes https://github.com/pypa/pip/issues/7808
Fixes https://github.com/NixOS/nixpkgs/issues/81441

The more recent c409f69480 caused trouble
with pyproject troubles and had to be reverted anyway.
https://github.com/NixOS/nixpkgs/pull/102222#issuecomment-722380794

Revert "pythonPackages.pip: make reproducible (#102222)"

This reverts commit c409f69480.

Revert "python3Packages.pip: allow setting reproducible temporary directory via NIX_PIP_INSTALL_TMPDIR"

This reverts commit aedbade43e.
2020-11-05 15:07:21 +01:00
zimbatm
c409f69480
pythonPackages.pip: make reproducible (#102222)
The previous attempt wasn't covering all of the bases. It relied on
invoking that pip-install-hook, and didn't apply to pip itself.

The core issue is that the generated .pyc files embed some of the
temporary paths, which are randomly generated. See
https://r13y.com/diff/bf8c3ca3148ebff9ecf41f294cc60b9f209c006d49699e356969ff32d736f1c6-8806a7cca91fdd300e48736bfcd57c4d0b54c1cc2fd61609f35143170862b59c.html

In this new attempt, the approach is to patch the TempFile
implementation directly, so that it creates stable temporary
directories. We also assume that if SOURCE_DATE_EPOCH is set, we are in
a scenario where reproducible builds are desirable and enter that
branch.

See also https://github.com/pypa/pip/issues/7808
2020-10-31 21:24:36 +01:00
misuzu
aedbade43e python3Packages.pip: allow setting reproducible temporary directory via NIX_PIP_INSTALL_TMPDIR 2020-07-02 17:27:13 +02: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
Frederik Rietdijk
a7ea828f09 pythonRemoveBinBytecodeHook: fix explanation 2020-06-13 10:20:14 +02:00
Daniël de Kok
1e2b6695cf pythonPackages.setuptoolsBuildHook: do not build in an isolated environment
When a PEP 517 project file is present, pip will not install
prerequisites in `site-packages`:

https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support

For the shell hook, this has the consequence that the generated
temporary directory that is added to PYTHONPATH does not contain
`site.py`. As a result, Python does not discover the Python
module. Thus when a user executes nix-shell in a project, they cannot
import the project's Python module.

This change adds the `--no-build-isolation` option to pip when
creating the editable environment, to correctly generate `site.py`,
even when a `pyproject.toml` is present.
2020-06-06 10:05:26 +02:00
Daniël de Kok
e2309df85e pythonPackages.pipBuildHook: do not build in an isolated environment
When a PEP 517 project file is present, pip will not install
prerequisites in `site-packages`:

https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support

For the shell hook, this has the consequence that the generated
temporary directory that is added to PYTHONPATH does not contain
`site.py`. As a result, Python does not discover the Python
module. Thus when a user executes nix-shell in a project, they cannot
import the project's Python module.

This change adds the `--no-build-isolation` option to pip when
creating the editable environment, to correctly generate `site.py`,
even when a `pyproject.toml` is present.
2020-06-06 10:05:26 +02:00
Jan Tojnar
7f40cfd97b
Merge branch 'master' into staging-next 2020-05-18 21:09:27 +02:00
Jon
15b3d9d277
python3Packages.venvShellHook: add postVenvCreation (#87850)
* python3Packages.venvShellHook: add postVenvCreation

* python: docs: add postVenvCreation explaination
2020-05-16 09:34:11 +02:00
Jonathan Ringer
884436b254 pythonPackages.pytestCheckHook: disable setuptoolsCheckPhase 2020-05-11 22:12:08 +02:00