-
Notifications
You must be signed in to change notification settings - Fork 4
185 lines (176 loc) · 6.66 KB
/
python.yml
File metadata and controls
185 lines (176 loc) · 6.66 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
name: Python SDK
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: python-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build wheel (${{ matrix.label }})
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python: "3.12"
label: ubuntu py3.12
- os: macos-latest
python: "3.12"
label: macos py3.12
- os: windows-latest
python: "3.12"
label: windows py3.12
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-rust-deps
with:
components: clippy
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
- run: cargo run -p thetadatadx --features config-file --bin generate_sdk_surfaces --locked -- --check
# `too_many_arguments` is allow-listed because every offender is a
# generated pyo3 endpoint method whose signature mirrors the
# underlying REST surface — not a real code smell. Every other
# warning (including new ones) stays fatal.
- name: Clippy (Python SDK)
shell: bash
working-directory: sdks/python
run: cargo clippy --all-targets -- -D warnings -A clippy::too_many_arguments
- shell: bash
run: python -m pip install --upgrade pip "maturin>=1.9.4,<2.0"
# Linux wheel uses the manylinux2014 (glibc 2.17) Docker toolchain so
# the published wheel is installable on every supported platform —
# Ubuntu 22.04 / RHEL 8 / Google Colab / Databricks / CentOS 7 all
# pin glibc at or below 2.34. Building on `ubuntu-latest` directly
# tags the wheel with the host glibc floor (currently 2.38), which
# silently breaks every older runtime.
- name: Build wheel (Linux, manylinux2014)
if: matrix.os == 'ubuntu-latest'
uses: PyO3/maturin-action@v1
with:
# `--interpreter python3.9` targets the abi3 floor declared in
# `sdks/python/Cargo.toml` (pyo3/abi3-py39). The default
# `python` binary inside the manylinux2014 Docker image is
# Python 2.7, which lacks `sys.implementation` and breaks
# maturin's interpreter probe; `python3.9` resolves cleanly
# inside the image.
command: build
args: --release -m sdks/python/Cargo.toml -o dist/ --interpreter python3.9
manylinux: '2014'
target: x86_64
# The manylinux2014 CentOS 7 image ships no `protoc`, which
# `tonic-prost-build` needs to compile `proto/mdds.proto`.
# Install a pinned prebuilt binary before maturin starts.
before-script-linux: |
set -euo pipefail
PROTOC_VERSION=29.3
curl -fsSL -o /tmp/protoc.zip \
"https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip"
unzip -q /tmp/protoc.zip -d /usr/local
chmod 0755 /usr/local/bin/protoc
protoc --version
- name: Build wheel (macOS / Windows)
if: matrix.os != 'ubuntu-latest'
shell: bash
run: python -m maturin build --release -m sdks/python/Cargo.toml -o dist/ --interpreter python
- name: Install wheel
shell: bash
run: python -m pip install --force-reinstall dist/*.whl
- name: Import smoke
shell: bash
run: |
python - <<'PY'
import thetadatadx
from thetadatadx import implied_volatility
iv, err = implied_volatility(450.0, 455.0, 0.05, 0.015, 30.0 / 365.0, 8.50, "C")
print(thetadatadx.__file__)
print(round(iv, 6), round(err, 6))
PY
# Run the Python pytest suite against the freshly-installed wheel. The
# `THETADX_TEST_CREDS`-gated tests skip cleanly without secrets so this
# step exercises the install path AND the public-API surface contracts
# that don't need a live FPSS handshake. Kept as a separate step from
# the import smoke above so a pytest regression points at the suite,
# not at the smoke output.
- name: Pytest suite (skipped tests stay skipped)
shell: bash
run: |
python -m pip install pytest
python -m pytest sdks/python/tests/ -v
- uses: actions/upload-artifact@v7
with:
name: wheel-${{ runner.os }}
path: dist/*.whl
compatibility:
name: ABI3 smoke (${{ matrix.os }} py${{ matrix.python }})
runs-on: ${{ matrix.os }}
needs: build
timeout-minutes: 15
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ["3.9", "3.14"]
steps:
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
- uses: actions/download-artifact@v8
with:
name: wheel-${{ runner.os }}
path: dist/
- shell: bash
run: python -m pip install --force-reinstall dist/*.whl
- shell: bash
run: python -c "import thetadatadx; print(thetadatadx.__file__)"
sdist:
name: Build source distribution
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-rust-deps
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- run: cargo run -p thetadatadx --features config-file --bin generate_sdk_surfaces --locked -- --check
- shell: bash
run: python -m pip install --upgrade pip "maturin>=1.9.4,<2.0"
- shell: bash
run: python -m maturin sdist -m sdks/python/Cargo.toml -o dist/
- shell: bash
run: python -m pip install --force-reinstall dist/*.tar.gz
- shell: bash
run: python -c "import thetadatadx"
- if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v7
with:
name: sdist
path: dist/*.tar.gz
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build, sdist]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v8
with:
path: dist/
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true