Skip to content

Document that using meson installed in a virtual environment requires the venv to be activated #630

Closed
@inklesspen

Description

@inklesspen

I create a venv (but do not activate it); instead I explicitly specify the path to the python binary: ../myvenv/bin/python3 -m pip --no-build-isolation -e .

The build fails because it cannot find the meson command. The meson command does exist in the venv; it's just not on the PATH. Note that the venv docs say that activating a venv is not required in order to use it.

Since meson-python expects to be able to use the meson package it includes as a dependency, it should have some way of finding it in the venv that does not depend on the path.

Reproducible example (via Docker)

FROM buildpack-deps

RUN apt update && apt install -y python3-venv python3-dev fonts-texgyre
RUN adduser --disabled-password --comment "" builder

USER builder
WORKDIR /home/builder

RUN python3 -m venv myvenv && /home/builder/myvenv/bin/python3 -m pip install meson ninja meson-python cffi
RUN git clone https://github.com/inklesspen/meson-python-cffi-example.git

WORKDIR /home/builder/meson-python-cffi-example
# specific known commit (current HEAD)
RUN git checkout b83508b99c0edd719475d4f4d5b1cb35e2ef2a50
RUN /home/builder/myvenv/bin/python3 -m pip install --no-build-isolation -e .

(Changing the final line to RUN PATH=/home/builder/myvenv/bin:$PATH /home/builder/myvenv/bin/python3 -m pip install --no-build-isolation -e . allows it to build properly.)

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions