Skip to content
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

Some python programs are in python-modules #332191

Closed
Aleksanaa opened this issue Aug 4, 2024 · 4 comments
Closed

Some python programs are in python-modules #332191

Aleksanaa opened this issue Aug 4, 2024 · 4 comments
Labels
6.topic: architecture Relating to code and API architecture of Nixpkgs 6.topic: python

Comments

@Aleksanaa
Copy link
Member

Aleksanaa commented Aug 4, 2024

Problem

I just discovered that in pkgs/development/python-modules:

=> grep -r 'mainProgram' . | wc -l
1210

=> find . -maxdepth 1 -type d | wc -l
7526

So 1210 out of 7526 python modules have a mainProgram. And also a lot of them (most?) don't have a toPythonApplication in top-level.

So now we have 3 approaches to package a python application:

  1. use python3Packages.buildPythonApplication, and put it in pkgs/by-name.
  2. use buildPythonPackage and put in pkgs/development/python-modules, and add a toPythonApplication entry in all-packages.nix
  3. use buildPythonPackage and put in pkgs/development/python-modules, and let users write python3Packages.foo

Solution

If the upstream documentation doesn't mention it can be used as a python module, then only 1 is correct. If upstream doesn't mention but there do have some examples, then toPythonModule should be used (but we can also tolerate toPythonApplication and put in python-modules).

If it's primarily used as a module, but also has some useful executables, then 2 is correct. If it's only used as a python module, or the executable doesn't have external use cases (for example, is serving the needs of the module), then only 3 is correct.

This should be explicitly documented and anti-patterns should be removed

@Aleksanaa Aleksanaa added 6.topic: python 6.topic: architecture Relating to code and API architecture of Nixpkgs labels Aug 4, 2024
@Aleksanaa
Copy link
Member Author

ping @natsukium @fabaff

@AndersonTorres
Copy link
Member

Hum, my suspects about git-filter-repo have some basis...

@fabaff
Copy link
Member

fabaff commented Aug 4, 2024

mainProgram was added automatically (in most cases) with #297084. I assume that most of the 1210 hits were coming for that PR.

@dotlambda
Copy link
Member

I don't think having a top-level alias is a necessity. If any of those are only tools and don't provide an API, they should be removed from python3Packages. But having mainProgram is not a sufficient condition.

@dotlambda dotlambda closed this as not planned Won't fix, can't repro, duplicate, stale Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: architecture Relating to code and API architecture of Nixpkgs 6.topic: python
Projects
None yet
Development

No branches or pull requests

4 participants