Repository navigation
Add ninja.__main__ #36
Description
Activity
Why is this weird? ninja isn't Python. https://ninja-build.org/ it's a command line tool.
It makes it impossible to run ninja given only the path to a venv python executable, which can happen in another python command in that venv wanting to use
sys.executableto subprocess another command known to be in that venv, e.g. google/pytype#642 (comment)- added a commit that references this issue
on Sep 4, 2020 Thanks for the feedback 🙏
- linked a pull request that will close this issueAdd support for running ninja as python module #37
on Sep 4, 2020 nathanielmanistaatgoogle commented
on Sep 7, 2020 AuthorMore actions@gpshead: Two reasons:
-
Given
user@host:~/temp-temp$ ./my_venv/bin/pip --version pip 20.2.2 from /usr/local/google/home/nathaniel/temp-temp/my_venv/lib/python3.8/site-packages/pip (python 3.8) user@host:~/temp-temp$ ./my_venv/bin/python -m pip --version pip 20.2.2 from /usr/local/google/home/nathaniel/temp-temp/my_venv/lib/python3.8/site-packages/pip (python 3.8) user@host:~/temp-temp$ ./my_venv/bin/pytype --version 2020.08.28 user@host:~/temp-temp$ ./my_venv/bin/python -m pytype --version 2020.08.28 user@host:~/temp-temp$ ./my_venv/bin/pylint --version pylint 2.6.0 astroid 2.4.2 Python 3.8.5 (default, Jul 20 2020, 18:32:44) [GCC 9.3.0] user@host:~/temp-temp$ ./my_venv/bin/python -m pylint --version pylint 2.6.0 astroid 2.4.2 Python 3.8.5 (default, Jul 20 2020, 18:32:44) [GCC 9.3.0] user@host:~/temp-temp$ ./my_venv/bin/nuitka3 --version 0.6.8.4 Python: 3.8.5 (default, Jul 20 2020, 18:32:44) Executable: /usr/local/google/home/nathaniel/temp-temp/my_venv/bin/python3 OS: Linux Arch: x86_64 user@host:~/temp-temp$ ./my_venv/bin/python -m nuitka --version 0.6.8.4 Python: 3.8.5 (default, Jul 20 2020, 18:32:44) Executable: /usr/local/google/home/nathaniel/temp-temp/my_venv/bin/python OS: Linux Arch: x86_64 user@host:~/temp-temp$ ./my_venv/bin/pyinstaller --version 4.0 user@host:~/temp-temp$ ./my_venv/bin/python -m PyInstaller --version 4.0 user@host:~/temp-temp$ ./my_venv/bin/pytest --version pytest 6.0.1 user@host:~/temp-temp$ ./my_venv/bin/python -m pytest --version pytest 6.0.1
one can see how one might sense a pattern, yes? ... and even if it isn't yet a convention, having played around with these utilities for a while now, it certainly is useful; it's something I'd definitely advocate promoting to be a convention.
-
This code is hosted on PyPI not at "ninja-but-only-the-command-line-executable" but rather at "ninja". If I were looking for a library that afforded Python-language programmatic access to ninja, this would definitely be the first place where I would think to look for it, and I would be surprised if I were told that such functionality would be considered out-of-scope (rather than merely "no one has yet needed it so no one has yet implemented it", which I'm guessing is more the actual case?).
@jcfr: thank you for #37! 🙂 It looks like it may unblock pytype issue 642.
-
it's something I'd definitely advocate promoting to be a convention.
👍 I will add support for
python -mto the cmake and castxml wheels as wellIf I were looking for a library that afforded Python-language programmatic access to ninja [...] this would definitely be the first place where I would think to look for it, and I would be surprised if I were told that such functionality would be considered out-of-scope
Makes complete sense.
It's weird that after installing
ninjain a virtual environment one can invoke it with./my_venv/bin/ninjabut not also with./my_venv/bin/python -m ninja.ENVIRONMENT:
Ubuntu 20.04 LTS
STEPS TO REPRODUCE:
python3.8 -m venv my_venv./my_venv/bin/python -m pip install --upgrade pip./my_venv/bin/python -m pip install --upgrade ninja./my_venv/bin/ninja --version./my_venv/bin/python -m ninja --versionEXPECTED RESULTS:
I would expect that the
./my_venv/bin/python -m ninja --versionexecution would produce the same output as that produced by the./my_venv/bin/ninja --versionexecution.OBSERVED RESULTS:
./my_venv/bin/python -m ninja --versionoutputs/home/nathaniel/temp-temp/my_venv/bin/python: No module named ninja.__main__; 'ninja' is a package and cannot be directly executed.