mesonbuild / meson-python

Meson PEP 517 Python build backend
https://mesonbuild.com/meson-python/
MIT License
125 stars 65 forks source link

FileNotFoundError: [Errno 2] No such file or directory: 'meson' when building wheel #572

Closed jeanbaptistelab closed 7 months ago

jeanbaptistelab commented 7 months ago

Attempting to build a wheel on a sytem without meson fails with the above exception.

Here is a shortened stacktrace (emphasis is mine):

python3 -m pip wheel -v --no-clean .
...
  Running command pip subprocess to install build dependencies
  Collecting meson-python
    Using cached meson_python-0.15.0-py3-none-any.whl (25 kB)
  **Collecting meson>=0.63.3
    Using cached meson-1.3.1-py3-none-any.whl (976 kB)**
...
  Installing backend dependencies ... done
  Running command Preparing metadata (pyproject.toml)
  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 156, in prepare_metadata_for_build_wheel
      hook = backend.prepare_metadata_for_build_wheel
  AttributeError: module 'mesonpy' has no attribute 'prepare_metadata_for_build_wheel'
...
      File "/tmp/pip-build-env-f9rx7mh4/overlay/local/lib/python3.10/dist-packages/mesonpy/__init__.py", line 947, in _get_meson_command
      meson_version = subprocess.run(cmd + ['--version'], check=False, text=True, capture_output=True).stdout
    File "/usr/lib/python3.10/subprocess.py", line 503, in run
      with Popen(*popenargs, **kwargs) as process:
    File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
      self._execute_child(args, executable, preexec_fn, close_fds,
    File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child
      raise child_exception_type(errno_num, err_msg, err_filename)
  **FileNotFoundError: [Errno 2] No such file or directory: 'meson'**
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /usr/bin/python3 /usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp633ix8cg
  cwd: /home/jbl/workspace/PyCSH
  Preparing metadata (pyproject.toml) ... error
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Some interesting facts: meson is being installed during the build process but isn't detected by meson-python:

jbl@jbl-ThinkPad-T15-Gen-1:~/workspace/PyCSH$ ls -la /tmp/pip-build-env-f9rx7mh4/overlay/local/bin
total 12
drwxrwxr-x 2 jbl jbl 4096 Feb  7 13:39 .
drwxrwxr-x 5 jbl jbl 4096 Feb  7 13:39 ..
-rwxrwxr-x 1 jbl jbl  219 Feb  7 13:39 meson
jbl@jbl-ThinkPad-T15-Gen-1:~/workspace/PyCSH$ 

It seems meson-python isn't able to correctly bootstrap itself, requiring an already installed, external, PATH available installation of meson.

eli-schwartz commented 7 months ago

(The first part of your codeblock paste appears to have typoed backticks as dots.)

As far as I know, pip is responsible for adding that overlay/local/bin path to the environment before running the build backend (meson-python). I seem to recall they had a bug like this and fixed it, though.

What's your version of pip?

jeanbaptistelab commented 7 months ago

The error was seen with pip 22.0.2.

I've updated to pip 24.0 and that seems to have sorted it

dnicolodi commented 7 months ago

Yes, it is a bug in pip.