Skip to content
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: PythonInterp: Fixed a bug related to python detection #11986

Merged

Conversation

SebastianBoe
Copy link
Collaborator

Fixed #11980, a bug where a build failure occured when 'python' was
not on path.

There was a bug in the implementation where it failed to detect that
'python' was not on path. This is now fixed.

Signed-off-by: Sebastian Bøe sebastian.boe@nordicsemi.no

Fixed zephyrproject-rtos#11980, a bug where a build failure occured when 'python' was
not on path.

There was a bug in the implementation where it failed to detect that
'python' was not on path. This is now fixed.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
@SebastianBoe SebastianBoe added bug The issue is a bug, or the PR is fixing a bug Trivial Changes that can be reviewed by anyone, i.e. doc changes, minor build system tweaks, etc. labels Dec 10, 2018
@@ -54,7 +54,7 @@ endfunction()
# and choose it if it does. This gives this executable the highest
# priority, which is expected behaviour.
find_program(PYTHON_EXECUTABLE python)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this look for an executable called python? That won't work on most systems, as python is usually Python 2.

I still get Python 3.4 on my system, even though I have 3.6 and 3.7 as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this look for an executable called python?

yes

That won't work on most systems, as python is usually Python 2.

It still works, this is only one piece in the "find python" machinery.

I still get Python 3.4 on my system, even though I have 3.6 and 3.7 as well.

What is the output of "which python", and "which python3" on your system? (And what is the versions of these outputs?)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ulf huvuddator ~ $ which python python3
/usr/bin/python
/usr/bin/python3
ulf huvuddator ~ $ python --version
Python 2.7.15+
ulf huvuddator ~ $ python3 --version
Python 3.6.7

Copy link
Collaborator

@ulfalizer ulfalizer Dec 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here's what CMake says:

-- Found PythonInterp: /usr/bin/python3.4 (found suitable version "3.4.9", minimum required is "3.4")`

That's what gets used too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I guess we should have python3 take priority over python3.4.

But I'm a bit busy at the moment, so I don't have time to implement this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[activate] will change your $PATH so its first entry is the virtualenv’s bin/ directory. (You have to use source because it changes your shell environment in-place.) This is all it does; it’s purely a convenience.

https://virtualenv.pypa.io/en/latest/userguide/?highlight=activate#activate-script
https://virtualenv.pypa.io/en/latest/

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree to document it but disagree to use the latest. We can always specify what to use with -DPYTHON_EXECUTABLE. The default should be latest stable interpreter, which is whatever python3 points to. Or at least that's what I thought.

CMake version 3.12 introduced FindPython which seems to find Python 3.7 even if my python3 points to 3.6. 🤔 If we are going to use FindPython when we require new version of CMake, it might be better to behave the same way?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMake version 3.12 introduced FindPython which seems to find Python 3.7 even if my python3 points to 3.6. thinking If we are going to use FindPython when we require new version of CMake, it might be better to behave the same way?

Maybe, let's deal with that question when we get there.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels a bit magic to me to assume that whatever python3 points to is what's intended to be used. Always use latest is super simple, and it's backwards compatible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to be the priority:

'python'
'python3'
'python3.x'

This makes sense to me. Is simple to understand, and meets the requirements described in: #11857

@codecov-io
Copy link

Codecov Report

Merging #11986 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #11986   +/-   ##
=======================================
  Coverage   48.13%   48.13%           
=======================================
  Files         281      281           
  Lines       43425    43425           
  Branches    10406    10406           
=======================================
  Hits        20902    20902           
  Misses      18368    18368           
  Partials     4155     4155

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5e7c916...18d44d2. Read the comment docs.

@SebastianBoe
Copy link
Collaborator Author

@carlescufi , @nashif : This is a trivial bugfix that is affecting users, would be good to get it in quickly.

Copy link
Member

@mnkp mnkp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes the issue on my Ubuntu 18.04.1 LTS machine.

@carlescufi carlescufi merged commit 8077b10 into zephyrproject-rtos:master Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug Trivial Changes that can be reviewed by anyone, i.e. doc changes, minor build system tweaks, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cmake: Build fails in an environment without python binary
6 participants