-
Notifications
You must be signed in to change notification settings - Fork 63
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
New target property for specifying Python version #2332
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThe recent changes enhance the Python version compatibility handling in the Changes
Sequence DiagramssequenceDiagram
participant User
participant PythonGenerator
participant Property
User->>PythonGenerator: Initiate Target Setup
PythonGenerator->>Property: Fetch PythonVersionProperty
PythonGenerator-->>PythonGenerator: Set `pyVersion` (Default: 3.8)
PythonGenerator->>PythonFinder: find_package(Python <pyVersion> REQUIRED COMPONENTS Interpreter Development)
Note over User,PythonGenerator: Setup Completed with appropriate Python version
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- core/src/main/java/org/lflang/generator/python/PythonGenerator.java (4 hunks)
- core/src/main/java/org/lflang/target/Target.java (2 hunks)
- core/src/main/java/org/lflang/target/property/PythonVersionProperty.java (1 hunks)
Files skipped from review due to trivial changes (1)
- core/src/main/java/org/lflang/target/property/PythonVersionProperty.java
Additional comments not posted (4)
core/src/main/java/org/lflang/target/Target.java (2)
63-63
: Import Statement for PythonVersionProperty Looks GoodThe addition of the
PythonVersionProperty
import is necessary for the changes made in theinitialize
method for the Python target configuration.
644-645
: Proper Initialization of PythonVersionProperty in Target ConfigurationThe addition of
PythonVersionProperty
to the Python target's initialization list correctly implements the functionality described in the PR. This allows users to specify the Python version, enhancing configurability.core/src/main/java/org/lflang/generator/python/PythonGenerator.java (2)
64-64
: Import Statement for PythonVersionProperty is CorrectThe import of
PythonVersionProperty
is essential for utilizing this property in the Python code generation logic.
92-92
: Addition of Static FieldpythonVersion
is AppropriateThe introduction of the
pythonVersion
static field is necessary to store the user-specified Python version. This field is used effectively in thesetUpMainTarget
method to determine the Python version for package configuration.
core/src/main/java/org/lflang/generator/python/PythonGenerator.java
Outdated
Show resolved
Hide resolved
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- core/src/main/java/org/lflang/generator/python/PythonGenerator.java (4 hunks)
Files skipped from review as they are similar to previous changes (1)
- core/src/main/java/org/lflang/generator/python/PythonGenerator.java
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- core/src/main/java/org/lflang/generator/python/PythonGenerator.java (5 hunks)
- core/src/main/java/org/lflang/target/Target.java (2 hunks)
- core/src/main/java/org/lflang/target/property/PythonVersionProperty.java (1 hunks)
Files skipped from review as they are similar to previous changes (3)
- core/src/main/java/org/lflang/generator/python/PythonGenerator.java
- core/src/main/java/org/lflang/target/Target.java
- core/src/main/java/org/lflang/target/property/PythonVersionProperty.java
core/src/main/java/org/lflang/generator/python/PythonGenerator.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/lflang/generator/python/PythonGenerator.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/lflang/generator/python/PythonGenerator.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/lflang/target/property/PythonVersionProperty.java
Show resolved
Hide resolved
core/src/main/java/org/lflang/generator/python/PythonGenerator.java
Outdated
Show resolved
Hide resolved
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.
Thanks for addressing the feedback! Looks much better now. Please still get rid of the static variable.
Note also this comment. |
59618b7
to
634bda0
Compare
634bda0
to
d14ae87
Compare
10d8f07
to
1023172
Compare
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.
Looks good now, but I'd like to discuss this feature in the developer meeting because I'd like to better understand how this would interact with virtual environments.
Looks like |
if (!version.isEmpty() && !version.contains("3.10")) { | ||
reporter | ||
.at(config.lookup(this), Literals.KEY_VALUE_PAIR__NAME) | ||
.warning( |
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.
@cmnrd: note that we issue a warning if anything other than 3.10
is selected.
I've conducted a series of tests to evaluate Python version detection in various environments: 1. Python 3.10 Virtual Environment
2. Python 3.11 Virtual Environment
3. Global Python Environment
Result: Correct Python interpreter found Based on these tests, it appears that Our current approach allows users to manage their Python environments and this PR provides an option for them to set the Python version used by LF. |
I can confirm this also for venv with cmake 3.30 on Linux. When the virtual environment is disabled, cmake uses the system's interpreter. When it is active, it uses the interpreter from the virtual environment. I also found out that |
This PR introduces a new target property
python-version
that allows users to explicitly specify the Python version to be used.Related Issues and PR:
Issue #2298
Issue #2299
PR #2292
Example:
If
python-version
is not specified, the system will default to using Python 3.10 or newer.Summary by CodeRabbit
New Features
Improvements