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

Fix #1949: zipapp virtual environment creation fails if zipapp path is symlinked #2722

Merged
merged 6 commits into from
May 11, 2024

Conversation

HandSonic
Copy link
Contributor

Original issue: #1949

Added test for pull #2613

The function in question assumes that ROOT is a prefix of full_path, and tries to remove it. However, it is not necessarily a prefix:

  • when ROOT is determined, both os.path.abspath() and os.path.realpath() gets called
  • when full_path is determined, only os.path.abspath() is called

This means that if the path contains a symlink, it will show up as resolved in ROOT, but not full_path, so simply removing the first X characters of full_path is not sufficient.

This PR adds an assertion to catch the bad situation early, then adds the os.path.realpath call to full_path.

  • ran the linter to address style issues (tox -e fix)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added news fragment in docs/changelog folder
  • updated/extended the documentation

@HandSonic HandSonic marked this pull request as ready for review May 11, 2024 09:22
src/virtualenv/util/zipapp.py Outdated Show resolved Hide resolved
src/virtualenv/util/zipapp.py Outdated Show resolved Hide resolved
@HandSonic HandSonic requested a review from gaborbernat May 11, 2024 17:12
@gaborbernat gaborbernat enabled auto-merge (squash) May 11, 2024 17:16
@gaborbernat gaborbernat merged commit 0a3816e into pypa:main May 11, 2024
47 checks passed
@HandSonic HandSonic deleted the Fix-#1949 branch May 12, 2024 12:06
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.

2 participants