-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Flag to ignore constraint for installing . #7839
Comments
Right now, I've written a script that templates my constraint file as a workaround. I use a tox wrapper to run the script before dependencies are installed. Pretty clunky. This issue is important for being able to develop sub-apps independently. My specific problem arose from django migrations working when testing one app but the integration failing because a related app was constrained to an older version of django-taggit and the expected migrations did not exist.
Here is an example of the tox wrapper incase this is helpful for anyone:
|
i think it is not a supported use-case to use unversioned constraints in the constraint-file. this has been discussed multiple times (#8210 or #6310) and usually the suggested workaround is to place the dependency in the requirements-file this is also what the current error message in pip 22.3 suggests:
from your description i do not quite understand your exact use case, maybe you could provide some more information why this constraint is required? :) |
This is from a long time ago and is not fresh on my mind. Consider your constraint file is the following:
This constraint file is shared among app-a, app-b, app-c, and lots of other apps so writing one for each app presents the challenge of keeping all of the constraint files in sync (i.e. not possible to maintain). Now consider you are developing a new feature in app-c. app-c requires app-a and app-b and lots of other apps of specific versions so you want to install these via the constraint file. Your test runner installs "." (the local working dir). Since app-c is listed in the constraints file it fails on the local version. |
thank you for clarifying, it makes sense to me now. As I understand this issue does only apply for the packages which you are developing by yourself. Would it be a possibility to allow newer versions of those packages in the constraints file? e.g.
this should allow the package to be installed. |
I still don't see the logic here. A constraint of Just omitting |
@pfmoore , true, but as I understand the author is using a constraint file on organization-level (or similar) in order to enforce certain versions organization-wide. if |
I fail to see why. Having What do you think putting |
This, exactly. |
The constraint lists a particular constraint. Not just the app name. Sorry if the way I presented made that detail confusing. And then it prevents installing "." for the test runner |
Rather than adding yet another pip option with a new file standard or syntax pattern I think a far more viable solution here in the face of any specific standards it to change this from an error to a warning. I think it makes sense when a requirement is found that can not have it's version checked but a constraint exists against it emit a warning to the user that this requirement can not be constrained and proceed as though that constraint doesn't exist. This will inform users who for some reason think it could work, but allow users who are using constraints in complex scenarios like this (such as managing multiple application development environments) at least the ability to keep using the constraints file. That said I think user built templating solutions are a reasonable solution to this problem. Yes it requires a small script then to build a dev environment, rather than one pip install, but pip can't solve all problems related to creating dev environments anyway so some users will always need to make themselves a script to reduce it to one command. |
@pfmoore I documented this further in a duplicate issue, #11718, but to give a concrete example, OpenStack uses constraints files to provide upper constraints across all libraries including the ones we develop ourselves. When working on e.g. https://github.com/openstack/oslo.db, you would want to constrain all the dependencies of oslo.db but not oslo.db itself as constraining oslo.db itself means you can't install it. A flag to say either "ignore the constraint if installing from a local repo/in editable mode" or "ignore the constraint for the package with this name" would be ideal. The alternative is to have a separate constraints file for every single library you want to develop, or to install all dependencies of a package separately with constraints before installing the package itself without constraints. |
Constraint files are often shared across an organization. When developing a package included in such a constraint file, it is not possible to install the package with constraints since the constraint on the package prevents us installing a development version. ❯ cd my-amazing-package ❯ cat constraints.txt my-amazing-package==1.2.3 Jinja2==3.1.2 iso8601==1.1.0 msgpack==1.0.4 ❯ pip install -c constraints.txt . Processing /dev/my-amazing-package Preparing metadata (setup.py) ... done ERROR: Cannot install my-amazing-package 1.2.4.dev1 (from /dev/my-amazing-package) because these package versions have conflicting dependencies. The conflict is caused by: The user requested my-amazing-package 1.2.4.dev1 (from /dev/my-amazing-package) The user requested (constraint) my-amazing-package===1.2.4.dev1 To fix this you could try to: 1. loosen the range of package versions you've specified 2. remove package versions to allow pip attempt to solve the dependency conflict ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts Resolve this by allowing users to opt out of individual constraints to the 'install', 'wheel', and 'download' subcommands. This is rather manual but it's expected that tools like tox could automatically generate a value for this option when invoking 'pip install' command. ❯ pip install -c constraints.txt --ignore-constraint my-amazing-package . ❯ pip wheel -c constraints.txt --ignore-constraint my-amazing-package . ❯ pip download -c constraints.txt --ignore-constraint my-amazing-package . This is only added for the '2020-resolver' resolver, not the 'legacy-resolver' resolver, given the latter is deprecated for removal. Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Fixes: pypa#7839
@stephenfin imagine you have a mechanism that says to pip: whenever you meet a dependency on oslo.db, replace all version specifiers for that package (whether they are provided by dependencies or constraints) by Would that solve your problem? I think such a mechanism has a deeper reach than just ignoring constraints because:
|
@sbidoul i agree it might have a deeper result. But the current situation of pips refusal an overwrite of a dependency constraint dosnt imo fit the lax nature of python. I would suggest a warning like use at your own risks which are ... |
We also need this. Hopefully it can advance soon. |
This sounds very similar to go's |
Constraint files are often shared across an organization. When developing a package included in such a constraint file, it is not possible to install the package with constraints since the constraint on the package prevents us installing a development version. ❯ cd my-amazing-package ❯ cat constraints.txt my-amazing-package==1.2.3 Jinja2==3.1.2 iso8601==1.1.0 msgpack==1.0.4 ❯ pip install -c constraints.txt . Processing /dev/my-amazing-package Preparing metadata (setup.py) ... done ERROR: Cannot install my-amazing-package 1.2.4.dev1 (from /dev/my-amazing-package) because these package versions have conflicting dependencies. The conflict is caused by: The user requested my-amazing-package 1.2.4.dev1 (from /dev/my-amazing-package) The user requested (constraint) my-amazing-package===1.2.4.dev1 To fix this you could try to: 1. loosen the range of package versions you've specified 2. remove package versions to allow pip attempt to solve the dependency conflict ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts Resolve this by allowing users to opt out of individual constraints to the 'install', 'wheel', and 'download' subcommands. This is rather manual but it's expected that tools like tox could automatically generate a value for this option when invoking 'pip install' command. ❯ pip install -c constraints.txt --ignore-constraint my-amazing-package . ❯ pip wheel -c constraints.txt --ignore-constraint my-amazing-package . ❯ pip download -c constraints.txt --ignore-constraint my-amazing-package . This is only added for the '2020-resolver' resolver, not the 'legacy-resolver' resolver, given the latter is deprecated for removal. Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Fixes: pypa#7839
The @plone community would benefit a lot from it as well, exactly like the Openstack community, we are also trying to use a I see that the @stephenfin commit on his |
I actually do have a PR open, #11723. It just hasn't received much attention, unfortunately. |
Constraint files are often shared across an organization. When developing a package included in such a constraint file, it is not possible to install the package with constraints since the constraint on the package prevents us installing a development version. ❯ cd my-amazing-package ❯ cat constraints.txt my-amazing-package==1.2.3 Jinja2==3.1.2 iso8601==1.1.0 msgpack==1.0.4 ❯ pip install -c constraints.txt . Processing /dev/my-amazing-package Preparing metadata (setup.py) ... done ERROR: Cannot install my-amazing-package 1.2.4.dev1 (from /dev/my-amazing-package) because these package versions have conflicting dependencies. The conflict is caused by: The user requested my-amazing-package 1.2.4.dev1 (from /dev/my-amazing-package) The user requested (constraint) my-amazing-package===1.2.4.dev1 To fix this you could try to: 1. loosen the range of package versions you've specified 2. remove package versions to allow pip attempt to solve the dependency conflict ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts Resolve this by allowing users to opt out of individual constraints to the 'install', 'wheel', and 'download' subcommands. This is rather manual but it's expected that tools like tox could automatically generate a value for this option when invoking 'pip install' command. ❯ pip install -c constraints.txt --ignore-constraint my-amazing-package . ❯ pip wheel -c constraints.txt --ignore-constraint my-amazing-package . ❯ pip download -c constraints.txt --ignore-constraint my-amazing-package . This is only added for the '2020-resolver' resolver, not the 'legacy-resolver' resolver, given the latter is deprecated for removal. Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Fixes: pypa#7839
Would Pip maintainers be interested in a PR that does this based on my reasoning in the comment: #7839 (comment) I would be happy to raise a PR if #11723 isn't accepted and no one else wants to. |
Are there any updates related to that issue? AWS enforces usage of constraints in MWAA:
Due to that, we have a huge problem to install our custom libraries, which need different versions of some dependencies (although we know they won't break anything). |
What's the problem this feature will solve?
Global constraint file that is shared among many related apps where the constraints point to git repos this will allow installing
pip install .
to work for the tox testing environment.Currently you get an error like: ERROR: Could not satisfy constraints for 'app-foo': installation from path or url cannot be constrained to a version
Describe the solution you'd like
pip install --ignore-constraint=app-foo .
Or any other way to suppress this error for installing "."
An example where this is handy is requirements.txt like this:
Where tox installs the project like:
The text was updated successfully, but these errors were encountered: