-
Notifications
You must be signed in to change notification settings - Fork 66
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
Document that using meson installed in a virtual environment requires the venv to be activated #630
Comments
The I don't understand why you don't want to set |
At the very least it could be documented that the venv bin directory has to be on the PATH for meson-python to work. |
I agree - given how much trouble the The one place where we already mention a virtual environment is at meson-python/docs/tutorials/introduction.rst Line 236 in 0d2df77
|
AFAICT the venv documentation says that you can avoid activating a venv if the only thing you want to do is to run the Python linked in the the venv by invoking it with the full path. Emphasis on the only thing you want to do is to run Python. I consider this advanced usage and I am surprised that someone that does this (or went all the way to read the documentation to learn it is a possibility) does not realize that this does not allow to run other executables installed in the venv. The documentation is pretty clear about how a venv works and what activation does. The fact that other executables installed in the venv would not be found logically follows. I'm not opposed to add a sentence to the documentation (although anticipating all the ways in which people can shoot themself in the foot makes for very hard to read documentation). However, the title of this ticked need to be changed, there is nothing wrong with what meson-python does. |
Sorry, but that page does say
and
and
Maybe this is a bonkers way to use the venv, but that's what the venv docs say. |
Yeah, it is confusing. The My random guess is that it's emphasized because the activation command is platform-dependent (at least Windows is different), which is annoying. I was just working on a documentation update now. |
I do agree with this. Any Python package may rely on an executable being on the path. E.g., an IDE like Spyder may run a CLI tool like |
PR to address this: gh-634. |
And you're trying to do something that is neither invoking a script in the venv, nor trying to directly run the venv python. I agree with @rgommers that the documentation is just really poor here. Fundamentally, the venv docs are attempting to make a statement about reality. They aren't saying all software is supposed to make it work - they are saying that software inherently works whether you try to make it work or not, "because shebangs". The problem is that having a shebang just means if you do run a script, the script doesn't execute using a wrong non-venv python. It doesn't mean that scripts are in PATH and usable to other software. Part of the issue with venv's robustness of documentation is that the target userbase of the docs is not people who do complex things. It's people who don't know much about python, and are being told by the same documentation writers that the only way to safely use python is to have one venv per script and use tools like pipx to make sure they are all in PATH because it's too dangerous to try to manually get it correct. They're being told it's dangerous to use a venv for multiple purposes (like having a single copy of pytorch or SciPy/NumPy used in multiple contexts) and that they should just bite the bullet and have 16 different copies in as many venvs scattered around their home directory. They're also told "editable installs are something you should not use. They're only for developers." |
@inklesspen |
I use direnv, actually. |
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. Themeson
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)
(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.)The text was updated successfully, but these errors were encountered: