Skip to content

Commit

Permalink
Attempt to add windows wheel build
Browse files Browse the repository at this point in the history
  • Loading branch information
kratman committed Sep 30, 2024
1 parent 264421d commit 6a017b5
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,67 @@ env:
FORCE_COLOR: 3

jobs:
build_windows_wheels:
name: Wheels (windows-latest)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Get number of cores on Windows
id: get_num_cores
shell: python
run: |
from os import environ, cpu_count
num_cpus = cpu_count()
output_file = environ['GITHUB_OUTPUT']
with open(output_file, "a", encoding="utf-8") as output_stream:
output_stream.write(f"count={num_cpus}\n")
- name: Install 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@v4
env:
cache-name: vckpg_binary_cache
with:
path: C:\Users\runneradmin\AppData\Local\vcpkg\archives
key: ${{ runner.os }}-build-VS2022-${{ env.cache-name }}-${{ hashFiles('vcpkg*.json') }}

- name: Build wheels on Windows
run: pipx run cibuildwheel --output-dir wheelhouse
env:
CIBW_ENVIRONMENT: >
PYBAMM_USE_VCPKG=ON
VCPKG_ROOT_DIR=C:\vcpkg
VCPKG_DEFAULT_TRIPLET=x64-windows-static-md
VCPKG_FEATURE_FLAGS=manifests,registries
CMAKE_GENERATOR="Visual Studio 17 2022"
CMAKE_GENERATOR_PLATFORM=x64
CMAKE_BUILD_PARALLEL_LEVEL=${{ steps.get_num_cores.outputs.count }}
CIBW_ARCHS: AMD64
CIBW_BEFORE_BUILD: python -m pip install setuptools wheel delvewheel # skip CasADi and CMake
CIBW_REPAIR_WHEEL_COMMAND: delvewheel repair --add-path C:/Windows/System32 -w {dest_dir} {wheel}
CIBW_TEST_EXTRAS: "dev"
CIBW_TEST_COMMAND: |
python -m pytest {project}/tests/unit
- name: Upload Windows wheels
uses: actions/upload-artifact@v4
with:
name: wheels_windows
path: ./wheelhouse/*.whl
if-no-files-found: error

build_manylinux_wheels:
name: Wheels (linux-amd64)
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ setup.log
install_KLU_Sundials
.idaklu
build

# Extra directories for local work
workspace
deploy
20 changes: 20 additions & 0 deletions vcpkg-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"default-registry": {
"kind": "builtin",
"baseline": ""
},
"registries": [
{
"kind": "git",
"repository": "https://github.com/pybamm-team/sundials-vcpkg-registry.git",
"baseline": "13d432fcf5da8591bb6cb2d46be9d6acf39cd02b",
"packages": ["sundials"]
},
{
"kind": "git",
"repository": "https://github.com/pybamm-team/casadi-vcpkg-registry.git",
"baseline": "1cb93f2fb71be26c874db724940ef8e604ee558e",
"packages": ["casadi"]
}
]
}
12 changes: 12 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "pybamm",
"version-string": "24.9.0",
"dependencies": [
"casadi",
{
"name": "sundials",
"default-features": false,
"features": ["klu"]
}
]
}

0 comments on commit 6a017b5

Please sign in to comment.