Skip to content

Commit

Permalink
pybamm-team#2047 swap back to visual studio for windows build, compil…
Browse files Browse the repository at this point in the history
…e casadi manually
  • Loading branch information
martinjrobins committed May 6, 2022
1 parent 78f68c2 commit 7520d35
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 78 deletions.
116 changes: 48 additions & 68 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,52 @@ on:
default: 'pypi'

jobs:
build_windows_wheels:
build_windows_wheels:
runs-on: windows-latest
steps:

- uses: actions/setup-python@v2

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==1.9.0

- name: Clone pybind11 repo (no history)
run: git clone --depth 1 --branch v2.6.2 https://github.com/pybind/pybind11.git

# see https://github.com/pybamm-team/PyBaMM/pull/1930
- name: Install the latest version of vcpkg on windows
run: |
cd C:\
rm -r -fo 'C:\vcpkg'
git clone https://github.com/microsoft/vcpkg
cd vcpkg
.\bootstrap-vcpkg.bat
- name: Cache packages installed through vcpkg on windows
uses: actions/cache@v2
env:
cache-name: vckpg_binary_cache
with:
path: C:\Users\runneradmin\AppData\Local\vcpkg\archives
key: ${{ runner.os }}-build-${{ env.cache-name }}-v1-${{ hashFiles('vcpkg*.json') }}

- name: Build 64 bits wheels on Windows
if: matrix.os == 'windows-latest'
run: |
choco install --yes visualstudio2019community
choco install --yes visualstudio2019-workload-nativedesktop
python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ENVIRONMENT: "PYBAMM_USE_VCPKG=ON VCPKG_ROOT_DIR=$cd/vcpkg VCPKG_DEFAULT_TRIPLET=x64-windows-static VCPKG_FEATURE_FLAGS=manifests,registries CMAKE_GENERATOR=\"Visual Studio 16 2019\" CMAKE_GENERATOR_PLATFORM=x64"
CIBW_ARCHS: "AMD64"

- uses: actions/upload-artifact@v2
with:
name: wheels
path: ./wheelhouse/*.whl
- uses: actions/checkout@v2

build_windows_wheels_msys:
runs-on: windows-latest
defaults:
run:
Expand Down Expand Up @@ -77,7 +122,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v2

Expand All @@ -99,77 +144,12 @@ jobs:
python scripts/install_KLU_Sundials.py
- name: Build wheels on Linux and MacOS
if: matrix.os != 'windows-latest'
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BEFORE_ALL_LINUX: "bash build_manylinux_wheels/install_sundials.sh 5.8.1 5.7.0"
CIBW_BEFORE_BUILD: "python -m pip install cmake casadi numpy"
CIBW_SKIP: pp*


- name: Install mingw on windows
if: matrix.os == 'windows-latest'
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: >-
git
base-devel
mingw-w64-x86_64-toolchain
- name: Add mingw64 to path
if: matrix.os == 'windows-latest'
run: echo "D:/a/_temp/msys/msys64/mingw64/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: print path
if: matrix.os == 'windows-latest'
run: echo $env:PATH

- name: check gcc compiler
if: matrix.os == 'windows-latest'
run: |
gcc.exe --version
- name: check g++ compiler
if: matrix.os == 'windows-latest'
run: |
g++.exe --version
- name: check gfortran compiler
if: matrix.os == 'windows-latest'
run: |
gfortran.exe --version
# see https://github.com/pybamm-team/PyBaMM/pull/1930
- name: Install the latest version of vcpkg on windows
if: matrix.os == 'windows-latest'
run: |
cd C:\
rm -r -fo 'C:\vcpkg'
git clone https://github.com/microsoft/vcpkg
cd vcpkg
.\bootstrap-vcpkg.bat
- name: Cache packages installed through vcpkg on windows
if: matrix.os == 'windows-latest'
uses: actions/cache@v2
env:
cache-name: vckpg_binary_cache
with:
path: C:\Users\runneradmin\AppData\Local\vcpkg\archives
key: ${{ runner.os }}-build-${{ env.cache-name }}-v1-${{ hashFiles('vcpkg*.json') }}

- name: Build 64 bits wheels on Windows
if: matrix.os == 'windows-latest'
run: |
python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ENVIRONMENT: "PYBAMM_USE_VCPKG=ON VCPKG_ROOT_DIR=$cd/vcpkg VCPKG_DEFAULT_TRIPLET=x64-mingw-dynamic VCPKG_DEFAULT_HOST_TRIPLET=x64-mingw-dynamic VCPKG_FEATURE_FLAGS=manifests,registries CMAKE_GENERATOR=\"MinGW Makefiles\" CC=gcc CXX=g++"
CIBW_BEFORE_BUILD: "python -m pip install casadi numpy"
CIBW_ARCHS: "AMD64"
CIBW_BUILD_VERBOSITY: 1

- uses: actions/upload-artifact@v2
with:
name: wheels
Expand All @@ -178,7 +158,7 @@ jobs:

publish-pypi:
name: Upload wheels to PyPI
needs: build_wheels
needs: [build_wheels, build_windows_wheels]
runs-on: ubuntu-latest
steps:
- name: Download wheels
Expand Down
8 changes: 0 additions & 8 deletions CMakeBuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,13 @@ def set_vcpkg_environment_variables():
raise EnvironmentError(
"Environment variable 'VCPKG_DEFAULT_TRIPLET' is undefined."
)
if not os.getenv("VCPKG_DEFAULT_HOST_TRIPLET"):
raise EnvironmentError(
"Environment variable 'VCPKG_DEFAULT_HOST_TRIPLET' is undefined."
)

if not os.getenv("VCPKG_FEATURE_FLAGS"):
raise EnvironmentError(
"Environment variable 'VCPKG_FEATURE_FLAGS' is undefined."
)
return (
os.getenv("VCPKG_ROOT_DIR"),
os.getenv("VCPKG_DEFAULT_TRIPLET"),
os.getenv("VCPKG_DEFAULT_HOST_TRIPLET"),
os.getenv("VCPKG_FEATURE_FLAGS"),
)

Expand Down Expand Up @@ -110,12 +104,10 @@ def run(self):
(
vcpkg_root_dir,
vcpkg_default_triplet,
vcpkg_default_host_triplet,
vcpkg_feature_flags,
) = set_vcpkg_environment_variables()
build_env["vcpkg_root_dir"] = vcpkg_root_dir
build_env["vcpkg_default_triplet"] = vcpkg_default_triplet
build_env["vcpkg_default_host_triplet"] = vcpkg_default_host_triplet
build_env["vcpkg_feature_flags"] = vcpkg_feature_flags

cmake_list_dir = os.path.abspath(os.path.dirname(__file__))
Expand Down
6 changes: 6 additions & 0 deletions vcpkg-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
"repository": "https://github.com/pybamm-team/sundials-vcpkg-registry.git",
"baseline": "8ce5391ccddb4b3d0bf01a037ece3a6d72a708da",
"packages": [ "sundials" ]
},
{
"kind": "git",
"repository": "https://github.com/pybamm-team/casadi-vcpkg-registry.git",
"baseline": "1ba8ef0c87d525a584e00096837dfaff69920895",
"packages": [ "casadi" ]
}
]
}
5 changes: 3 additions & 2 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"name": "pybamm",
"version-string": "22.3",
"dependencies": [
"casadi",
{
"name": "sundials",
"default-features": false,
"features": [
"klu"
]
}
},
]
}
}

0 comments on commit 7520d35

Please sign in to comment.