Skip to content

Cannot use ninja from a venv #600

Description

@stephanlachnit

I'm currently having an issue using meson-python in an environment where I cannot install ninja system-wide.

In particular, I'm in a venv

python3 -m venv venv
source venv/bin/activate
pip install -e . # has `requires = ["meson-python"]`

Which results in the following ninja:

Found ninja-1.11.1.git.kitware.jobserver-1 at /tmp/pip-build-env-3_c2bhz3/normal/bin/ninja

However, this doesn't work in the venv:

>>> import constellation
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1138, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1078, in _find_spec
  File "/home/stephan/Projects/constellation/venv/lib/python3.11/site-packages/_constellation_editable_loader.py", line 271, in find_spec
    tree = self.rebuild()
           ^^^^^^^^^^^^^^
  File "/home/stephan/Projects/constellation/venv/lib/python3.11/site-packages/_constellation_editable_loader.py", line 312, in rebuild
    subprocess.run(self._build_cmd, cwd=self._build_path, env=env, stdout=stdout, check=True)
  File "/usr/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.11/subprocess.py", line 1953, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-build-env-3_c2bhz3/normal/bin/ninja'

I also tried installing ninja in the venv and setting the NINJA env var, but this also doesn't work:

meson-python: error: Could not find ninja version 1.8.2 or newer.

which I think is because this is called outside of the venv - ninja --version in the venv is fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions