-
-
Couldn't load subscription status.
- Fork 1.1k
fix: Improve symlink check and sysconfig path handling #2914
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
Merged
gaborbernat
merged 11 commits into
pypa:main
from
esafak:fix-symlink-check-and-headers-bug
Jul 31, 2025
Merged
fix: Improve symlink check and sysconfig path handling #2914
gaborbernat
merged 11 commits into
pypa:main
from
esafak:fix-symlink-check-and-headers-bug
Jul 31, 2025
+87
−14
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Make `fs_supports_symlink` perform a real symlink creation check on all platforms * Add a test case for environments without symlink support and `--copies` flag * Handle missing keys in `sysconfig_path` to prevent `KeyError` Fixes pypa#2786
gaborbernat
approved these changes
Jul 31, 2025
gaborbernat
requested changes
Jul 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems you have macos brew to fix 🤔
auto-merge was automatically disabled
July 31, 2025 16:24
Pull request was converted to draft
This commit addresses two main issues:
1. A bug where creating a virtual environment on a filesystem without symlink support would fail because the check was not robust enough.
2. A confusing error message when no creation method (symlink or copy) is available.
Summary of changes:
- Modified `fs_supports_symlink` in `src/virtualenv/info.py` to perform a real symlink creation check on all platforms, not just Windows. This ensures that `virtualenv` correctly detects filesystems that do not support symlinks and can fall back to copies.
- Improved the error message in `src/virtualenv/create/via_global_ref/api.py` to be more informative when no creation method is available, showing the reason for each method's failure.
- Added two new tests to `tests/unit/create/test_creator.py`:
- `test_fallback_to_copies_if_symlink_unsupported`: Verifies that `virtualenv` successfully falls back to using copies when symlinks are not supported on a system that allows copying.
- `test_fail_gracefully_if_no_method_supported`: Verifies that `virtualenv` raises a detailed `RuntimeError` on systems where both symlinks and copies are disabled.
- Fixed an unrelated bug in `src/virtualenv/discovery/py_info.py` that caused a `KeyError: 'headers'` during test collection in environments without Python development headers.
- Fixed several linter issues.
The changes have been validated by running a focused set of tests, which all passed.
for more information, see https://pre-commit.ci
…g' into fix-symlink-check-and-headers-bug
* Mock `is_macos_brew` to return `False` to test the generic fallback case. * This allows testing the fallback to copies when symlinks are unsupported.
* Refine test for symlink fallback when copy is unsupported. * Ensure the `is_macos_brew` check is correctly applied. * Update the error message for brew-related copy failures. * Add a skip condition for brew python on macOS to avoid testing unsupported copy scenarios.
gaborbernat
approved these changes
Jul 31, 2025
This was referenced Aug 1, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fs_supports_symlinkperform a real symlink creation check on all platforms--copiesflagsysconfig_pathto preventKeyErrorFixes #2786
tox -e fix)docs/changelogfolder