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

Python 3 can't be found on NetBSD 8.0 or DragonFlyBSD 5.2 #4608

Open
nomis opened this issue Dec 9, 2018 · 8 comments
Open

Python 3 can't be found on NetBSD 8.0 or DragonFlyBSD 5.2 #4608

nomis opened this issue Dec 9, 2018 · 8 comments

Comments

@nomis
Copy link
Contributor

nomis commented Dec 9, 2018

meson.build

...
python3 = import('python').find_installation('python3')
...

NetBSD 8.0

Version: 0.48.1
...
meson.build:79:0: ERROR:  python3 not found
$ echo $PATH
/home/simon/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R7/bin:/usr/pkg/bin:/usr/pkg/sbin:/usr/games:/usr/local/bin:/usr/local/sbin:/home/simon/.local/bin
$ which python3
$ which python3.6
/usr/pkg/bin/python3.6

DragonflyBSD 5.2

Version: 0.46.1
...
meson.build:79:0: ERROR:  python3 not found
$ echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/pkg/sbin:/usr/pkg/bin:/home/simon/bin:/home/simon/.local/bin
$ which python3
$ which python3.6
/usr/local/bin/python3.6
@nomis nomis changed the title Python 3 can't be found on NetBSD 8.0 Python 3 can't be found on NetBSD 8.0 or DragonFlyBSD 5.2 Dec 9, 2018
@nomis
Copy link
Contributor Author

nomis commented Dec 9, 2018

It seems I'm confusing find_program() with pymod.find_installation()...

@nomis nomis closed this as completed Dec 9, 2018
@nomis
Copy link
Contributor Author

nomis commented Dec 9, 2018

I've reopened this because pymod.find_installation() can't find python3 either.

The standard Python 3 package on these systems does not provide a python3 command.

@nomis nomis reopened this Dec 9, 2018
@jpakkane
Copy link
Member

jpakkane commented Dec 9, 2018

Does this work:

python3 = import('python').find_installation()

@nomis
Copy link
Contributor Author

nomis commented Dec 9, 2018

Yes that works... I think I'll use that instead

@jtojnar
Copy link
Contributor

jtojnar commented Jul 5, 2020

IMHO, the fact that Meson uses Python 3 should be an implementation detail. Ideally, we would try to find any python3.x executable on PATH on BSDs but something like this might cover most use cases as it will make find_installation('python3') fall back to the same value as find_installation():

--- a/mesonbuild/modules/python.py
+++ b/mesonbuild/modules/python.py
@@ -534,6 +534,11 @@ class PythonModule(ExtensionModule):
             if not python.found() and name_or_path in ['python2', 'python3']:
                 python = ExternalProgram('python', silent=True)
 
+            # Even more dire effort, Meson must be using python3,
+            # even though it might be a minimal bootstrapping instance.
+            if not python.found() and name_or_path == 'python3':
+                python = ExternalProgram('python3', mesonlib.python_command, silent=True)
+
         if python.found() and want_modules:
             for mod in want_modules:
                 p, out, err = mesonlib.Popen_safe(

I am definitely against find_installation without arguments and would like to deprecate it: #7415

jtojnar added a commit to jtojnar/meson that referenced this issue Jan 30, 2022
If the project wants Python 3 but it cannot be found any other way,
let’s fall back to the Python installation used by Meson.

This can be useful for some BSDs that use names like python3.9.

Partially fixes: mesonbuild#4608
jtojnar added a commit to jtojnar/meson that referenced this issue Jan 30, 2022
If the project wants Python 3 but it cannot be found any other way,
let’s fall back to the Python installation used by Meson.

This can be useful for some BSDs that use names like python3.9.

Partially fixes: mesonbuild#4608
@arrowd
Copy link

arrowd commented May 7, 2022

This is still a problem for FreeBSD too:

python3 = import('python').find_installation('python3')
# which python3.7
/usr/local/bin/python3.7
Program python found: NO

meson.build:47:0: ERROR: python3 not found

@eli-schwartz
Copy link
Member

This is still a FreeBSD bug, meson.build asked for the $PATH lookup key command -v python3 and you're bringing evidence that command -v python3.7 exists, which is an entirely different lookup key.

Moreover, it's conceptually broken because FreeBSD is directly refusing to comply with https://peps.python.org/pep-0394/ and as a result probing does not work, whether that probing is done by Meson or any other software.

You are of course welcome to use https://mesonbuild.com/Machine-files.html to override the locations of programs, for example by instructing meson to find the python3 program at /usr/local/bin/python3.7 - this is very similar to how with most autotools build systems you would override the path of python by setting the $PYTHON environment variable in the ./configure command line.

Meson could in theory fall back again to the python it knows exists due to having it as sys.executable, but this then makes people who have Meson installed with python 3.7 but want to build software for python 3.9, to be unhappy when it gets built for 3.7 instead...

@arrowd
Copy link

arrowd commented May 11, 2022

This is still a FreeBSD bug, meson.build asked for the $PATH lookup key command -v python3 and you're bringing evidence that command -v python3.7 exists, which is an entirely different lookup key.

Ah, I see. I had an expectation that find_installation('python3') means "find any Python 3 installation", not literally "find an executable named python3".

Moreover, it's conceptually broken because FreeBSD is directly refusing to comply with https://peps.python.org/pep-0394/ and as a result probing does not work, whether that probing is done by Meson or any other software.

It seems you're right. I'll bring this up on our side, thanks.

You are of course welcome to use https://mesonbuild.com/Machine-files.html to override the locations of programs, for example by instructing meson to find the python3 program at /usr/local/bin/python3.7 - this is very similar to how with most autotools build systems you would override the path of python by setting the $PYTHON environment variable in the ./configure command line.

Yep, this sounds like a most sane workaround for now, I'll try it.

Thanks for your input!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants