Call meson using python -m meson
See original GitHub issueFeature Request I would like to call meson using
python -m meson <args>
docs: __main__.py
Adding a simple __main__.py would solve this issue. But I noticed that the module name mesonbuild rather meson is there a particular reason why it is named so?
Use Case
I am on Appveyor and I would like to meson there using their python because I am building something which requires the python header, so I could easily shift between x86 and x64 python version using direct path instead of path manipulation. I would simply call it using direct path rather than path manipulation.
Also, this would be so helpful, if I run it inside a python scipt and I could get the python executable using
import sys
print(sys.executable)
So, I could simply call it using the path recieved. Now, I find a __main__.py in repo, but why is it in root directory rather than inside mesonbuild directory?
The solution
Copy the meson.py (with slight edit) inside the mesonbuild(should be meson?) as __main__.py and it is fixed.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:14 (13 by maintainers)

Top Related StackOverflow Question
@naveen521kk,
You can currently do this via
python -m mesonbuild.mesonmain.The
__main__.pyfile is intended merely to make this usable viapython -m zipapp /path/to/meson-checkoutto create a single-file executable out of the box. Although I don’t know that it’s doing a great job of it. 😮The python script merely imports mesonbuild and calls the entrypoint main function. So I don’t see how this could possibly work… unless multiple python versions each have mesonbuild installed to site-packages…