Skip to content

Commit

Permalink
chg: pkg: add env support for toolchain file, update windows ci env
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen L Arnold <[email protected]>
  • Loading branch information
sarnold committed Jan 2, 2021
1 parent cb0d423 commit beed1ce
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 31 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,3 @@ jobs:
run: |
pip install --user cython
python setup.py sdist
check_artifacts:
name: Check artifacts are correct
needs: [build_wheels]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: wheels

- name: Check number of downloaded artifacts
run: .github/workflows/wheel-check.sh 9
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ jobs:
python -m pip install --upgrade pip wheel
pip install tox
- name: Set Windows environment variables
if: runner.os == 'Windows'
run: |
.github/workflows/vs_env.bat x64
source env.sh
echo "CMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake" >> $GITHUB_ENV
- name: Test in place
run: |
tox -e py
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/vs_env.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@echo off

SET VSWHERE="C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere"

:: See https://github.com/microsoft/vswhere/wiki/Find-VC
for /f "usebackq delims=*" %%i in (`%VSWHERE% -latest -property installationPath`) do (
call "%%i\VC\Auxiliary\Build\vcvarsall.bat" %*
)

bash -c "export -p > env.sh"
17 changes: 0 additions & 17 deletions .github/workflows/wheel-check.sh

This file was deleted.

19 changes: 18 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from distutils.dir_util import mkpath
from distutils.errors import DistutilsExecError, DistutilsFileError
from operator import methodcaller
from distutils.file_util import copy_file
from os import environ, unlink
from os.path import dirname, join
from platform import system
Expand All @@ -36,6 +37,19 @@
TRACE = 0


def cmd() -> None:
"""
Construct the cmake command plus args.
:return: cmd_list
"""
cmd_list = ['cmake', '--log-level=WARNING']
toolchain_file = environ.get('CMAKE_TOOLCHAIN_FILE', '')
if toolchain_file:
cmd_list += ['-DCMAKE_TOOLCHAIN_FILE={}'.format(toolchain_file)]
cmd_list += ['.']
return cmd_list


def src(file: str) -> str:
"""Return path to the given file in src."""
return join(dirname(__file__), 'src', file)
Expand All @@ -45,10 +59,13 @@ class CMakeBuild(build_ext):
"""CMake extension builder and process runner."""
def finalize_options(self) -> None:
super().finalize_options()
cmake_cmd = cmd()
mkpath(self.build_temp)
copy_file(join(dirname(__file__), 'CMakeLists.txt'), self.build_temp)
try:
cmake = run(
['cmake', '../..'], check=True, stdout=DEVNULL, stderr=PIPE,
cmake_cmd, check=True,
stdout=DEVNULL, stderr=PIPE,
cwd=self.build_temp, universal_newlines=True)
except CalledProcessError as e:
log.error(e.stderr.strip())
Expand Down

0 comments on commit beed1ce

Please sign in to comment.