Skip to content

Commit 7afdd40

Browse files
authored
Merge pull request #354 from henryiii/patch-2
Better help for GitHub Actions + Py27 workaround
2 parents e12ca14 + fb0e192 commit 7afdd40

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

docs/cpp_standards.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,31 @@ Forcing `distutils` or `setuptools` to use a more recent version of MSVC that su
3939
1. Set the environment variables `DISTUTILS_USE_SDK=1` and `MSSdk=1`. These two environment variables will tell `distutils`/`setuptools` to not search and set up a build environment that uses Visual C++ for Python 2.7 (aka. MSVC 9).
4040
2. Set up the build Visual Studio build environment you want to use, making sure that e.g. `PATH` contains `cl`, `link`, etc.
4141
- Usually, this can be done through `vcvarsall.bat x86` or `vcvarsall.bat x64`. The exact location of this file depends on the installation, but the default path for VS 2019 Community (e.g. used in AppVeyor's `Visual Studio 2019` image) is `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat`. **Note**: `vcvarsall.bat` changes the environment variables, so this cannot be run in a subprocess/subshell and consequently running `vsvarsall.bat` in `CIBW_BEFORE_BUILD` does not have any effect.
42-
- In Azure Pipelines, [a `VSBuild` task is available](https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/visual-studio-build) and GitHub Actions has [an action `microsoft/setup-msbuild`](https://github.com/microsoft/setup-msbuild) that help setting up the Visual Studio environment.
43-
3. Next, call `cibuildwheel`. Unfortunately, MSVC has separate toolchains for compiling 32-bit and 64-bit, so you will need to run `cibuildwheel` twice: once with `CIBW_BUILD=*-win32` after setting up the `x86` build environment, and once with `CIBW_BUILD=*-win_amd64` in a `x64` enviroment (see previous step).
42+
- In Azure Pipelines, [a `VSBuild` task is available](https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/visual-studio-build)
43+
- In GitHub Actions, the default shell is powershell, so you'll need to use `shell: cmd` to source a `.bat` file, and the directory is `"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"`. Or you can use an action, such as the [`ilammy/msvc-dev-cmd@v1`](https://github.com/ilammy/msvc-dev-cmd) action to setup the environment (see example below).
44+
3. Next, call `cibuildwheel`. Unfortunately, MSVC has separate toolchains for compiling 32-bit and 64-bit, so you will need to run `cibuildwheel` twice: once with `CIBW_BUILD=*-win32` after setting up the `x86` build environment, and once with `CIBW_BUILD=*-win_amd64` in a `x64` environment (see previous step).
45+
46+
47+
**GitHub Action example with ilammy/msvc-dev-cmd**:
48+
49+
```yaml
50+
- uses: ilammy/msvc-dev-cmd@v1
51+
52+
- name: Build 64-bit wheel
53+
run: python -m cibuildwheel --output-dir wheelhouse
54+
env:
55+
CIBW_BUILD: cp27-win_amd64
56+
DISTUTILS_USE_SDK: 1
57+
MSSdk: 1
58+
59+
- uses: ilammy/msvc-dev-cmd@v1
60+
with:
61+
arch: x86
62+
63+
- name: Build 32-bit wheel
64+
run: python -m cibuildwheel --output-dir wheelhouse
65+
env:
66+
CIBW_BUILD: cp27-win32
67+
DISTUTILS_USE_SDK: 1
68+
MSSdk: 1
69+
```

0 commit comments

Comments
 (0)