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

sys_platform and python_version env markers in requirements files should respect --platform and --python-version #6117

Closed
chadrik opened this issue Jan 7, 2019 · 2 comments
Labels
C: download About fetching data from PyPI and other sources state: awaiting PR Feature discussed, PR is needed type: enhancement Improvements to functionality

Comments

@chadrik
Copy link

chadrik commented Jan 7, 2019

Environment

  • pip version: 18.0
  • Python version: 2.7.7
  • OS: centos 7

Description

pip download allows you to specify an explicit platform (--platform) and python version (--python-version) which overrides the current environment, however, the sys_platform and python_version markers in requirements files still use the current environment, making them useless in practice.

Expected behavior

sys_platform and python_version markers should be overridden by --platform and --python-version .

How to Reproduce

create a requirments.txt file:

future  ; python_version < '3.0'

Install from python2 for python3:

$ python2 -m pip download --python-version 36 --abi cp36m --platform linux_x86_64 -r requirements.txt --only-binary=:all:

the future package should be skipped because we're trying to download packages for python 3.6 and the marker specifies that it should only be installed for python_version < '3.0', but because the current python interpreter is 2.7, pip attempts to download it anyway.

Output

Collecting future (from -r requirements.txt (line 9))
  Could not find a version that satisfies the requirement future (from -r requirements.txt (line 9)) (from versions: )
No matching distribution found for future (from -r requirements.txt (line 9))

Expected Output

Ignoring future: markers 'python_version < "3.0"' don't match your environment
@chadrik chadrik changed the title download: environment markers in requirements files should use those given on command-line sys_platform and python_version env markers in requirements files should use --platform and --python-version Jan 7, 2019
@pradyunsg pradyunsg added the S: needs triage Issues/PRs that need to be triaged label Jan 20, 2019
@cjerdonek cjerdonek added C: download About fetching data from PyPI and other sources type: enhancement Improvements to functionality and removed S: needs triage Issues/PRs that need to be triaged labels May 25, 2019
@cjerdonek
Copy link
Member

I just posted PR #6591 ("Add a TargetPython class"), which should help some more with this.

@chrahunt chrahunt changed the title sys_platform and python_version env markers in requirements files should use --platform and --python-version sys_platform and python_version env markers in requirements files should respect --platform and --python-version Oct 13, 2019
@chrahunt chrahunt added the state: awaiting PR Feature discussed, PR is needed label Nov 16, 2019
@pradyunsg
Copy link
Member

Consolidating this into #11664

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: download About fetching data from PyPI and other sources state: awaiting PR Feature discussed, PR is needed type: enhancement Improvements to functionality
Projects
None yet
Development

No branches or pull requests

4 participants