3

I would like to use meson build system on windows. I am python noob. It looks like I installed it, but I do not know how to run it.

I have installed python 3.6. I have installed meson from 'cmd':

C:\>python -m pip install meson
Collecting meson
  Downloading meson-0.39.0.tar.gz (558kB)
    100% |████████████████████████████████| 563kB 866kB/s
Installing collected packages: meson
  Running setup.py install for meson ... done
Successfully installed meson-0.39.0

I try to run meson:

C:\>python -m meson
C:\Users\user\AppData\Local\Programs\Python\Python36-32\python.exe: No module named meson


C:\>meson
'meson' is not recognized as an internal or external command,
operable program or batch file.

How can I use/run this thing?

urkon
  • 233
  • 1
  • 5
  • 15

4 Answers4

9

Ok the official advice is to associate .py files with the Windows Python Launcher (at c:\Windows\py.exe). However this is a shitty solution because a) That means you can't associate them with an editor or IDE, and b) command line argument passing e.g. meson.py --help does not work.

A better solution is to:

  1. Download and install Python 3 to the default installation location (in %APPDATA%). Have it add Python to your path.

  2. Run python -m pip install meson

  3. Create a meson.bat file somewhere in your PATH with the following contents:

    @echo off
    c:\Windows\py.exe %LOCALAPPDATA%\Programs\Python\Python36-32\Scripts\meson.py %*
    

Then you should be able to just run meson --help successfully.

I have no idea why this isn't done automatically.

Timmmm
  • 88,195
  • 71
  • 364
  • 509
  • Your point b) is not true (anymore?). meson --help, setup --help-commands, etc. work, at least in Windows 10 with Python 3.6.6. –  Jul 31 '18 at 22:53
  • Did you run `meson.py --help` or `meson --help`? [Here is the issue for this problem by the way](https://github.com/mesonbuild/meson/issues/1877). – Timmmm Aug 02 '18 at 10:21
  • Both `meson --help` and `meson.py --help` work. Also, setup.py from pycairo and pygobject builds work both ways. –  Aug 03 '18 at 19:53
1

This is what I did:

  1. Download the latest MSI for Windows form the Releases page.
  2. Use LessMSI to extract the MSI into my own folder.
  3. Create a bat file which opens a CMD with the path to Meson added to the System Variable %PATH%.

Then just use it as guided form the CMD.
No need to install Python or anything.

Royi
  • 4,640
  • 6
  • 46
  • 64
  • Indeed, I see the MSI file just includes a directly runnable meson.exe, no need for separate Python installation, as it comes with a standalone Python DLL. I just installed the MSI (double click) though to the path I wanted, rather than use 7-zip or LessMSI. – Dwayne Robinson Jan 14 '21 at 08:27
0

from the documentation

Running

Meson requires that you have a source directory and a build directory and that these two are different. In your source root must exist a file called 'meson.build'. To generate the build system run this command:

meson

Depending on how you obtained Meson the command might also be called meson.py

check for a meson.py in the directory that you installed meson.

https://github.com/mesonbuild/meson

parsethis
  • 7,998
  • 3
  • 29
  • 31
  • Yes. `meson.py` solves it. Thats what is missing on the meson home page. – urkon Mar 10 '17 at 07:54
  • awesome, since this answered your question please mark this as the answer so we can help other find it. – parsethis Mar 10 '17 at 07:55
  • Just running `meson.py` does not work unless you a) have it in your path, and b) have set all `.py` files to open with `python.exe` (no thanks). And even then it doesn't seem to pass arguments. – Timmmm May 29 '17 at 11:45
0

Windows 10 / Python 3.9

pip3 install meson

meson.exe will be installed in Scripts folder

c:\users\<usernmae>\appdata\roaming\python\pythonxx\Scripts\meson.exe
Mohammad Kanan
  • 4,452
  • 10
  • 23
  • 47