When single package specified several times with different extras, only first set is considered #4653
Labels
auto-locked
Outdated issues that have been locked by automation
resolution: duplicate
Duplicate of an existing issue/PR
Description:
When having several entries for one package with different extras requested (in particular when first entry uses git URL and second just cites name), extras for second entry are not recognized.
Example
requirements.txt
:In this example,
some-package
will be installed, but only dependencies forextra1
andextra2
will be installed, but no dependencies forextra3
.Notice there are no version constraints.
Here is a bit of what I could find from
pip
internals:When
pip install
command encounters a package reference, it adds that reference with all parameters toRequirementSet
usingRequirementSet.add_requirement
method passing it a singleinstall_req
object.Then,
add_requirement
(around line 260) checks if there is already required package with the same name. And if it is (which is the case for second line in my example), it just returnsexisting_req
, ignoring new value with additional extras (around line 301).I have noticed that there actually is a code to update extras. But this code is only used
if not install_req.constraint and existing_req.constraint
.I am not sure if I understand it correctly, but looks like constraint flag is only set for packages coming from constraints file. So in my case (when both package references come from requirements file) this clause is just not executed.
What I've run:
Here is the simplest way I found to reproduce the problem. This particular command looks meaningless (as one could just write
requests[security,socks]
), but it does make sense if e.g. requirements are separated in different files, and some of them are taken from URLs, etc.Notice that
PySocks
was is not installed!The text was updated successfully, but these errors were encountered: