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

python optional-dependencies build-time support #202948

Open
arcnmx opened this issue Nov 26, 2022 · 2 comments
Open

python optional-dependencies build-time support #202948

arcnmx opened this issue Nov 26, 2022 · 2 comments

Comments

@arcnmx
Copy link
Member

arcnmx commented Nov 26, 2022

Some python applications use optional dependencies / extras_requires to represent support for non-essential features.

Being able to set extraDependencies = [ "feat1" "feat2" ] or something in a derivation would be nice, similar to how buildFeatures = [] works in buildRustPackage.

Technical details

The setuptools build hook calls pip install -e . directly and does not allow any environment variables to customize the invocation. Installing optional dependencies seems to require running pip install -e '.[feat1,feat2,etc]' instead.

@fabaff
Copy link
Member

fabaff commented Nov 26, 2022

optional-dependencies was introduced to deal with optional requirements of Python module (see 17.27.2.3.2. Optional extra dependencies in the manual for details).

@arcnmx
Copy link
Member Author

arcnmx commented Nov 26, 2022

Note that I am specifically referring to derivations that end users will interact with (applications mainly), not modules used by other python projects/derivations. The difference is that while another python module/application/etc can enable extras by depending on dask[complete], a derivation building a final package that isn't used as a python dependency cannot.

So this is mainly useful for buildPythonApplication (and hybrid toPythonApplication modules probably too, as well as modules that act as dynamic plugins rather than dependencies). For example, a python application might optionally support sqlite as a database backend, and mark it as an optional feature. Even though you can just shove the dependencies into propagatedBuildInputs anyway and it will be in the closure/PYTHONPATH, you lose various checks and safety that can result in runtime failures (but successful builds).

Thanks for pointing that out though, it is relevant and helpful!

@arcnmx arcnmx changed the title python/setuptools extras_requires optional feature support python optional-dependencies build-time support Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants