-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (146 loc) · 5.06 KB
/
Copy path_python.yaml
File metadata and controls
165 lines (146 loc) · 5.06 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
name: Python CI Workflow
on:
workflow_call:
secrets:
PYPI_API_TOKEN:
required: true
jobs:
# ----------------------------------------------------------------------------
# Build Python Wheels
# ----------------------------------------------------------------------------
python-build-wheels:
name: Build wheels on ${{ matrix.platform.runner }}
runs-on: ${{ matrix.platform.runner }}
strategy:
fail-fast: false
matrix:
platform:
- { runner: ubuntu-latest, artifact: linux-x86_64 }
- { runner: macos-14, artifact: macos-arm64 }
- { runner: windows-latest, artifact: windows-x86_64 }
python:
- {
version: "3.10",
target: wheel_cp310,
tag: cp310,
dist: dist_cp310,
}
- {
version: "3.11",
target: wheel_cp311,
tag: cp311,
dist: dist_cp311,
}
- { version: "3.12+", target: wheel_abi3, tag: abi3, dist: dist_abi3 }
env:
CI: true
BAZELISK_ALLOW_ENVS: Y
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache Bazel
uses: actions/cache@v4
with:
path: |
~/.cache/bazel
C:\bzl
key: bazel-${{ runner.os }}
restore-keys: bazel-${{ runner.os }}
- name: Build wheels (Unix)
if: runner.os != 'Windows'
shell: bash
env:
MSYS2_ARG_CONV_EXCL: "*"
run: |
bazel build //python:${{ matrix.python.target }}.dist
BAZEL_BIN="$(bazel info bazel-bin)"
mkdir -p dist
cp "${BAZEL_BIN}/python/${{ matrix.python.dist }}/"*.whl dist/
- name: Build wheels (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$bazelArgs = @("--output_user_root=C:/bzl")
bazel @bazelArgs build //python:${{ matrix.python.target }}.dist
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$bazelBin = bazel @bazelArgs info bazel-bin
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
New-Item -ItemType Directory -Force -Path dist | Out-Null
Copy-Item "$bazelBin/python/${{ matrix.python.dist }}/*.whl" dist/
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.platform.artifact }}-${{ matrix.python.tag }}
path: dist/*.whl
# ----------------------------------------------------------------------------
# Test Python Bindings
# ----------------------------------------------------------------------------
python-test:
name: Test Python Bindings
runs-on: ubuntu-latest
needs: python-build-wheels
strategy:
fail-fast: false
matrix:
python:
- { version: "3.10", tag: cp310 }
- { version: "3.11", tag: cp311 }
- { version: "3.12", tag: abi3 }
- { version: "3.13", tag: abi3 }
env:
CI: true
BAZELISK_ALLOW_ENVS: Y
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache Bazel
uses: actions/cache@v4
with:
path: ~/.cache/bazel
key: bazel-${{ runner.os }}
restore-keys: bazel-${{ runner.os }}
- name: Setup Python ${{ matrix.python.version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python.version }}
- name: Download Linux wheel
uses: actions/download-artifact@v4
with:
name: wheels-linux-x86_64-${{ matrix.python.tag }}
path: dist/
- name: Smoke test built wheel
run: |
python -m pip install --upgrade pip
python -m pip install dist/*.whl
python -c "import dv_py; value = dv_py.DimensionalVariable(10, 'm').value(); print(value)"
- name: Test Python Bindings
run: bazel test //python/... --test_output=errors --keep_going
- name: Run Python Example
run: bazel run //examples/python:python_example
- name: Run Python Regression Tests
run: bazel test //tests:regression_python_tests --test_output=errors --keep_going
# ----------------------------------------------------------------------------
# Publish Python Wheels
# ----------------------------------------------------------------------------
python-publish-pypi:
name: Publish Python Wheels to PyPI
needs: [python-build-wheels, python-test]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
steps:
- name: Download all wheels
uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: dist/