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

In HackedPythonVersion, patch sys.version_info #1076

Merged
merged 2 commits into from
Nov 16, 2017
Merged

Conversation

vphilippon
Copy link
Member

This is required to have pip/pip-tools get the right wheels according to
the project virtualenv python version.

Should completely fix #857, and the likes.

/cc @kennethreitz @erinxocon @nateprewitt @techalchemy

@vphilippon
Copy link
Member Author

sigh
Note to self: Always re-run your code at least once before the push.

def __init__(self, python_version, python_path):
self.python_version = python_version
self.python_path = python_path

def __enter__(self):
os.environ['PIP_PYTHON_VERSION'] = str(self.python_version)
os.environ['PIP_PYTHON_PATH'] = str(self.python_path)
self.backup_version_info = sys.version_info
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this being used by pip-tools or is it being added as a nice to have for use later?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's to reset sys.version_info outside of the context manager (in __exit__). We don't want that patched thing globally.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or was your question "Why are we patching sys.version_info? That's for pip to generate the right list of pep425 tags for wheel selection, i.e. Pick the right wheel for the right python version in the managed venv.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that makes sense. Thanks for clarifying!

This is required to have pip/pip-tools get the right wheels according to
the project virtualenv python version.
@nateprewitt
Copy link
Member

🛬 Landing, thanks @vphilippon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lock file differs depending on Python version of Pipenv installation
2 participants