CI: Add bagPy Python build: debug #52
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Matrix - Windows | |
on: | |
push: | |
paths-ignore: | |
- 'docs/**' | |
- appveyor.yml | |
- readme.* | |
- README.* | |
- '*.md' | |
- '*.svg' | |
- '*.png' | |
- .github/workflows/testmatrix.yml | |
- .github/workflows/testreporting.yml | |
branches: [ "master" ] | |
pull_request: | |
paths-ignore: | |
- 'docs/**' | |
- appveyor.yml | |
- readme.* | |
- README.* | |
- '*.md' | |
- '*.svg' | |
- '*.png' | |
- .github/workflows/testmatrix.yml | |
- .github/workflows/testreporting.yml | |
branches: [ "master", "v2" ] | |
env: | |
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | |
BUILD_TYPE: Release | |
jobs: | |
windows_build: | |
runs-on: ${{matrix.os}} | |
defaults: | |
run: | |
shell: bash | |
strategy: | |
fail-fast: true | |
matrix: | |
include: | |
- python-version: ["3.11"] | |
os: [windows-latest] | |
c_compiler: [cl] | |
platform: | |
VS_VERSION: Visual Studio 17 | |
VS_VER: 2022 | |
SDK: release-1911 | |
MSVC_VER: 1920 | |
ZLIB_URL: "https://github.com/madler/zlib/releases/download/v1.3/zlib13.zip" | |
LIBXML2_URL: "https://gitlab.gnome.org/GNOME/libxml2/-/archive/v2.12.0/libxml2-v2.12.0.zip" | |
HDF5_URL: "https://github.com/HDFGroup/hdf5/releases/download/hdf5-1_12_3/hdf5-1_12_3.zip" | |
CATCH2_URL: "https://github.com/catchorg/Catch2/archive/refs/tags/v3.4.0.zip" | |
env: | |
ARCHITECTURE: "amd64" | |
VS_VERSION: ${{ matrix.VS_VERSION }} | |
VS_VER: ${{ matrix.VS_VER }} | |
SDK: ${{ matrix.SDK }} | |
MSVC_VER: ${{ matrix.MSVC_VER }} | |
platform: ${{ matrix.platform }} | |
ZLIB_URL: ${{ matrix.ZLIB_URL }} | |
LIBXML2_URL: ${{ matrix.LIBXML2_URL }} | |
HDF5_URL: ${{ matrix.HDF5_URL }} | |
CATCH2_URL: ${{ matrix.CATCH2_URL }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set compiler environment | |
shell: cmd | |
run: | | |
if "%VS_VER%" == "2022" CALL "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=%ARCHITECTURE% | |
echo PATH=%PATH%>> %GITHUB_ENV% | |
echo INCLUDE=%INCLUDE%>> %GITHUB_ENV% | |
echo LIB=%LIB%>> %GITHUB_ENV% | |
echo LIBPATH=%LIBPATH%>> %GITHUB_ENV% | |
- name: Build | |
shell: pwsh | |
run: | | |
$ErrorActionPreference = 'continue' | |
function exec | |
{ | |
param ( [ScriptBlock] $ScriptBlock ) | |
& $ScriptBlock 2>&1 | ForEach-Object -Process { "$_" } | |
if ($LastExitCode -ne 0) { exit $LastExitCode } | |
} | |
Install-Module Pscx -AllowClobber | |
Install-Module VSSetup -Scope CurrentUser | |
# Setup | |
$env:BAG_INSTALL_PATH="$env:GITHUB_WORKSPACE\install" | |
# Debug: env | |
if(-Not (Test-Path -Path $env:BAG_INSTALL_PATH)) { mkdir $env:BAG_INSTALL_PATH } | |
# Create Python venv in the same place as BAG_INSTALL_PATH | |
python -m venv $env:BAG_INSTALL_PATH | |
# Debug: dir $env:GITHUB_WORKSPACE | |
# Download dependencies | |
if(-Not (Test-Path -Path downloads)) { mkdir downloads } | |
cd downloads | |
$env:ZLIB_ZIP="zlib.zip" | |
if(-Not (Test-Path -Path $env:ZLIB_ZIP -PathType Leaf)) { Invoke-WebRequest "$env:ZLIB_URL" -OutFile "$env:ZLIB_ZIP" } | |
$env:LIBXML2_ZIP="libxml2.zip" | |
if(-Not (Test-Path -Path $env:LIBXML2_ZIP -PathType Leaf)) { Invoke-WebRequest "$env:LIBXML2_URL" -OutFile "$env:LIBXML2_ZIP" } | |
$env:HDF5_ZIP="hdf5.zip" | |
if(-Not (Test-Path -Path $env:HDF5_ZIP -PathType Leaf)) { Invoke-WebRequest "$env:HDF5_URL" -OutFile "$env:HDF5_ZIP" } | |
$env:CATCH2_ZIP="catch2.zip" | |
if(-Not (Test-Path -Path $env:CATCH2_ZIP -PathType Leaf)) { Invoke-WebRequest "$env:CATCH2_URL" -OutFile "$env:CATCH2_ZIP" } | |
# Unzip and build dependencies | |
cd .. | |
mkdir src | |
cd src | |
# zlib | |
exec { 7z x ..\downloads\$env:ZLIB_ZIP } | |
cd zlib-1.3 | |
if(-Not (Test-Path -Path build)) { mkdir build } | |
$env:CMAKE_INSTALL_PREFIX="-DCMAKE_INSTALL_PREFIX=" + $env:BAG_INSTALL_PATH | |
cmake -B build -G $env:VS_VERSION -S . $env:CMAKE_INSTALL_PREFIX -DCMAKE_BUILD_TYPE=Release | |
cmake --build build --config Release --target install -- /nologo /verbosity:minimal | |
cd .. | |
# libxml2 | |
exec { 7z x ..\downloads\$env:LIBXML2_ZIP } | |
cd libxml2-v2.12.0 | |
if(-Not (Test-Path -Path build)) { mkdir build } | |
cmake -B build -G $env:VS_VERSION -S . $env:CMAKE_INSTALL_PREFIX -DCMAKE_BUILD_TYPE=Release ` | |
-DLIBXML2_WITH_ZLIB=ON -DLIBXML2_WITH_ICONV=OFF -DLIBXML2_WITH_LZMA=OFF -DLIBXML2_WITH_PYTHON=OFF | |
cmake --build build --config Release --target install -- /nologo /verbosity:minimal | |
cd .. | |
# HDF5 | |
exec { 7z x ..\downloads\$env:HDF5_ZIP } | |
cd hdfsrc | |
if(-Not (Test-Path -Path build)) { mkdir build } | |
cmake -B build -G $env:VS_VERSION -S . $env:CMAKE_INSTALL_PREFIX -DCMAKE_BUILD_TYPE=Release ` | |
-DHDF5_BUILD_CPP_LIB=ON -DHDF5_BUILD_TOOLS:BOOL=OFF ` | |
-DBUILD_TESTING:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=ON ` | |
-DHDF5_BUILD_HL_LIB:BOOL=ON -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=ON | |
cmake --build build --config Release --target install -- /nologo /verbosity:minimal | |
cd .. | |
# Catch2 | |
exec { 7z x ..\downloads\$env:CATCH2_ZIP } | |
cd Catch2-3.4.0 | |
if(-Not (Test-Path -Path build)) { mkdir build } | |
# Debug: dir | |
# Debug: pwd | |
cmake -B build -G $env:VS_VERSION -S . $env:CMAKE_INSTALL_PREFIX -DCMAKE_BUILD_TYPE=Release ` | |
-DBUILD_TESTING:BOOL=OFF | |
cmake --build build --config Release --target install -- /nologo /verbosity:minimal | |
cd ..\.. | |
dir -r $env:BAG_INSTALL_PATH | |
# Build and install BAG C++ API | |
cmake -B build -G $env:VS_VERSION -S . $env:CMAKE_INSTALL_PREFIX -DCMAKE_BUILD_TYPE=Release ` | |
-DBAG_BUILD_TESTS:BOOL=ON -DBAG_CI=ON | |
cmake --build build --config Release --target install | |
# Build and install bagPy Python wheel | |
$activate_cmd="$env:BAG_INSTALL_PATH\Scripts\Activate.ps1" | |
dir $activate_cmd | |
echo "Attempting to activate Python environment using script: $activate_cmd ..." | |
& $activate_cmd | |
python -m pip install --upgrade pip | |
python -m pip install -r requirements.txt | |
$env:CMAKE_PREFIX_PATH=$env:BAG_INSTALL_PATH | |
$env:LIBXML2_LIBRARY="$env:BAG_INSTALL_PATH\Lib" | |
$env:LIBXML2_INCLUDE_DIR="$env:BAG_INSTALL_PATH\Include" | |
python -m pip wheel -w .\wheel\ .\build\api\swig\python | |
python -m pip install .\wheel\bagPy-*.whl |