Skip to content

Commit 2db997a

Browse files
authored
Merge branch 'quantumaikr:main' into main
2 parents 8a164f3 + 1a7fe20 commit 2db997a

42 files changed

Lines changed: 4052 additions & 284 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,28 @@ jobs:
5555
- name: Run tests
5656
run: ctest --test-dir build --output-on-failure --timeout 120 -C Release
5757

58+
# 10-year position guard: fail CI if structural moats erode.
59+
# Runs on Linux only (POSIX shell). Checks single-header LOC/size,
60+
# zero-deps, papers count, honest correction track, PyPI presence.
61+
- name: 10-year position guard
62+
if: matrix.os == 'ubuntu-latest'
63+
shell: bash
64+
run: |
65+
chmod +x score.sh
66+
bash score.sh --position 2>&1 | tee /tmp/position.log
67+
# Extract dimension percentage; require >= 75%.
68+
pct=$(grep -E '^\s*position\s' /tmp/position.log | awk '{print $2}' | tr -d '%')
69+
echo "position dimension: ${pct}%"
70+
if [ -z "$pct" ]; then
71+
echo "could not parse position score"
72+
exit 1
73+
fi
74+
# bash arithmetic: integer compare
75+
if [ "${pct%.*}" -lt 75 ]; then
76+
echo "::error::Position dimension regressed below 75% (${pct}%)"
77+
exit 1
78+
fi
79+
5880
- name: Upload test results
5981
if: failure()
6082
uses: actions/upload-artifact@v4

.github/workflows/publish.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: Publish quantcpp to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
- 'pypi-v*'
8+
workflow_dispatch:
9+
inputs:
10+
target:
11+
description: 'Where to publish'
12+
required: true
13+
default: 'testpypi'
14+
type: choice
15+
options:
16+
- testpypi
17+
- pypi
18+
19+
jobs:
20+
# ---------------------------------------------------------------------
21+
# Build platform-specific wheels via cibuildwheel
22+
# ---------------------------------------------------------------------
23+
build_wheels:
24+
name: Wheels on ${{ matrix.os }} (${{ matrix.arch }})
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
include:
30+
- os: ubuntu-latest
31+
arch: x86_64
32+
- os: ubuntu-24.04-arm # Native ARM runner (free, no QEMU)
33+
arch: aarch64
34+
- os: macos-14 # Apple Silicon (M-series). Intel macs deferred.
35+
arch: arm64
36+
# Windows mingw64 wheel is deferred — quant.h's clock_gettime shim
37+
# conflicts with mingw's native one. Windows users install via sdist
38+
# with MSVC for now. Tracked for v0.8.x.
39+
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
46+
# cibuildwheel mounts only the package-dir into Linux build containers,
47+
# so quant.h must already live inside bindings/python/ before invoke.
48+
# We stage it as bindings/python/quant.h (NOT inside quantcpp/, which
49+
# is .gitignore'd and would be excluded by isolated source copies).
50+
- name: Bundle quant.h into package
51+
shell: bash
52+
run: cp quant.h bindings/python/quant.h
53+
54+
- name: Build wheels
55+
uses: pypa/cibuildwheel@v2.21.3
56+
with:
57+
package-dir: bindings/python
58+
output-dir: wheelhouse
59+
env:
60+
CIBW_ARCHS: ${{ matrix.arch }}
61+
62+
- name: Upload wheels
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: wheels-${{ matrix.os }}-${{ matrix.arch }}
66+
path: ./wheelhouse/*.whl
67+
if-no-files-found: error
68+
69+
# ---------------------------------------------------------------------
70+
# Build the source distribution
71+
# ---------------------------------------------------------------------
72+
build_sdist:
73+
name: Source distribution
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/checkout@v4
77+
with:
78+
fetch-depth: 0
79+
80+
- uses: actions/setup-python@v5
81+
with:
82+
python-version: '3.11'
83+
84+
- name: Bundle quant.h into package
85+
shell: bash
86+
run: cp quant.h bindings/python/quant.h
87+
88+
- name: Build sdist
89+
run: |
90+
cd bindings/python
91+
python -m pip install --upgrade pip build
92+
python -m build --sdist
93+
94+
- name: Smoke-test sdist install (clean venv)
95+
run: |
96+
python -m venv /tmp/sdist-test
97+
/tmp/sdist-test/bin/pip install bindings/python/dist/quantcpp-*.tar.gz
98+
cd /tmp
99+
/tmp/sdist-test/bin/python -c "import quantcpp; from quantcpp._binding import get_lib; print('sdist OK:', quantcpp.__version__, get_lib().quant_version().decode())"
100+
101+
- uses: actions/upload-artifact@v4
102+
with:
103+
name: sdist
104+
path: bindings/python/dist/*.tar.gz
105+
if-no-files-found: error
106+
107+
# ---------------------------------------------------------------------
108+
# Publish — Trusted Publishing (OIDC), no API token needed
109+
# ---------------------------------------------------------------------
110+
publish_testpypi:
111+
name: Publish to TestPyPI
112+
needs: [build_wheels, build_sdist]
113+
runs-on: ubuntu-latest
114+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'testpypi'
115+
environment:
116+
name: testpypi
117+
url: https://test.pypi.org/p/quantcpp
118+
permissions:
119+
id-token: write
120+
steps:
121+
- uses: actions/download-artifact@v4
122+
with:
123+
path: dist
124+
merge-multiple: true
125+
- name: List artifacts
126+
run: ls -la dist/
127+
- uses: pypa/gh-action-pypi-publish@release/v1
128+
with:
129+
repository-url: https://test.pypi.org/legacy/
130+
skip-existing: true
131+
132+
publish_pypi:
133+
name: Publish to PyPI
134+
needs: [build_wheels, build_sdist]
135+
runs-on: ubuntu-latest
136+
# Auto-publish on tag push, OR manual dispatch with target=pypi
137+
if: |
138+
startsWith(github.ref, 'refs/tags/') ||
139+
(github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'pypi')
140+
environment:
141+
name: pypi
142+
url: https://pypi.org/p/quantcpp
143+
permissions:
144+
id-token: write
145+
steps:
146+
- uses: actions/download-artifact@v4
147+
with:
148+
path: dist
149+
merge-multiple: true
150+
- name: List artifacts
151+
run: ls -la dist/
152+
- uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@ tq_run.dSYM/
6262
.claude/worktrees/
6363
docs/assets/hero_backup.png
6464
build_nomt/
65+
build_nometal/

0 commit comments

Comments
 (0)