-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
cmake: Simplify python finding #65995
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Oops, something went wrong.
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.
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.
But you are changing this functionality which is described here: https://github.com/zephyrproject-rtos/zephyr/blob/main/cmake/modules/west.cmake#L11
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.
I think this is exactly the problem, as WEST_PYTHON doesn't seem to use the path to the symlinked python interpreter in my virtualenv?
Like if I were to keep the existing find python code, it finds not the virtualenv python but the actual installed python on my system, and this isn't correct!
Shouldn't this simply be finding the python that is my path not trying to do some odd "yeah but use the one west was called with" nonsense?
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.
Then you've installed west at a system level, you can't have it both ways, either install west and all zephyr dependencies at a system level, or install them at a virtual env level, not one at system and rest in virtual env.
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.
Both west and python are installed in the virtualenv, and no it doesn't choose the virtualenv python it uses the system python.
It does this because the static link is looked past in west.cmake I believe? Like with nix there's two levels of python environments basically... the actual interpreter, the interpret + python packages, then my virtualenv.
Without this patch I get...
With this patch cmake correctly chooses my virtualenv python as the executable.
Hard to understand why any of this cmake to root out a different python interpreter is even needed, if I have python in my path it should be choosing the first python in my path not go spelunking into the static links looking for something.
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.
@teburd could you move this data to a new bug?
EDIT:
Isn't the answer in your commit message? "Now that the minimum version required is 3.20,..."
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.
I'd be happy with an explanation as to why west.cmake tries to find the real python elf. I couldn't find one in the git history or file comments.
Python is also broken on archlinux for me and has been for a long time, which is why I ended up using nix in the first place. Because I was tired of seeing some python dep suddenly breaking when python was updated on there.
Current situation on my arch machine without this patch..
With this patch...
So no its not just nix actually
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 would only be the case if you did something like ignore this warning:
If you ignore it, you do so at your own risk, which may or may not work for you (personally for me, it's been working fine on the same VM for years)
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.
I never saw a warning like the above, but I guess there's no argument convincing enough here for you.
As I said, I'd be happy with an explanation as to why west.cmake code in particular does what it does. The git history and file have no clues for me.
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.
Did you look here: 9284e60
or here: #34368
Generally speaking, the CMake find python handling has always been broken when having more than just a single python interpreter installed.
If not using
venv
and having multiple Pythons installed, but only thewest
package / other Zephyr required pip-packages in one of them can give strange results if using the plain CMake FindPython3 mechanism.That said, CMake's FindPython3 has improved significantly over the years, and is quite good nowadays.
Also we have a requirement / expectation that if
west build
is used for building Zephyr, then we want to use that exact same Python interpreter that was used for invokingwest
.A bit of some history to check up on, to see what we have tried to handle:
Please take a look at the history, some PRs and issues (note, the list is not exhaustive):
PRs
Issues:
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.
Noticing this:
is this only a problem when building the docs or also in general ?
Cause in this particular case then
west
is not used to invoke the build and hence theWEST_PYTHON
is not set.Did you try to set
Python3_EXECUTABLE
pointing directly to the interpreter you want ?(not because that's what you should generally do, but in order to help further investigations)