Windows build with MSVC #689
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: Windows build with MSVC | |
on: | |
push: | |
branches: [ master, dev ] | |
schedule: | |
- cron: '0 0 * * 0' | |
env: | |
GLPK_VERSION: "5.0" | |
GLPK_SHA256: 4a1013eebb50f728fc601bdd833b0b2870333c3b3e5a816eeba921d95bec6f15 | |
OSQP_VERSION: 0.6.3 | |
GSL_COMMIT_HASH: "f8e56946ce337a5a3f3229821faaf52607842874" | |
jobs: | |
Build_common_libs: | |
runs-on: windows-2019 | |
strategy: | |
matrix: | |
ARCH: [x64, x86] | |
include: | |
- ARCH: x64 | |
VC_TARGET: 64 | |
CMAKE_TARGET: x64 | |
- ARCH: x86 | |
VC_TARGET: 32 | |
CMAKE_TARGET: Win32 | |
steps: | |
- name: Setup msys2 | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: MINGW64 | |
install: coreutils unzip git | |
- name: Check cache for GLPK | |
id: cache-glpk | |
uses: actions/cache@v3 | |
with: | |
path: glpk-${{ env.GLPK_VERSION }} | |
key: ${{ runner.os }}-${{ matrix.ARCH }}-glpk-${{ env.GLPK_VERSION }}-${{ env.GLPK_SHA256 }} | |
- if: ${{ steps.cache-glpk.outputs.cache-hit != 'true' }} | |
name: Get GLPK | |
shell: msys2 {0} | |
run: | | |
wget -nv http://ftp.gnu.org/gnu/glpk/glpk-${{ env.GLPK_VERSION }}.tar.gz | |
echo "${GLPK_SHA256} glpk-${{ env.GLPK_VERSION }}.tar.gz" > GLPK.sha256 | |
shasum -a 256 -c GLPK.sha256 | |
tar -xf glpk-${{ env.GLPK_VERSION }}.tar.gz | |
- if: ${{ steps.cache-glpk.outputs.cache-hit != 'true' }} | |
name: Compile GLPK | |
run: | | |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars${{ matrix.VC_TARGET }}.bat" | |
cd glpk-${{ env.GLPK_VERSION }}\w64 | |
cp config_VC config.h | |
nmake /f Makefile_VC glpk.lib | |
dir | |
cd ..\.. | |
shell: cmd | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: glpk-${{ matrix.ARCH }} | |
path: | | |
glpk-${{ env.GLPK_VERSION }}\w64\* | |
glpk-${{ env.GLPK_VERSION }}\src\glpk.h | |
- name: Check cache for OSQP | |
id: cache-osqp | |
uses: actions/cache@v3 | |
with: | |
path: osqp | |
key: ${{ runner.os }}-${{ matrix.ARCH }}-osqp-${{ env.OSQP_VERSION }} | |
- if: ${{ steps.cache-osqp.outputs.cache-hit != 'true' }} | |
name: Get OSQP | |
shell: msys2 {0} | |
run: | | |
git clone --recursive https://github.com/oxfordcontrol/osqp.git | |
cd osqp | |
git checkout v${{ env.OSQP_VERSION }} | |
git submodule sync --recursive | |
git -c protocol.version=2 submodule update --init --force --depth=1 --recursive | |
- if: ${{ steps.cache-osqp.outputs.cache-hit != 'true' }} | |
name: Compile OSQP | |
run: | | |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars${{ matrix.VC_TARGET }}.bat" | |
cd osqp | |
mkdir build | |
cd build | |
cmake -G "Visual Studio 16 2019" -A ${{ matrix.CMAKE_TARGET }} -DCMAKE_INSTALL_PREFIX=dist .. | |
cmake --build . --target install | |
shell: cmd | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: osqp-${{ matrix.ARCH }} | |
path: osqp/build/dist/* | |
- name: Check cache for GSL | |
id: cache-gsl | |
uses: actions/cache@v3 | |
with: | |
path: gsl | |
key: ${{ runner.os }}-${{ matrix.ARCH }}-osqp-${{ env.GSL_COMMIT_HASH }} | |
- if: ${{ steps.cache-gsl.outputs.cache-hit != 'true' }} | |
name: Get GSL | |
shell: msys2 {0} | |
run: | | |
git clone --recursive https://github.com/ampl/gsl.git | |
cd gsl | |
git checkout ${GSL_COMMIT_HASH} | |
- if: ${{ steps.cache-gsl.outputs.cache-hit != 'true' }} | |
name: Compile GSL | |
run: | | |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars${{ matrix.VC_TARGET }}.bat" | |
cd gsl | |
mkdir build | |
cd build | |
cmake -G "Visual Studio 16 2019" -A ${{ matrix.CMAKE_TARGET }} -DGSL_INSTALL_MULTI_CONFIG=ON -DBUILD_SHARED_LIBS=ON -DMSVC_RUNTIME_DYNAMIC=ON -DCMAKE_INSTALL_PREFIX=dist .. | |
cmake --build . --target install | |
shell: cmd | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: gsl-${{ matrix.ARCH }} | |
path: gsl/build/dist/* | |
build: | |
needs: Build_common_libs | |
runs-on: windows-2019 | |
env: | |
KVXOPT_BUILD_GSL: 1 | |
KVXOPT_BUILD_FFTW: 1 | |
KVXOPT_BUILD_GLPK: 1 | |
KVXOPT_BUILD_DSDP: 0 | |
KVXOPT_MSVC: 1 | |
KVXOPT_BUILD_OSQP: 1 | |
SUITESPARSE_VERSION: 7.7.0 | |
SUITESPARSE_SHA256: 529b067f5d80981f45ddf6766627b8fc5af619822f068f342aab776e683df4f3 | |
OPENBLAS_VERSION: 0.3.23 | |
FFTW_VERSION: 3.3.5 | |
strategy: | |
matrix: | |
python-version: ['3.8', '3.9', '3.10', '3.11'] | |
suite-sparse: [src_suitesparse] | |
ARCH: [x64, x86] | |
include: | |
- ARCH: x64 | |
VC_TARGET: 64 | |
CMAKE_TARGET: x64 | |
PYTHON_ARCH_TARGET: win-amd64 | |
OPENBLAS_SHA256: e3a82e60db8d6197228790567e7cf74f2c421a65b29f848977a07b5457debdaa | |
FFTW_SHA256: cfd88dc0e8d7001115ea79e069a2c695d52c8947f5b4f3b7ac54a192756f439f | |
- ARCH: x86 | |
VC_TARGET: 32 | |
CMAKE_TARGET: Win32 | |
PYTHON_ARCH_TARGET: win32 | |
OPENBLAS_SHA256: 89060f862ca33219aaf7ef49b58a0a8b2d763236a1c6a16c693cd28146a812e6 | |
FFTW_SHA256: 29882a43033c9393479a4df52a2e9120589c06a2b724155b1a682747fa3e57d4 | |
- python-version: 3.8 | |
PYTHON_TARGET: 3.8 | |
- python-version: 3.9 | |
PYTHON_TARGET: 3.9 | |
- python-version: 3.10 | |
PYTHON_TARGET: cpython-310 | |
- python-version: 3.11 | |
PYTHON_TARGET: cpython-311 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: ${{ matrix.ARCH}} | |
- name: Setup msys2 | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: MINGW64 | |
install: coreutils unzip | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pytest pytest-cov coveralls wheel numpy build | |
- name: Get openblas | |
shell: msys2 {0} | |
run: | | |
wget https://github.com/openmathlib/OpenBLAS/releases/download/v${OPENBLAS_VERSION}/OpenBLAS-${OPENBLAS_VERSION}-${{matrix.ARCH}}.zip | |
wget https://raw.githubusercontent.com/xianyi/OpenBLAS/v${OPENBLAS_VERSION}/LICENSE -O OpenBLAS_LINCENSE | |
echo "${{matrix.OPENBLAS_SHA256}} OpenBLAS-${OPENBLAS_VERSION}-${{ matrix.ARCH }}.zip" > OpenBLAS.sha256 | |
shasum -a 256 -c OpenBLAS.sha256 | |
mkdir src/python/.libs | |
mkdir OpenBLAS | |
unzip OpenBLAS-${OPENBLAS_VERSION}-${{matrix.ARCH}}.zip -d OpenBLAS/ | |
cp OpenBLAS/bin/libopenblas.dll src/python/.libs | |
echo "KVXOPT_BLAS_LIB_DIR=${{github.workspace}}/OpenBLAS/lib/" >> $GITHUB_ENV | |
echo "KVXOPT_LAPACK_LIB=libopenblas" >> $GITHUB_ENV | |
echo "KVXOPT_BLAS_LIB=libopenblas" >> $GITHUB_ENV | |
- name: Get FFTW | |
shell: msys2 {0} | |
run: | | |
wget ftp://ftp.fftw.org/pub/fftw/fftw-${FFTW_VERSION}-dll${{matrix.VC_TARGET}}.zip | |
echo "${{matrix.FFTW_SHA256}} fftw-${FFTW_VERSION}-dll${{ matrix.VC_TARGET }}.zip" > FFTW.sha256 | |
shasum -a 256 -c FFTW.sha256 | |
mkdir fftw_lib | |
unzip fftw-${FFTW_VERSION}-dll${{matrix.VC_TARGET}}.zip -d fftw_lib/ | |
cp fftw_lib/libfftw3-3.dll src/python/.libs | |
echo "KVXOPT_FFTW_LIB_DIR=${{github.workspace}}/fftw_lib" >> $GITHUB_ENV | |
echo "KVXOPT_FFTW_INC_DIR=${{github.workspace}}/fftw_lib" >> $GITHUB_ENV | |
echo "KVXOPT_FFTW_LIB=libfftw3-3" >> $GITHUB_ENV | |
- name: Get suite-sparse source | |
shell: msys2 {0} | |
run: | | |
export MSYS=winsymlinks:lnk | |
wget https://github.com/DrTimothyAldenDavis/SuiteSparse/archive/v${{ env.SUITESPARSE_VERSION }}.tar.gz | |
echo "${SUITESPARSE_SHA256} v${{ env.SUITESPARSE_VERSION }}.tar.gz" > SuiteSparse.sha256 | |
shasum -a 256 -c SuiteSparse.sha256 | |
tar -xf v${{ env.SUITESPARSE_VERSION }}.tar.gz | |
echo "KVXOPT_SUITESPARSE_SRC_DIR=${{github.workspace}}/SuiteSparse-${{ env.SUITESPARSE_VERSION }}" >> $GITHUB_ENV | |
- uses: actions/download-artifact@v2 | |
with: | |
name: glpk-${{ matrix.ARCH }} | |
path: glpk_lib | |
- name: Set GLPK path | |
run: | | |
echo "KVXOPT_GLPK_LIB_DIR=${{github.workspace}}\glpk_lib\w64" >> $env:GITHUB_ENV | |
echo "KVXOPT_GLPK_INC_DIR=${{github.workspace}}\glpk_lib\src" >> $env:GITHUB_ENV | |
- uses: actions/download-artifact@v2 | |
with: | |
name: osqp-${{ matrix.ARCH }} | |
path: osqp_lib | |
- name: Set OSQP path | |
run: | | |
copy osqp_lib\bin\osqp.dll src\python\.libs | |
copy osqp_lib\bin\qdldl.dll src\python\.libs | |
echo "KVXOPT_OSQP_LIB_DIR=${{github.workspace}}\osqp_lib\lib" >> $env:GITHUB_ENV | |
echo "KVXOPT_OSQP_INC_DIR=${{github.workspace}}\osqp_lib\include\osqp" >> $env:GITHUB_ENV | |
- name: Create .lib import files for FFTW | |
run: | | |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars${{ matrix.VC_TARGET }}.bat" | |
cd fftw_lib | |
lib /machine:${{ matrix.ARCH }} /def:libfftw3-3.def | |
shell: cmd | |
- uses: actions/download-artifact@v2 | |
with: | |
name: gsl-${{ matrix.ARCH }} | |
path: gsl_lib | |
- name: Set GSL path | |
run: | | |
copy gsl_lib\bin\Debug\gsl.dll src\python\.libs | |
copy gsl_lib\bin\Debug\gslcblas.dll src\python\.libs | |
echo "KVXOPT_GSL_LIB_DIR=${{github.workspace}}\gsl_lib\lib\Debug" >> $env:GITHUB_ENV | |
echo "KVXOPT_GSL_INC_DIR=${{github.workspace}}\gsl_lib\include" >> $env:GITHUB_ENV | |
- name: Build | |
run: | | |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars${{ matrix.VC_TARGET }}.bat" | |
python -m build --wheel | |
pip install --no-index --find-links=${{github.workspace}}\dist kvxopt | |
shell: cmd | |
- name: Test | |
run: | | |
python -c 'from kvxopt import blas,lapack,cholmod,umfpack,klu,glpk,osqp,fftw,gsl' | |
pytest --cov=kvxopt tests/ |