Skip to content

Commit beed1ce

Browse files
author
Stephen L Arnold
committed
chg: pkg: add env support for toolchain file, update windows ci env
Signed-off-by: Stephen L Arnold <nerdboy@gentoo.org>
1 parent cb0d423 commit beed1ce

5 files changed

Lines changed: 35 additions & 31 deletions

File tree

.github/workflows/build.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,3 @@ jobs:
6161
run: |
6262
pip install --user cython
6363
python setup.py sdist
64-
65-
check_artifacts:
66-
name: Check artifacts are correct
67-
needs: [build_wheels]
68-
runs-on: ubuntu-20.04
69-
steps:
70-
- uses: actions/checkout@v2
71-
- uses: actions/download-artifact@v2
72-
with:
73-
name: wheels
74-
75-
- name: Check number of downloaded artifacts
76-
run: .github/workflows/wheel-check.sh 9

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ jobs:
6464
python -m pip install --upgrade pip wheel
6565
pip install tox
6666
67+
- name: Set Windows environment variables
68+
if: runner.os == 'Windows'
69+
run: |
70+
.github/workflows/vs_env.bat x64
71+
source env.sh
72+
echo "CMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake" >> $GITHUB_ENV
73+
6774
- name: Test in place
6875
run: |
6976
tox -e py

.github/workflows/vs_env.bat

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@echo off
2+
3+
SET VSWHERE="C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere"
4+
5+
:: See https://github.com/microsoft/vswhere/wiki/Find-VC
6+
for /f "usebackq delims=*" %%i in (`%VSWHERE% -latest -property installationPath`) do (
7+
call "%%i\VC\Auxiliary\Build\vcvarsall.bat" %*
8+
)
9+
10+
bash -c "export -p > env.sh"

.github/workflows/wheel-check.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

setup.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from distutils.dir_util import mkpath
1616
from distutils.errors import DistutilsExecError, DistutilsFileError
1717
from operator import methodcaller
18+
from distutils.file_util import copy_file
1819
from os import environ, unlink
1920
from os.path import dirname, join
2021
from platform import system
@@ -36,6 +37,19 @@
3637
TRACE = 0
3738

3839

40+
def cmd() -> None:
41+
"""
42+
Construct the cmake command plus args.
43+
:return: cmd_list
44+
"""
45+
cmd_list = ['cmake', '--log-level=WARNING']
46+
toolchain_file = environ.get('CMAKE_TOOLCHAIN_FILE', '')
47+
if toolchain_file:
48+
cmd_list += ['-DCMAKE_TOOLCHAIN_FILE={}'.format(toolchain_file)]
49+
cmd_list += ['.']
50+
return cmd_list
51+
52+
3953
def src(file: str) -> str:
4054
"""Return path to the given file in src."""
4155
return join(dirname(__file__), 'src', file)
@@ -45,10 +59,13 @@ class CMakeBuild(build_ext):
4559
"""CMake extension builder and process runner."""
4660
def finalize_options(self) -> None:
4761
super().finalize_options()
62+
cmake_cmd = cmd()
4863
mkpath(self.build_temp)
64+
copy_file(join(dirname(__file__), 'CMakeLists.txt'), self.build_temp)
4965
try:
5066
cmake = run(
51-
['cmake', '../..'], check=True, stdout=DEVNULL, stderr=PIPE,
67+
cmake_cmd, check=True,
68+
stdout=DEVNULL, stderr=PIPE,
5269
cwd=self.build_temp, universal_newlines=True)
5370
except CalledProcessError as e:
5471
log.error(e.stderr.strip())

0 commit comments

Comments
 (0)