New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split buildPythonPackage into setup hooks #64997
Conversation
# No tests in archive | ||
doCheck = false; | ||
|
||
# We add this flag to ignore the copy installed by bootstrapped-pip | ||
installFlags = [ "--ignore-installed" ]; | ||
pipInstallFlags = [ "--ignore-installed" ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renaming is related to #64812
Not sure whether the naming of the various phases (prefixed with the package providing them) makes it easier. |
cc @copumpkin have not seen you around in a while, but I recall you requested this once. |
25966d0
to
102b558
Compare
7e2a567
to
7bce3af
Compare
Need to consider also the naming of the flags that can be passed to setuptools and pip. |
|
||
args=" -m pytest" | ||
if ! [ -z "$disabledTests" ]; then | ||
args="$args -k disabledTests" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this one. We should have the same for nosetest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Note it's not yet correct. Need to implement the "and not " bit. Here I dislike having to write these things in bash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't there a similar implementation but in nix for this?
Something like having an attribute disabledTests
but as an argument to buildPython*
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was #53142
I prefer to do as much as possible in Nix, however, that does not always work. In this case, the problem was that the generated value (a string) cannot be overridden.
@@ -8,8 +8,6 @@ buildPythonPackage rec { | |||
sha256 = "52ab47715fa0fc7d8e6cd15168d1a69ba995feb1505131c3e814eb7087b57358"; | |||
}; | |||
|
|||
buildInputs = [ pip ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separate commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup! Did only a cursory glance to get the general idea for now.
@@ -0,0 +1,15 @@ | |||
# Setup hook for flit | |||
echo "Sourcing flit-build-hook" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are for debugging I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they are. I think it would be good if the stdenv would output a bit more what it is doing.
4424712
to
807a1b9
Compare
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`).
I intend to include this in the upcoming |
Pushed this to staging. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/updating-python-projects-nix-shell-requirements-nix/4505/1 |
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 withpython setup.py test
but this is less common nowadays. Most projectsnow 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-systemindependent format (
pyproject.toml
),pip
can now use that format toexecute the correct build-system.
In the past I've added support for PEP 517 (
pyproject
) to the Pythonbuilder, 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 shouldbe removed from
buildPythonPackage
to make it easier to use another hook(curently one has to pass in
dontUseSetuptoolsCheck
).