-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Allow pip install to only install optional dependencies #12191
Comments
Can you provide some reference for this? Who needs it? Why is it needed? |
It's perhaps not a wide-spread need, but I came across this today numpy/numpydoc#481 (comment) |
If I understand the context correctly, the perceived need for the feature comes from the desire to put all requirements in |
To provide a single
The current working solution for that specific project is to maintain a template pyproject.toml.in file and two requirements files, with some custom pre-commit logic to ensure the "do not edit" pyproject.toml is properly synced to the template. This is awkward. A better solution for the project is to have only one pyproject.toml file to specify optional dependencies. Another scenario that I routinely come across is installing a project once, then later deciding that one or more of the extras is needed. This example is:
Both "install" commands may take a bit of time to do, for instance if Cython modules need to be created and compiled. However, if there was an option to only install optional dependencies, the second install would be much quicker. |
I am definitely missing some context here, since the relation between templating
I would say this seems like a deciciency in how the build backend functions. Installing an already-installed editable package should only require minimal building work aside from metadata preparation (which will still be needed even if the title feature is implemented). If the above requires a lot of rebuilding, I would direct efforts into finding why the build backend cannot re-use existing built artifacts and has to do the work from scratch and attempt to find improvements there instead. |
Perhaps too many details of an example PR are being interpreted here, as this feature request has nothing directly to do with pyproject.toml, so the context shouldn't be relevant to the core feature in this request. Take an example "mypackage", which was packaged with core metadata containing:
|
The feature request is clear. What isn’t clear is the justification for it. Extras in As a result, your request reads like “we are trying to do this thing we don’t need to do, and it doesn’t work”. What you need to do is explain why you can’t continue to use a requirements file, if you want to justify this feature request. |
Previously discussed in https://discuss.python.org/t/adding-a-non-metadata-installer-only-dev-dependencies-table-to-pyproject-toml/20106 (IIUC). |
Requirements files are not published with the distribution, optional-dependencies metadata is. How would you ship a requirements.txt? |
Some projects repeat the optional dependencies in one or more requirements files. These files need to be synchronized; here is an example of a pre-commit script to do that. This feature idea would not require duplication or synchronization, as they would be kept in one place and accessible via
There are lots of ways, unfortunately. E.g. setuptools uses a
There are some complications with this feature idea. Upon reflection, I don't think using syntax (e.g. This idea would naturally open the door for other requests, e.g. to only install |
It's painful to see, how after literally hundreds of people in at least three different issues ( #11440 #12100 #4783 ) requesting this feature, commenting and upvoting, some maintainers of this project keep trying to tell those people, that their use case is invalid and keep closing one issue after another on that topic. It's 2023. Lots of people want to switch their projects to Just to give you an example, how popular it was to install dev dependencies using |
The maintainers of this projects are also authors/approvers/implementers for the PEPs that led to the creation of
It's more that we don't want to have the same discussion in multiple places -- all the issues that you've linked to have been closed to consolidate them, or because the person who filed them closed it themselves. This is something we've agreed on a design for, but at the end of the day, this is an extremely under-resourced open source project and there's limited amount of maintainer time available to help get this implemented. We have agreed on a design over on that issue, and help is welcome to implement this -- subject of course to the give-and-take of engaging with an open source project. :) To that end, I'm actually also going to close this one to consolidate this into #11440, which is the current tracking issue for the feature being requested here. |
What's the problem this feature will solve?
It seems there is a need to allow pip to install optional dependencies (or extras) independent from a package installation. For instance, packages use stand-alone requirements files that can simply be installed e.g.:
However, if these optional dependencies are migrated into a static pyproject.toml file following PEP 621, there is no equivalent to install only
test
dependencies.Describe the solution you'd like
Unsure what solution would be best, but here are some suggestions:
Alternative Solutions
Install/uninstall method
Using the above example, install the package + test, then uninstall the package with two commands:
But there is obvious overhead to install the package (+ dependencies) then uninstall the package (without dependencies).
Copy/paste method
This method needs access to the sdist or source repository. Locate the source file where optional dependencies are declared, which may vary within
pyproject.toml
,python.cfg
,python.py
or dynamically loaded from another file. Copy and paste entries into apip install ...
command. This is often the quickest solution where there are only a few dependencies.Duplicate requirements files method
Projects may duplicate their optional dependencies in requirements files. This can be manually maintained to mirror the information, or (e.g.) kept in sync with create a pre-commit script to generate requirements files.
Additional context
N/A
Code of Conduct
The text was updated successfully, but these errors were encountered: