Pipenv: Support for pip --constraint

Created on 21 Sep 2020  路  6Comments  路  Source: pypa/pipenv

Is your feature request related to a problem? Please describe.

Some projects recommend installing using pip with --constraint:
pip install \
apache-airflow==1.10.12 \
--constraint "https://raw.githubusercontent.com/apache/airflow/constraints-1.10.12/constraints-3.7.txt"

It would be nice to have an equivalent pipenv command. The idea is that some project already provide all the resolved dependencies (an equivalent of the Pipfile.lock file) that should be input to the dependency resolution step.

Describe the solution you'd like

Add a --constraint parameter to pipenv that behaves as pip --constraint does.

Describe alternatives you've considered

I think there is no alternative but to drop the --constraint and hope that the dependencies' version resolved by pipenv match the ones that in the project's constraints.

Additional context

Discussion Type Type

All 6 comments

I feel it would be much more explicit (and reproducible) if the constraints are put directly into Pipfile. Maybe what we should do instead is to have a way to sync constraint files and Pipfile, instead

This feature would actually be required right now to lock dependencies, if you use the project mentioned by the author - Apache Airflow. Installing packages via pipenv just doesn't work because locking fails, the only way to update packages is with pip and --constraint flag, see issue

@aidar-ms I read the linked issue and it doesn't seem a problem.

did you pin attrs package version at 19.3 anywhere in the project

Yes, it is specified in 1.10.12 setup.py:
https://github.com/apache/airflow/blob/6416d898060706787861ff8ecbc4363152a35f45/setup.py#L553

Thanks, I've checked it.
The problem still persists though. Airflow's setup.py file in their master branch used to be pinned at 19.3, but now it's at 'attrs>=20.0, <21.0'. When I do pipenv graph, here's what I see in dependencies under apache-airflow:

apache-airflow==1.10.12
  ...
  - attrs [required: ~=19.3, installed: 19.3.0]

Trying to lock dependencies results in error whatever the version I try:

ERROR: ERROR: Could not find a version that matches attrs>=17.3.0,>=17.4.0,>=20.1.0,~=19.3

Hence why I created the issue in Airflow's repo and they pointed me to the section in their docs where it's suggested to install dependencies with --constraint flag, which afaik is not doable with pipenv currently, but supposedly it would've solved my problem + the issue of the author and people who've thumbed it up.

Airflow's setup.py file in their master branch used to be pinned at 19.3, but now it's at 'attrs>=20.0, <21.0'.

but you are not using the master branch, are you?

what i want to emphasize is pipenv's lock file isn't wrong

Ok, I understand now. I'm a bit unfamiliar with how pypi packaging works and pipenv locking exactly work.

I was suspecting the recent updates to Airflow's master somehow affected the error, because the error message:

ERROR: ERROR: Could not find a version that matches attrs>=17.3.0,>=17.4.0,>=20.1.0,~=19.3

states that some dependency requires attrs to be greater than or equal to 20.1.0. But according to pipenv graph, no package whatsoever sets attrs at 20.1.0. How can there be a requirement for >=20.1.0 if pipenv graph shows nothing? I even installed the package with --skip-lock and re-inspected dependencies with graph. Nowhere there is a >=20.1.0. But trying to lock dependencies only leads to error with the above message.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jeyraof picture jeyraof  路  3Comments

jakul picture jakul  路  3Comments

Californian picture Californian  路  3Comments

ipmb picture ipmb  路  3Comments

jerzyk picture jerzyk  路  3Comments