Skip to content

Commit 9893163

Browse files
authored
adding cache for vcpkg
1 parent 101cf08 commit 9893163

1 file changed

Lines changed: 56 additions & 70 deletions

File tree

.github/workflows/pypi.yml

Lines changed: 56 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,75 @@
1-
name: Deploy to PYPI
1+
name: 🛠️ Build and test wheels
22

33
on:
4+
push:
5+
branches: [main]
6+
pull_request:
47
workflow_dispatch:
8+
59
jobs:
6-
7-
sdist:
8-
name: Build sdist
9-
runs-on: ubuntu-latest
10-
steps:
11-
- uses: actions/checkout@v4
12-
- uses: actions/setup-python@v5
13-
- name: Install dependencies
14-
run: |
15-
python -m pip install --upgrade pip
16-
pip install build
17-
- name: Build sdist
18-
run: python -m build --sdist
19-
- uses: actions/upload-artifact@v4
20-
with:
21-
name: dist
22-
path: ./dist/*.tar.gz
23-
wheels:
24-
name: Build wheels
10+
build:
11+
name: Build on ${{ matrix.os }} with Python ${{ matrix.python-version }}
2512
runs-on: ${{ matrix.os }}
2613
strategy:
2714
fail-fast: false
2815
matrix:
29-
os: [ubuntu-latest, macos-latest, macos-14,windows-latest]
30-
env:
31-
MACOSX_DEPLOYMENT_TARGET: '15.0'
32-
steps:
33-
- uses: actions/checkout@v4
34-
- uses: actions/setup-python@v5
35-
- name: Install dependencies
36-
run: |
37-
python -m pip install --upgrade pip
38-
pip install cibuildwheel
39-
- if: matrix.os == 'macos-latest' || matrix.os == 'macos-14'
40-
run: |
41-
brew install cgal
42-
- name: Bootstrap & install with vcpkg on Windows
43-
if: runner.os == 'Windows'
44-
run: |
45-
$Env:VCPKG_ROOT = "${{ github.workspace }}\vcpkg"
46-
git clone https://github.com/microsoft/vcpkg $Env:VCPKG_ROOT
47-
& $Env:VCPKG_ROOT\bootstrap-vcpkg.bat
48-
& $Env:VCPKG_ROOT\vcpkg.exe install yasm-tool:x86-windows cgal:x64-windows
49-
50-
# export VCPKG_ROOT so later steps can see it
51-
echo "VCPKG_ROOT=$Env:VCPKG_ROOT" >> $Env:GITHUB_ENV
16+
os: [ubuntu-22.04, macos-13, windows-2022]
17+
python-version: ["3.9", "3.10", "3.11", "3.12"]
5218

53-
# now inject your extra CMake flags:
54-
$toolchain = "$Env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
55-
echo "CMAKE_ARGS=-DCMAKE_TOOLCHAIN_FILE=${toolchain//\\//} -DVCPKG_ROOT=${Env:VCPKG_ROOT//\\//}" >> $Env:GITHUB_EN
56-
57-
- name: Build wheels
58-
run: |
59-
cibuildwheel --output-dir dist
60-
- uses: actions/upload-artifact@v4
61-
with:
62-
name: wheels-${{ matrix.os }}
63-
path: ./dist/*
64-
publish:
65-
name: Publish wheels and sdist to PyPI
66-
runs-on: ubuntu-latest
67-
permissions:
68-
id-token: write
69-
needs: [wheels,sdist]
7019
steps:
71-
- uses: actions/download-artifact@v4
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Python
24+
uses: actions/setup-python@v5
7225
with:
73-
path: artifacts
26+
python-version: ${{ matrix.python-version }}
7427

75-
- name: Move all distributions to `dist/`
28+
- name: Upgrade pip and install build tools
7629
run: |
77-
mkdir -p dist
78-
find artifacts -name '*.whl' -exec cp {} dist/ \;
79-
find artifacts -name '*.tar.gz' -exec cp {} dist/ \;
30+
python -m pip install --upgrade pip
31+
pip install build scikit-build-core pybind11 cibuildwheel
8032
81-
- uses: pypa/gh-action-pypi-publish@release/v1
33+
# 🧩 Cache vcpkg on Windows
34+
- name: Restore vcpkg cache
35+
if: runner.os == 'Windows'
36+
id: cache-vcpkg
37+
uses: actions/cache@v4
8238
with:
83-
skip-existing: true
84-
verbose: true
85-
packages-dir: dist/
39+
path: |
40+
C:\vcpkg
41+
key: vcpkg-${{ runner.os }}-${{ hashFiles('vcpkg.json') }}
42+
restore-keys: |
43+
vcpkg-${{ runner.os }}-
8644
45+
- name: Install vcpkg dependencies (Windows only)
46+
if: runner.os == 'Windows'
47+
shell: pwsh
48+
run: |
49+
$Env:VCPKG_ROOT = "C:\vcpkg"
50+
if (!(Test-Path $Env:VCPKG_ROOT)) {
51+
git clone https://github.com/microsoft/vcpkg $Env:VCPKG_ROOT
52+
& "$Env:VCPKG_ROOT\bootstrap-vcpkg.bat"
53+
}
54+
& "$Env:VCPKG_ROOT\vcpkg.exe" install yasm-tool:x86-windows cgal:x64-windows
55+
echo "VCPKG_ROOT=$Env:VCPKG_ROOT" >> $env:GITHUB_ENV
8756
57+
# 🐧 Linux / macOS system deps
58+
- name: Install CGAL (Linux)
59+
if: runner.os == 'Linux'
60+
run: sudo apt-get update && sudo apt-get install -y libcgal-dev libgmp-dev libmpfr-dev
8861

62+
- name: Install CGAL (macOS)
63+
if: runner.os == 'macOS'
64+
run: brew install cgal gmp mpfr
8965

66+
# 🧱 Build the wheel
67+
- name: Build wheel
68+
run: |
69+
pip install .
70+
python -c "import loop_cgal; print('✅ loop_cgal import successful')"
71+
72+
# 🧪 Optional tests
73+
- name: Run basic tests
74+
run: |
75+
python -c "import loop_cgal; print(loop_cgal.__doc__)"

0 commit comments

Comments
 (0)