Improve python bindings for Windows #10
Workflow file for this run
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: Build and Test Matrix | |
on: [pull_request] | |
#on: [push] | |
jobs: | |
pipeline: | |
# if: github.repository == 'virtualpregnancy/reprosim' | |
name: ${{ matrix.config.name }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
# - { | |
# name: "Windows 2022 MSVC", | |
# build_type: "Release", | |
# os: windows-2022, | |
# } | |
- { | |
name: "Ubuntu 20.04", | |
build_type: "Release", | |
os: ubuntu-20.04, | |
} | |
- { | |
name: "macOS Big Sur 11", | |
build_type: "Release", | |
os: macos-11, | |
} | |
steps: | |
# Useful for debugging dll load issues. | |
# - name: Download Dependencies | |
# if: runner.os == 'Windows' | |
# shell: bash | |
# run: | | |
# curl -L https://github.com/lucasg/Dependencies/releases/download/v1.11.1/Dependencies_x64_Release.zip -O | |
# ls | |
# unzip Dependencies_x64_Release.zip | |
# - name: Run Dependencies | |
# if: runner.os == 'Windows' | |
# shell: cmd | |
# run: | | |
# python -VV | |
# Dependencies.exe -depth 2 -chain "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Redist/MSVC/14.29.30133/x64/Microsoft.VC142.CRT/vcruntime140.dll" | |
# This is not needed, we can just install the Fortran compiler for the HPC kit. | |
# - name: Install oneAPI base kit | |
# if: runner.os == 'Windows' | |
# shell: bash | |
# run: oneapi/scripts/install_windows.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_COMPONENTS | |
# - name: Build oneAPI base kit | |
# if: runner.os == 'Windows' | |
# shell: bash | |
# run: oneapi/scripts/build_windows.bat dpc++ "" $SAMPLES_TAG | |
# - name: Checkout oneAPI scripts | |
# if: runner.os == 'Windows' | |
# uses: actions/checkout@v3 | |
# with: | |
# repository: 'hsorby/oneapi-ci' | |
# path: 'oneapi' | |
# Caching doesn't work with Visual Studio integration on. | |
# - name: Cache install oneAPI | |
# if: runner.os == 'Windows' | |
# id: cache-install | |
# uses: actions/cache@v2 | |
# with: | |
# path: C:\Program Files (x86)\Intel\oneAPI\compiler | |
# key: install-${{ env.WINDOWS_HPCKIT_URL }}-${{ env.WINDOWS_FORTRAN_COMPONENTS }}-compiler-${{ hashFiles('**/oneapi/scripts/cache_exclude_windows.sh') }} | |
- name: Install oneAPI HPC kit for Fortran | |
uses: fortran-lang/setup-fortran@v1 | |
if: runner.os == 'Windows' | |
id: setup-fortran | |
with: | |
compiler: 'intel' | |
version: '2023.2' | |
# - name: Install oneAPI HPC kit | |
# if: runner.os == 'Windows' | |
# uses: hsorby/install-intelfortran-action@main | |
# with: | |
# cache: false | |
# working-directory: oneapi | |
# shell: bash | |
# run: | | |
# scripts/install_windows.bat $WINDOWS_HPCKIT_URL $WINDOWS_FORTRAN_COMPONENTS | |
# Delete the following if you don't want to save install logs | |
# - name: Saving install logs | |
# if: runner.os == 'Windows' && steps.cache-install.outputs.cache-hit != 'true' | |
# uses: actions/upload-artifact@v2 | |
# with: | |
# name: InstallLogs_${{ github.job }} | |
# path: | | |
# oneapi/bootstrapper* | |
# oneapi/installer* | |
# retention-days: 7 | |
# Add in for building a simple Fortran application to test the Fortran compiler is working. | |
# - name: Build oneAPI HPC kit | |
# if: runner.os == 'Windows' | |
# shell: bash | |
# run: oneapi/scripts/build_windows.bat fortran "" $SAMPLES_TAG | |
# - name: Exclude unused files from cache | |
# if: runner.os == 'Windows' && steps.cache-install.outputs.cache-hit != 'true' | |
# working-directory: oneapi | |
# run: scripts/cache_exclude_windows.ps1 | |
- name: Checkout reprosim | |
uses: actions/checkout@v3 | |
with: | |
path: reprosim | |
# - name: Run get Fortran environment script | |
# id: setup-fortran-win | |
# if: runner.os == 'Windows' | |
# shell: bash | |
# working-directory: reprosim | |
# run: | | |
# latest_version=`.github/scripts/oneapi-env-vars-location.bat` | |
# echo "ifort compiler: $latest_version" | |
# # latest_version=`echo $latest_version | tr '\' '/'` | |
# # echo $latest_version | |
# # echo "::set-output name=env_bat::${latest_version}" | |
# echo "fc=${latest_version}" >> $GITHUB_OUTPUT | |
# redist_location=`.github/scripts/oneapi-redist-location.bat` | |
# echo "redist location: ${redist_location}" | |
# echo "redist_loc=${redist_location}" >> $GITHUB_OUTPUT | |
- name: Report CMake version | |
run: | | |
cmake --version | |
ninja --version | |
- name: Create virtual environment | |
shell: cmake -P {0} | |
id: create-venv | |
run: | | |
if ("${{ runner.os }}" STREQUAL "Windows") | |
set(SYS_PYTHON_EXE python) | |
else() | |
set(SYS_PYTHON_EXE python3) | |
endif() | |
execute_process( | |
COMMAND ${SYS_PYTHON_EXE} -m venv venv | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Failed to create virtual environment.") | |
endif() | |
if ("${{ runner.os }}" STREQUAL "Windows") | |
file(GLOB PYTHON_EXE venv/Scripts/python.exe) | |
file(GLOB PIP_EXE venv/Scripts/pip.exe) | |
else() | |
file(GLOB PYTHON_EXE venv/bin/python) | |
file(GLOB PIP_EXE venv/bin/pip) | |
endif() | |
execute_process( | |
COMMAND ${PYTHON_EXE} -m pip install numpy | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Failed to install numpy to virtual environment.") | |
endif() | |
file(APPEND $ENV{GITHUB_OUTPUT} "python_exe=${PYTHON_EXE}\n") | |
file(APPEND $ENV{GITHUB_OUTPUT} "pip_exe=${PIP_EXE}\n") | |
- name: Generate build instructions - Windows | |
shell: cmd | |
if: runner.os == 'Windows' | |
run: | | |
echo "Fortran compiler: %FC%." | |
echo "Fortran ${{ env.FC }}." | |
echo "Fortran ${{ steps.setup-fortran.outputs.fc }}." | |
echo "C:/Program Files (x86)/Intel/oneAPI/" | |
dir "C:/Program Files (x86)/Intel/oneAPI/" | |
echo "C:/Program Files (x86)/Intel/oneAPI/compiler/" | |
dir "C:/Program Files (x86)/Intel/oneAPI/compiler/" | |
echo "C:/Program Files (x86)/Intel/oneAPI/compiler/2023.2.0/" | |
dir "C:/Program Files (x86)/Intel/oneAPI/compiler/2023.2.0/" | |
echo "C:/Program Files (x86)/Intel/oneAPI/compiler/2023.2.0/windows/" | |
dir "C:/Program Files (x86)/Intel/oneAPI/compiler/2023.2.0/windows/" | |
echo "C:/Program Files (x86)/Intel/oneAPI/compiler/2023.2.0/windows/bin/" | |
dir "C:/Program Files (x86)/Intel/oneAPI/compiler/2023.2.0/windows/bin/" | |
echo "C:/Program Files (x86)/Intel/oneAPI/compiler/2023.2.0/windows/bin/intel64/" | |
dir "C:/Program Files (x86)/Intel/oneAPI/compiler/2023.2.0/windows/bin/intel64/" | |
echo "C:/Program Files (x86)/Intel/oneAPI/compiler/2023.2.0/windows/bin/intel64/ifort.exe" | |
dir "C:/Program Files (x86)/Intel/oneAPI/compiler/2023.2.0/windows/bin/intel64/ifort.exe" | |
rem dir "C:\\Program Files (x86)\\Intel\\oneAPI\\compiler\\2023.2.0\\windows\\bin" | |
rem cmake -G Ninja -S reprosim -B build-reprosim -D CMAKE_Fortran_COMPILER=ifort -D Python_EXECUTABLE=${{ steps.create-venv.outputs.python_exe }} | |
cmake -S reprosim -B build-reprosim -D CMAKE_Fortran_COMPILER="C:/Program Files (x86)/Intel/oneAPI/compiler/2023.2.0/windows/bin/intel64/ifort.exe" -D Python_EXECUTABLE=${{ steps.create-venv.outputs.python_exe }} | |
- name: Generate build instructions - Linux | |
shell: bash | |
if: runner.os == 'Linux' | |
run: | | |
cmake \ | |
-S reprosim \ | |
-B build-reprosim \ | |
-D CMAKE_Fortran_COMPILER=gfortran \ | |
-D CMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \ | |
-D Python_EXECUTABLE=${{ steps.create-venv.outputs.python_exe }} | |
- name: Generate build instructions - macOS | |
shell: bash | |
if: runner.os == 'macOS' | |
run: | | |
cmake \ | |
-S reprosim \ | |
-B build-reprosim \ | |
-D CMAKE_Fortran_COMPILER=gfortran-10 \ | |
-D CMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \ | |
-D Python_EXECUTABLE=${{ steps.create-venv.outputs.python_exe }} | |
- name: Build reprosim | |
shell: cmake -P {0} | |
run: | | |
if ("${{ runner.os }}" STREQUAL "Windows") | |
set(WINDOWS_BUILD_CONFIG --config ${{ matrix.config.build_type }}) | |
endif() | |
execute_process( | |
COMMAND cmake --build build-reprosim ${WINDOWS_BUILD_CONFIG} | |
RESULT_VARIABLE result | |
OUTPUT_VARIABLE output | |
ERROR_VARIABLE output | |
ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE | |
) | |
if (NOT result EQUAL 0) | |
string(REGEX MATCH "FAILED:.*$" error_message "${output}") | |
string(REPLACE "\n" "%0A" error_message "${error_message}") | |
message("::error::${error_message}") | |
message(FATAL_ERROR "Build failed.") | |
endif() | |
- name: Test reprosim | |
shell: bash | |
run: | | |
if [ "${{ runner.os }}" == "Windows" ]; then | |
multi_config_dir=/${{ matrix.config.build_type }} | |
fi | |
${{ steps.create-venv.outputs.pip_exe }} install wheel | |
${{ steps.create-venv.outputs.pip_exe }} install $GITHUB_WORKSPACE/build-reprosim/src/bindings/python$multi_config_dir | |
if [ "${{ runner.os }}" == "Windows" ]; then | |
# Horrible hack for GitHub actions Windows virtual machine. | |
echo "Not sure if this is needed." | |
#prefix_path=$(dirname $(dirname ${{ steps.create-venv.outputs.python_exe }})) | |
#cp $prefix_path/Library/bin/libifcoremd.dll $GITHUB_WORKSPACE/venv/Lib/site-packages/aether | |
#cp $prefix_path/Library/bin/libmmd.dll $GITHUB_WORKSPACE/venv/Lib/site-packages/aether | |
#cp $prefix_path/Library/bin/svml_dispmd.dll $GITHUB_WORKSPACE/venv/Lib/site-packages/aether | |
fi | |
cd build-reprosim | |
ctest --output-on-failure --build-config ${{ matrix.config.build_type }} | |
#${{ steps.create-venv.outputs.python_exe }} $GITHUB_WORKSPACE/reprosim/.github/scripts/diagnostics_test.py | |
#exit $? | |