-
Notifications
You must be signed in to change notification settings - Fork 34
360 lines (309 loc) · 13.6 KB
/
Copy pathpython.yml
File metadata and controls
360 lines (309 loc) · 13.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
name: 🐍 Bindings
on:
release:
types:
- published
push:
branches:
- master
pull_request:
workflow_dispatch:
inputs:
publish:
type: boolean
description: Publish on PyPi
env:
VCPKG_COMMIT: 72d876b20f06129a1b1e0db80c7075fe3e419d7c
jobs:
test-bindings:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
container: ghcr.io/viennatools/vienna-builder:cuda-suite-python
- os: windows-latest
- os: macos-15-intel
- os: macos-latest
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
env:
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/.vcpkg-bincache
name: "🐍 Test Bindings on ${{ matrix.os }}"
steps:
- name: 📥 Checkout
uses: actions/checkout@v6
- name: 🖥️ Setup Environment
uses: ./.github/actions/setup
with:
os: ${{ matrix.os }}
- name: 🖥️ Setup vcpkg (Windows)
shell: pwsh
if: ${{ matrix.os == 'windows-latest' }}
run: |
Remove-Item Env:VCPKG_ROOT -ErrorAction SilentlyContinue
git clone https://github.com/microsoft/vcpkg.git
git -C vcpkg checkout $env:VCPKG_COMMIT
& .\vcpkg\bootstrap-vcpkg.bat
"VCPKG_ROOT=$($env:GITHUB_WORKSPACE)\vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
New-Item -ItemType Directory -Force -Path "${{ env.VCPKG_DEFAULT_BINARY_CACHE }}"
- name: 📋 Install MacOS Dependencies
if: ${{ startsWith(matrix.os, 'macos-') }}
run: brew install embree tbb vtk
- name: 🔑 Prepare vcpkg cache key (Windows)
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
$manifest = Get-Content vcpkg.json -Raw | ConvertFrom-Json
$cacheKey = [ordered]@{
dependencies = $manifest.dependencies
features = $manifest.features
defaultFeatures = $manifest.'default-features'
overrides = $manifest.overrides
builtinBaseline = $manifest.'builtin-baseline'
}
$cacheKey | ConvertTo-Json -Depth 20 | Out-File -FilePath vcpkg-cache-key.json -Encoding utf8
Get-Content vcpkg-cache-key.json
- name: 🦥 Cache vcpkg installed (Windows)
if: ${{ matrix.os == 'windows-latest' }}
id: vcpkg-installed-cache
uses: actions/cache@v5
with:
path: ${{ github.workspace }}/vcpkg_installed
key: vcpkg-installed-${{ matrix.os }}-${{ env.VCPKG_COMMIT }}-${{ hashFiles('vcpkg-cache-key.json') }}
restore-keys: |
vcpkg-installed-${{ matrix.os }}-${{ env.VCPKG_COMMIT }}-
- name: 🛠️ Build Dependencies (Windows)
if: ${{ matrix.os == 'windows-latest' && steps.vcpkg-installed-cache.outputs.cache-hit != 'true' }}
shell: pwsh
run: |
./vcpkg/vcpkg install --triplet x64-windows
- name: 🐍 Build and check Python Module (Windows)
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
python -m venv venv
$toolchain = "${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake".Replace('\', '/')
$vcpkgInstalled = "${{ github.workspace }}/vcpkg_installed".Replace('\', '/')
$viennalsVer = python -c "import re; print(re.search(r'ViennaLS>=([0-9.]+)', open('pyproject.toml').read()).group(1))"
.\venv\Scripts\python -m pip install --upgrade pip
$cmakeExtra = "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF"
.\venv\Scripts\python -m pip install "ViennaLS>=$viennalsVer"
if ($LASTEXITCODE -ne 0) {
git clone --depth 1 --branch master https://github.com/ViennaTools/ViennaLS.git _viennals
if ($LASTEXITCODE -ne 0) { exit 1 }
$env:CMAKE_ARGS = $cmakeExtra
.\venv\Scripts\python -m pip install ./_viennals `
--config-settings=cmake.define.CMAKE_TOOLCHAIN_FILE="$toolchain" `
--config-settings=cmake.define.VCPKG_TARGET_TRIPLET="x64-windows" `
--config-settings=cmake.define.VCPKG_INSTALLED_DIR="$vcpkgInstalled" `
--config-settings=cmake.define.VCPKG_MANIFEST_INSTALL=OFF
$cmakeExtra = "$cmakeExtra -DCPM_ViennaLS_SOURCE=$((Get-Location).Path)/_viennals"
}
$env:CMAKE_ARGS = $cmakeExtra
.\venv\Scripts\python -m pip install . --no-deps `
--config-settings=cmake.define.CMAKE_TOOLCHAIN_FILE="$toolchain" `
--config-settings=cmake.define.VCPKG_TARGET_TRIPLET="x64-windows" `
--config-settings=cmake.define.VCPKG_INSTALLED_DIR="$vcpkgInstalled" `
--config-settings=cmake.define.VCPKG_MANIFEST_INSTALL=OFF
.\venv\Scripts\python -c "import viennaps; print(viennaps.__doc__)"
- name: 🐍 Build and check Python Module (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
python -m venv venv
VIENNALS_VER=$(python3 -c "import re; print(re.search(r'ViennaLS>=([0-9.]+)', open('pyproject.toml').read()).group(1))")
CMAKE_EXTRA="-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF -DVIENNAPS_USE_GPU=ON -DVIENNACORE_LINK_CUDA_DRIVER=OFF"
if ! ./venv/bin/pip install "ViennaLS>=${VIENNALS_VER}"; then
rm -rf _viennals
git clone --depth 1 --branch master https://github.com/ViennaTools/ViennaLS.git _viennals
CMAKE_ARGS="${CMAKE_EXTRA}" ./venv/bin/pip install ./_viennals
CMAKE_EXTRA="${CMAKE_EXTRA} -DCPM_ViennaLS_SOURCE=$(pwd)/_viennals"
fi
CMAKE_ARGS="${CMAKE_EXTRA}" ./venv/bin/pip install . --no-deps
./venv/bin/python -c "import viennaps; print(viennaps.__doc__)"
- name: 🐍 Build and check Python Module (macOS)
if: ${{ startsWith(matrix.os, 'macos-') }}
run: |
python -m venv venv
./venv/bin/python -m pip install --upgrade pip
VIENNALS_VER=$(python3 -c "import re; print(re.search(r'ViennaLS>=([0-9.]+)', open('pyproject.toml').read()).group(1))")
CMAKE_EXTRA="-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF"
if ! ./venv/bin/pip install "ViennaLS>=${VIENNALS_VER}"; then
rm -rf _viennals
git clone --depth 1 --branch master https://github.com/ViennaTools/ViennaLS.git _viennals
CMAKE_ARGS="${CMAKE_EXTRA}" ./venv/bin/pip install ./_viennals
CMAKE_EXTRA="${CMAKE_EXTRA} -DCPM_ViennaLS_SOURCE=$(pwd)/_viennals"
fi
CMAKE_ARGS="${CMAKE_EXTRA}" ./venv/bin/pip install . --no-deps
./venv/bin/python -c "import viennaps; print(viennaps.__doc__)"
- name: 📦 Upload Artifact
uses: actions/upload-artifact@v7
with:
name: Pre-Built (${{ matrix.os }})
path: venv
package:
if: ${{ github.event_name == 'release' || github.event.inputs.publish == 'true' || github.event_name == 'workflow_dispatch' }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
skip: "cp38-* cp39-* *-manylinux_i686 *-musllinux_*"
- os: windows-latest
skip: "cp38-* cp39-*"
- os: macos-15-intel
archs: x86_64
skip: "cp38-* cp39-* cp310-*"
- os: macos-15
archs: arm64
skip: "cp38-* cp39-* cp310-*"
runs-on: ${{ matrix.os }}
name: "🐍 Package Bindings on ${{ matrix.os }}"
env:
VCPKG_COMMIT: 72d876b20f06129a1b1e0db80c7075fe3e419d7c
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/.vcpkg-bincache
steps:
- name: 📥 Checkout
uses: actions/checkout@v6
- name: 🖥️ Setup Environment
uses: ./.github/actions/setup
with:
os: ${{ matrix.os }}
- name: 🛞 CIBuildWheel
run: pip install cibuildwheel==3.4.0 --break-system-packages
- name: Inspect OpenMP runtime (Windows)
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
$roots = @(
$env:llvmX64,
$env:VCToolsRedistDir,
$env:VCINSTALLDIR,
$env:VCToolsInstallDir,
'C:\Program Files\LLVM\bin',
'C:\Program Files (x86)\LLVM\bin'
) | Where-Object { $_ -and (Test-Path $_) } | Select-Object -Unique
$matches = @()
foreach ($root in $roots) {
Write-Host "Searching $root"
$matches += Get-ChildItem -Path $root -Filter libomp140.x86_64.dll -Recurse -ErrorAction SilentlyContinue
}
if ($matches.Count -eq 0) {
Write-Warning "libomp140.x86_64.dll was not found in the Visual Studio or LLVM runtime locations."
} else {
$matches | Select-Object -ExpandProperty FullName
}
- name: 🏗️ Build Wheels (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_SKIP: ${{ matrix.skip }}
CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/viennatools/vienna-builder:cuda-python
CIBW_REPAIR_WHEEL_COMMAND_LINUX: >-
auditwheel repair
--exclude libcuda.so.1
--exclude libcudart.so.12
--exclude libcusparse.so.12
--exclude libnvJitLink.so.12
-w {dest_dir} {wheel}
CIBW_TEST_COMMAND: >-
python -c "import viennaps;
print(viennaps.__file__);
print(viennaps.d2);
print(viennaps.d3)"
CIBW_CONFIG_SETTINGS: >-
cmake.define.VIENNAPS_PACKAGE_PYTHON=ON
cmake.define.VIENNAPS_IS_CI=ON
cmake.define.VIENNAPS_USE_GPU=ON
cmake.define.VIENNACORE_LINK_CUDA_DRIVER=OFF
cmake.define.VIENNAPS_VTK_RENDERING=ON
cmake.define.USE_IPO=OFF
- name: 🏗️ Build Wheels (Other)
if: ${{ matrix.os != 'ubuntu-latest' }}
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_SKIP: ${{ matrix.skip }}
CIBW_ARCHS_WINDOWS: auto64
CIBW_ARCHS_MACOS: ${{ matrix.archs }}
CIBW_BEFORE_TEST: >-
python -m pip install "ViennaLS>=5.8.3" ||
python -m pip install "git+https://github.com/ViennaTools/ViennaLS.git@v5.8.3#egg=ViennaLS"
CIBW_TEST_COMMAND: >-
python -c "import viennaps;
print(viennaps.__file__);
print(viennaps.d2);
print(viennaps.d3)"
CIBW_CONFIG_SETTINGS: >-
cmake.define.VIENNAPS_PACKAGE_PYTHON=ON
cmake.define.VIENNAPS_IS_CI=ON
cmake.define.VIENNAPS_VTK_RENDERING=ON
- name: 🔎 Inspect wheel contents
shell: bash
run: |
python - <<'PY'
import glob
import sys
import zipfile
missing = []
for wheel in glob.glob("wheelhouse/*.whl"):
print("\n" + wheel)
with zipfile.ZipFile(wheel) as zf:
entries = sorted(zf.infolist(), key=lambda item: item.file_size, reverse=True)
for entry in entries[:40]:
size_mb = entry.file_size / 1024 / 1024
print(f"{size_mb:8.2f} MB {entry.filename}")
names = [entry.filename for entry in entries]
if "win_amd64" in wheel:
libs = [name for name in names if name.startswith("viennaps.libs/")]
libs_lower = [n.lower() for n in libs]
openmp = [n for n in libs_lower if "libomp140" in n]
embree = [n for n in libs_lower if "embree" in n]
tbb = [n for n in libs_lower if "tbb" in n]
core = next(
name
for name in names
if name.startswith("viennaps/_core") and name.endswith(".pyd")
)
core_bytes = zf.read(core)
print("\nWindows runtime libraries:")
for name in libs:
print(f" {name}")
if not libs:
missing.append(f"{wheel}: missing viennaps.libs/")
if not openmp:
missing.append(f"{wheel}: missing viennaps.libs/libomp140.x86_64.dll")
if not embree:
missing.append(f"{wheel}: missing viennaps.libs/embree*.dll")
if not tbb:
missing.append(f"{wheel}: missing viennaps.libs/tbb*.dll")
if b"omp_set_nested" in core_bytes:
missing.append(f"{wheel}: _core.pyd still references deprecated omp_set_nested")
if missing:
print("\nWheel runtime checks failed:", file=sys.stderr)
for item in missing:
print(f" {item}", file=sys.stderr)
raise SystemExit(1)
PY
- name: 📦 Upload Artifact
uses: actions/upload-artifact@v7
with:
name: wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl
deploy:
if: ${{ github.event_name == 'release' || github.event.inputs.publish == 'true' }}
needs: [package]
permissions:
id-token: write
runs-on: ubuntu-latest
name: "🐍 Publish Bindings"
steps:
- name: 📦 Download Wheels
uses: actions/download-artifact@v8
with:
pattern: wheels-*
path: dist
merge-multiple: true
- name: 🚀 Publish Wheels
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true