fix(env): ensure all system site paths are used#9942
Merged
abn merged 3 commits intopython-poetry:mainfrom Jan 6, 2025
Merged
Conversation
bd1aab7 to
abcc889
Compare
Member
Author
|
@sourcery-ai review |
Reviewer's Guide by SourceryThis pull request fixes a bug in Poetry where read-only system site packages were not being considered when an environment is loaded in newer Python versions (>=3.12). This is achieved by adding a fallback mechanism to include system site packages when constructing the environment's site packages. Sequence diagram for environment path resolutionsequenceDiagram
participant Poetry
participant BaseEnv
participant Python
Poetry->>BaseEnv: Initialize environment
BaseEnv->>Python: Get paths (GET_PATHS script)
Python-->>BaseEnv: Return paths including system site packages
BaseEnv->>BaseEnv: Initialize site_packages
Note over BaseEnv: Now includes fallback paths
BaseEnv-->>Poetry: Return initialized environment
Class diagram showing the updated BaseEnv class structureclassDiagram
class BaseEnv {
-_purelib: Path
-_platlib: Path
-_fallbacks: list[Path]
-_site_packages: SitePackages
+site_packages: SitePackages
+purelib: Path
+platlib: Path
+fallbacks: list[Path]
-_get_lib_dirs(): list[Path]
}
class SitePackages {
+purelib: Path
+platlib: Path
+fallbacks: list[Path]
}
BaseEnv --> SitePackages: creates
note for BaseEnv "Added fallbacks property and
modified _get_lib_dirs to include
fallback paths"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @abn - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
72efd57 to
dc4c68c
Compare
Secrus
reviewed
Jan 6, 2025
With this change, when using newer Python versions (>=3.12), Poetry correctly detects and considers read-only system site packages when an environment is loaded. Resolves: python-poetry#9878
dc4c68c to
3dd85d5
Compare
Secrus
approved these changes
Jan 6, 2025
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
With this change, when using newer Python versions (>=3.12), Poetry
correctly detects and considers read-only system site packages when
an environment is loaded.
Resolves: #9878
An example of this scenario is when the OS distributions manages your Python installations, you can end up with the following.
You can see that both
platlibandpurelibuses the/usr/localprefix. While the system installation site uses the/usrprefix.Summary by Sourcery
Include system site packages when loading a Python environment.
Bug Fixes:
Enhancements:
purelibandplatlib.