-
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): isolated env must validate requirements #10048
Conversation
This change ensures that when an isolated environment is created, the temporary lockfile created does not consider dependencies that are not valid for the environment. This reduces the possibility of constraint errors when building dependencies from source that use complex build-system requirements. Resolves: python-poetry#8409
@sourcery-ai review |
Reviewer's Guide by SourceryThis pull request fixes a bug in the isolated environment creation process where invalid dependencies were considered during temporary lockfile creation. This change ensures that only valid dependencies for the target environment are considered, reducing the risk of constraint errors during dependency resolution. Sequence diagram for isolated environment dependency validationsequenceDiagram
participant IsolatedEnv as IsolatedEnvironment
participant Package as ProjectPackage
participant Dep as Dependency
participant Marker as Marker
IsolatedEnv->>Package: Create root package
IsolatedEnv->>IsolatedEnv: Get environment markers
loop For each requirement
IsolatedEnv->>Dep: Create from PEP 508
IsolatedEnv->>Marker: Validate dependency marker
alt Marker is empty or valid
IsolatedEnv->>Package: Add dependency
else Invalid for environment
Note over IsolatedEnv: Skip dependency
end
end
Flow diagram for dependency validation processflowchart TD
A[Start] --> B[Create root package]
B --> C[Get environment markers]
C --> D[Get next requirement]
D --> E{Create dependency}
E --> F{Check marker}
F -->|Empty marker| H[Add dependency]
F -->|Valid for env| H
F -->|Invalid for env| I[Skip dependency]
H --> J{More requirements?}
I --> J
J -->|Yes| D
J -->|No| K[End]
File-Level Changes
Possibly linked issues
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 - here's some feedback:
Overall Comments:
- Could you explain why the expected VirtualEnv.run call count in test_info_setup_simple increased from 4 to 6? This change seems unrelated to the main PR changes.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟡 Testing: 1 issue found
- 🟢 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.
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.
This only sorts out direct dependencies. Transitive dependencies that are not valid for the environment will still be considered. However, since it is a simple change and a clear improvement - and a complete fix would take more effort - I think we can merge it anyway.
This change ensures that when an isolated environment is created, the temporary lockfile created does not consider dependencies that are not valid for the environment. This reduces the possibility of constraint errors when building dependencies from source that use complex build-system requirements.
Resolves: #8409
Summary by Sourcery
Validate dependencies before installing them in an isolated environment. This prevents constraint errors during dependency resolution, especially for complex build systems.
Bug Fixes:
Tests: