Skip to content
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 Meson and thus meson-python require MSVC compilers to be found in $PATH #224

Closed
dnicolodi opened this issue Nov 22, 2022 · 6 comments
Labels
documentation Improvements or additions to documentation
Milestone

Comments

@dnicolodi
Copy link
Member

setuptools has its magic to find the compilers but Meson does not thus this may come as a surprise especially to people like me that compiles on Windows only on CI jobs. Because many CI environments have images where the GCC compilers are available via MSYS2 or similar, Meson picks up those by default and things break in unexpected ways because the right command line arguments should be passed to these compilers to correctly build Python extensions.

One more related issue is that cibuildweels (I don't know how popular but definitely convenient way to build distributable wheels) most prominently way to build wheels in GitHub Actions is using a reusable action that does not play nicely with adding the MSVC compilers in $PATH. The solution is to use pipx run cibuildwheel directly. @henryiii can probably fill in the details.

All this should be documented somewhere.

@rgommers rgommers added the documentation Improvements or additions to documentation label Nov 22, 2022
@eli-schwartz
Copy link
Member

meson setup --vsenv will force Meson to run the vcvars*.bat script and acquire its information on finding MSVC before any other compiler. Without that option, Meson does indeed pick an msys2 compiler from $PATH.

@henryiii
Copy link
Contributor

I've looked into updating the action to run the native pwsh backend on Windows. Unfortunately, it seems powershell doesn't like empty args, that is, --flag "" complains about flag not getting an argument. We use this for a couple of arguments, so that's where I'm stuck at the moment.

@henryiii
Copy link
Contributor

henryiii commented Nov 22, 2022

Here's the run if you are curious: https://github.com/pybind/scikit_build_example/actions/runs/3519251284/jobs/5899006227

Run henryiii/cibuildwheel@henryiii/fix/action
with:
  package-dir: .
  output-dir: wheelhouse
env:
  CIBW_ARCHS_MACOS: auto universal2
Run actions/setup-python@v4
with:
  python-version: 3.7 - 3.11
  update-environment: false
  check-latest: false
  token: ***
env:
  CIBW_ARCHS_MACOS: auto universal2
Successfully set up CPython (3.11.0)
Run pipx run --python "C:\hostedtoolcache\windows\Python\3.11.0\x64\python.exe" --spec "D:\a\_actions\henryiii\cibuildwheel\henryiii/fix/action" cibuildwheel "." --output-dir "wheelhouse" --config-file "" --only ""
pipx run --python "C:\hostedtoolcache\windows\Python\3.11.0\x64\python.exe" --spec "D:\a\_actions\henryiii\cibuildwheel\henryiii/fix/action" cibuildwheel "." --output-dir "wheelhouse" --config-file "" --only ""
shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
env:
  CIBW_ARCHS_MACOS: auto universal2
creating virtual environment...
creating virtual environment...
determining package name from 'D:\\a\\_actions\\henryiii\\cibuildwheel\\henryiii\\fix\\action'...
installing cibuildwheel from spec 'D:\\a\\_actions\\henryiii\\cibuildwheel\\henryiii\\fix\\action'...
usage: cibuildwheel [-h] [--platform {auto,linux,macos,windows}]
                    [--archs ARCHS] [--only ONLY] [--output-dir OUTPUT_DIR]
                    [--config-file CONFIG_FILE] [--print-build-identifiers]
                    [--allow-empty] [--prerelease-pythons]
                    [PACKAGE]
cibuildwheel: error: argument --config-file: expected one argument

The run line looks correct:

pipx run --python "C:\hostedtoolcache\windows\Python\3.11.0\x64\python.exe" --spec "D:\a\_actions\henryiii\cibuildwheel\henryiii/fix/action" cibuildwheel "." --output-dir "wheelhouse" --config-file "" --only ""

But powershell seems to be muddling it somehow since argparse reports is has no argument for --config-file. We could technically fix that one (the default can be written in text, so could be put into the action), but --only really does need to be empty.

If there's some powershell trickery to avoid printing the option if the variable is empty, I'd be happy to hear it. :) Edit: Doubling quotes. Hmm, okay.

@henryiii
Copy link
Contributor

Got it working, made pypa/cibuildwheel#1346.

@lithomas1
Copy link
Member

meson setup --vsenv will force Meson to run the vcvars*.bat script and acquire its information on finding MSVC before any other compiler. Without that option, Meson does indeed pick an msys2 compiler from $PATH.

Isn't that bugging behavior, though? Here, https://github.com/mesonbuild/meson/blob/master/mesonbuild/compilers/detect.py#L56, it says that meson should prefer cl.exe before other compilers. It would be inconsistent for meson, to only prefer cl.exe if it was in the path?

Interestingly enough, if nothing is in the PATH, meson is somehow able to find MSVC.

@dnicolodi dnicolodi changed the title Document that Meson ans thus meson-python require MSVC compilers to be found in $PATH Document that Meson and thus meson-python require MSVC compilers to be found in $PATH Nov 24, 2022
FFY00 added a commit to FFY00/meson-python that referenced this issue Jan 27, 2023
Closes mesonbuild#197, mesonbuild#230, mesonbuild#253, and mesonbuild#264
Sets us up to fix mesonbuild#138, mesonbuild#233, and mesonbuild#224

Signed-off-by: Filipe Laíns <lains@riseup.net>
FFY00 added a commit to FFY00/meson-python that referenced this issue Jan 27, 2023
Closes mesonbuild#197, mesonbuild#230, mesonbuild#253, and mesonbuild#264
Sets us up to fix mesonbuild#138, mesonbuild#233, and mesonbuild#224

Signed-off-by: Filipe Laíns <lains@riseup.net>
FFY00 added a commit to FFY00/meson-python that referenced this issue Jan 27, 2023
Closes mesonbuild#197, mesonbuild#230, mesonbuild#253, and mesonbuild#264
Sets us up to fix mesonbuild#138, mesonbuild#233, and mesonbuild#224

Signed-off-by: Filipe Laíns <lains@riseup.net>
FFY00 added a commit to FFY00/meson-python that referenced this issue Jan 27, 2023
Closes mesonbuild#197, mesonbuild#230, mesonbuild#253, and mesonbuild#264
Sets us up to fix mesonbuild#138, mesonbuild#233, and mesonbuild#224

Signed-off-by: Filipe Laíns <lains@riseup.net>
FFY00 added a commit to FFY00/meson-python that referenced this issue Jan 27, 2023
Closes mesonbuild#197, mesonbuild#230, mesonbuild#253, and mesonbuild#264
Sets us up to fix mesonbuild#138, mesonbuild#233, and mesonbuild#224

Signed-off-by: Filipe Laíns <lains@riseup.net>
FFY00 added a commit to FFY00/meson-python that referenced this issue Jan 27, 2023
Closes mesonbuild#197, mesonbuild#230, mesonbuild#253, and mesonbuild#264
Sets us up to fix mesonbuild#138, mesonbuild#233, and mesonbuild#224

Signed-off-by: Filipe Laíns <lains@riseup.net>
FFY00 added a commit to FFY00/meson-python that referenced this issue Jan 31, 2023
Closes mesonbuild#197, mesonbuild#230, mesonbuild#253, and mesonbuild#264
Sets us up to fix mesonbuild#138, mesonbuild#233, and mesonbuild#224

Signed-off-by: Filipe Laíns <lains@riseup.net>
FFY00 added a commit to FFY00/meson-python that referenced this issue Feb 1, 2023
Closes mesonbuild#197, mesonbuild#230, mesonbuild#253, and mesonbuild#264
Sets us up to fix mesonbuild#138, mesonbuild#233, and mesonbuild#224

Signed-off-by: Filipe Laíns <lains@riseup.net>
FFY00 added a commit that referenced this issue Feb 1, 2023
Closes #197, #230, #253, and #264
Sets us up to fix #138, #233, and #224

Signed-off-by: Filipe Laíns <lains@riseup.net>
@rgommers
Copy link
Contributor

This was documented in gh-371, so we should be good here.

@rgommers rgommers added this to the v0.13.0 milestone Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

5 participants