-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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
Inclusion of tests in Python package installations is causing collisions #81482
Comments
They're included in a tarball through |
this is likely an upstream issue, the test directories should be getting filtered out with
|
You are right there, though most won't bother with that because they don't add tests to |
In the case of packages = [
{include = "tomlkit"},
{include = "tests", format = "sdist"}
] This appears to be poetry's officially documented approach for including tests in the sdist tarball, and the resultant generated packages = \
['tests', 'tomlkit'] So I suspect we'd see this with a lot of poetry packages. |
.............. If this installs "tests" into site-packages, then this is just wrong |
what's the benefit to using poetry? Seems to be switching one packaging paradigm with a fair amount of gotchas with another. Syntax? |
Poetry provides a static declarative syntax, virtualenv management, a dependency-version resolver, lockfiles, and publication to PyPI, none of which are offered by setuptools. poetry2nix is a new tool for helping Nix use Poetry-based projects by pulling the hashes from the lockfiles. |
That |
If multiple distributions have `tests` as a top-level package, they'll conflict whenever both are installed. (Examples [here]((https://github.com/python-poetry/poetry/issues/1905) and [here](NixOS/nixpkgs#81482). Two common alternative strategies are: 1. not distributing tests (as [here](https://github.com/pypa/sampleproject)), or 2. placing tests in a subdirectory of the main package, rather than adjacent (as [here](http://blog.habnab.it/blog/2013/07/21/python-packages-and-you/) and [here](http://as.ynchrono.us/2007/12/filesystem-structure-of-python-project_21.html)). Each of these strategies will avoid this issue. Users may fall into this trap because of the [package documentation](https://python-poetry.org/docs/pyproject/#packages) page, which gives an example: ``` packages = [ { include = "my_package" }, { include = "tests", format = "sdist" }, ] ``` Having two top-level packages in a distribution is relatively unusual, but does have some use cases. Using `"tests"` as a top-level package name in the example is likely to lead to conflicts, however. The alternate package in the documentation example could have a unique name like `"my_other_package"`, which would reduce the likelihood of this kind of overlap.
I won't call the python tooling "cohesive", but I think all of these have analogous tools/solutions:
So yes, This is in contrast to rust with cargo. Where not only does it address all the points you raised, but is also the canonical tool for all rust development and packaging. Maybe poetry will be python's cargo. I hope so. |
Yep, I agree on all of those :-) |
I've submitted a PR to Poetry's docs to avoid user confusion. The particular case of tomlkit has already been reported upstream. |
#81538 has made it's way to master, this now works on master
|
thank you @Shados for opening the issue |
If multiple distributions have `tests` as a top-level package, they'll conflict whenever both are installed. (Examples [here]((https://github.com/python-poetry/poetry/issues/1905) and [here](NixOS/nixpkgs#81482). Two common alternative strategies are: 1. not distributing tests (as [here](https://github.com/pypa/sampleproject)), or 2. placing tests in a subdirectory of the main package, rather than adjacent (as [here](http://blog.habnab.it/blog/2013/07/21/python-packages-and-you/) and [here](http://as.ynchrono.us/2007/12/filesystem-structure-of-python-project_21.html)). Each of these strategies will avoid this issue. Users may fall into this trap because of the [package documentation](https://python-poetry.org/docs/pyproject/#packages) page, which gives an example: ``` packages = [ { include = "my_package" }, { include = "tests", format = "sdist" }, ] ``` Having two top-level packages in a distribution is relatively unusual, but does have some use cases. Using `"tests"` as a top-level package name in the example is likely to lead to conflicts, however. The alternate package in the documentation example could have a unique name like `"my_other_package"`, which would reduce the likelihood of this kind of overlap.
I'm getting an error like this whenever I try to install poetry. Do I need to use nixpkgs-unstable to use the fix? Should the fix be incorporated into nixos-20.03? |
If you're installing |
Wow, I've been installing it through python3Packages.poetry and having lots of issues using it. Just installed it through pkgs.poetry and it worked beautifully. Thanks a lot! |
nixos/acme: Fix ordering of certificate requests (#81482)
The same error message still happen for
|
I would create a new one. Ideally we would have a way nix-friendly way to remove modules that shouldn't be installed. In this case, |
Describe the bug
Many Python packages store their tests in a top-level
tests
package, and include this in their sdist tarballs, which is typically what nixpkgs installs from. Combining said packages in a Python environment thus results in multipletests
packages being installed, with a decent chance of collision.To Reproduce
Example collision:
Expected behavior
I would expect the above command to succeed, and produce a working Python environment.
Additional context
Arguably, Python packages that wish to include their tests in their sdist tarball should not be marking them as an installable package. However, this practice doesn't really cause any issues outside of Nix-land; tests are never run from the installed
tests
package, and we're unfortunately the only ones who care about file collisions.As a result, I'm not sure we'd have much luck convincing package maintainers to alter their behaviour, so we might be better off working around the issue in nixpkgs. Possibly we could either prevent installation of
tests
somehow, or remove thetests
package in post-install.Metadata
"x86_64-linux"
Linux 5.5.0, NixOS, 20.09.git.353f2215dc6 (Nightingale)
yes
yes
nix-env (Nix) 2.3.3
"home-manager"
"nixos-20.09pre215333.42f0be81ae0"
/nix/var/nix/profiles/per-user/root/channels/nixos
@FRidh
The text was updated successfully, but these errors were encountered: