-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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(env): ensure all system site paths are used #9942
Conversation
bd1aab7
to
abcc889
Compare
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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
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
platlib
andpurelib
uses the/usr/local
prefix. While the system installation site uses the/usr
prefix.Summary by Sourcery
Include system site packages when loading a Python environment.
Bug Fixes:
Enhancements:
purelib
andplatlib
.