From 901f708d4c38a308a36a6fb2a1f0625dd8ed03b0 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 27 May 2020 15:56:12 -0400 Subject: [PATCH 1/3] Better help for GitHub Actions + Py27 workaround --- docs/cpp_standards.md | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/cpp_standards.md b/docs/cpp_standards.md index 5dd83614..907643fd 100644 --- a/docs/cpp_standards.md +++ b/docs/cpp_standards.md @@ -39,5 +39,30 @@ Forcing `distutils` or `setuptools` to use a more recent version of MSVC that su 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). 2. Set up the build Visual Studio build environment you want to use, making sure that e.g. `PATH` contains `cl`, `link`, etc. - 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. - - 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. + - In Azure Pipelines, [a `VSBuild` task is available](https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/visual-studio-build) + - In GitHub Actions, the default shell is powershell, so you'll need to use `shell: cmd` to source a `.bat` file. 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). + +In GitHub Actions, you will probably need something like this: + +```yaml + - name: Build 64-bit wheel + run: | + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + python -m cibuildwheel --output-dir wheelhouse + shell: cmd + env: + CIBW_BUILD: cp27-win_amd64 + DISTUTILS_USE_SDK: 1 + MSSdk: 1 + + - name: Build 32-bit wheel + run: | + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86 + python -m cibuildwheel --output-dir wheelhouse + shell: cmd + env: + CIBW_BUILD: cp27-win32 + DISTUTILS_USE_SDK: 1 + MSSdk: 1 +``` From 2c564dfb9c2d7570cbf8a5105180f9d41f333211 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 27 May 2020 19:45:34 -0400 Subject: [PATCH 2/3] Mention action, drop example code. --- docs/cpp_standards.md | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/docs/cpp_standards.md b/docs/cpp_standards.md index 907643fd..954ea7db 100644 --- a/docs/cpp_standards.md +++ b/docs/cpp_standards.md @@ -40,29 +40,5 @@ Forcing `distutils` or `setuptools` to use a more recent version of MSVC that su 2. Set up the build Visual Studio build environment you want to use, making sure that e.g. `PATH` contains `cl`, `link`, etc. - 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. - In Azure Pipelines, [a `VSBuild` task is available](https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/visual-studio-build) - - In GitHub Actions, the default shell is powershell, so you'll need to use `shell: cmd` to source a `.bat` file. + - 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. 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). - -In GitHub Actions, you will probably need something like this: - -```yaml - - name: Build 64-bit wheel - run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - python -m cibuildwheel --output-dir wheelhouse - shell: cmd - env: - CIBW_BUILD: cp27-win_amd64 - DISTUTILS_USE_SDK: 1 - MSSdk: 1 - - - name: Build 32-bit wheel - run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86 - python -m cibuildwheel --output-dir wheelhouse - shell: cmd - env: - CIBW_BUILD: cp27-win32 - DISTUTILS_USE_SDK: 1 - MSSdk: 1 -``` From fb0e192681d4ab42faa6229e5823d36af69eb5f4 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 5 Jun 2020 16:58:57 -0400 Subject: [PATCH 3/3] Add example snippit --- docs/cpp_standards.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/cpp_standards.md b/docs/cpp_standards.md index 954ea7db..fa26dfc7 100644 --- a/docs/cpp_standards.md +++ b/docs/cpp_standards.md @@ -40,5 +40,30 @@ Forcing `distutils` or `setuptools` to use a more recent version of MSVC that su 2. Set up the build Visual Studio build environment you want to use, making sure that e.g. `PATH` contains `cl`, `link`, etc. - 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. - In Azure Pipelines, [a `VSBuild` task is available](https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/visual-studio-build) - - 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. -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). + - 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). +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). + + +**GitHub Action example with ilammy/msvc-dev-cmd**: + +```yaml + - uses: ilammy/msvc-dev-cmd@v1 + + - name: Build 64-bit wheel + run: python -m cibuildwheel --output-dir wheelhouse + env: + CIBW_BUILD: cp27-win_amd64 + DISTUTILS_USE_SDK: 1 + MSSdk: 1 + + - uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x86 + + - name: Build 32-bit wheel + run: python -m cibuildwheel --output-dir wheelhouse + env: + CIBW_BUILD: cp27-win32 + DISTUTILS_USE_SDK: 1 + MSSdk: 1 +```