Skip to content

Commit d3787c4

Browse files
ciaranraqartik
andauthored
Rust code (#91)
* Branch smash * Clippy cleanup * Update README * Makefile: pre-commit target -> lint target * Updating Python building/testing workflows to include Python 3.13 * Update README.md Co-authored-by: Kartik Singhal <kartik.singhal@quantinuum.com> * Update development.md Co-authored-by: Kartik Singhal <kartik.singhal@quantinuum.com> * Linting * Don't install optional dep that don't work >py3.13. Qulacs no longer default state-vector sim * Updating requirement version to fix Windows Python 3.13 issue... hopefully * Get Python 3.13 Windows working by allowing new NumPy * Dealing with weird numpy issue... * Update makefile/requirements to include numpy py<3.13 requirements * Removing redundant installations * Adding back pytest-cov to gitflow * Removing pytest-cov again after updating requirements * refactor pecos-qsims to pecos-qsim * Updating Cargo.toml to publishable style --------- Co-authored-by: Kartik Singhal <kartik.singhal@quantinuum.com>
1 parent eca0ce7 commit d3787c4

File tree

932 files changed

+11213
-4462
lines changed

Some content is hidden

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

932 files changed

+11213
-4462
lines changed

.github/workflows/python-app.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/python-release.yml

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
name: Python Artifacts
2+
3+
env:
4+
TRIGGER_ON_PR_PUSH: false # Set to true to enable triggers on PR pushes
5+
PYTHON_VERSION: '3.10'
6+
7+
on:
8+
push:
9+
branches:
10+
- development
11+
- master
12+
tags:
13+
- 'py-*'
14+
pull_request:
15+
branches:
16+
- development
17+
- master
18+
workflow_dispatch:
19+
inputs:
20+
sha:
21+
description: Commit SHA
22+
type: string
23+
dry_run:
24+
description: 'Dry run (build but not publish)'
25+
type: boolean
26+
default: true
27+
28+
concurrency:
29+
group: ${{ github.workflow }}-${{ github.ref }}
30+
cancel-in-progress: true
31+
32+
defaults:
33+
run:
34+
shell: bash
35+
36+
jobs:
37+
check_pr_push:
38+
runs-on: ubuntu-latest
39+
if: github.event_name == 'pull_request' && github.event.action != 'closed'
40+
outputs:
41+
run: ${{ steps.check.outputs.run }}
42+
steps:
43+
- name: Check if should run on PR push
44+
id: check
45+
run: |
46+
if [ "${{ env.TRIGGER_ON_PR_PUSH }}" = "true" ]; then
47+
echo "run=true" >> $GITHUB_OUTPUT
48+
else
49+
echo "run=false" >> $GITHUB_OUTPUT
50+
fi
51+
52+
build_sdist_pecos_rslib:
53+
needs: check_pr_push
54+
if: |
55+
always() &&
56+
(needs.check_pr_push.result == 'success' && needs.check_pr_push.outputs.run == 'true' || needs.check_pr_push.result == 'skipped') &&
57+
(github.event_name != 'pull_request' || github.event.pull_request.merged == true || github.event.action == 'opened' || github.event.action == 'synchronize')
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v4
61+
with:
62+
ref: ${{ inputs.sha || github.sha }}
63+
64+
- name: Set up Python
65+
uses: actions/setup-python@v5
66+
with:
67+
python-version: ${{ env.PYTHON_VERSION }}
68+
69+
- name: Remove conflicting README.md
70+
run: |
71+
if [ -f crates/pecos-python/README.md ]; then
72+
mv crates/pecos-python/README.md crates/pecos-python/README.md.bak
73+
echo "Moved conflicting README.md to README.md.bak"
74+
else
75+
echo "No conflicting README.md found"
76+
fi
77+
78+
- name: Build pecos-rslib SDist
79+
uses: PyO3/maturin-action@v1
80+
with:
81+
command: sdist
82+
args: --out dist
83+
working-directory: python/pecos-rslib
84+
85+
- name: Restore README.md
86+
if: always()
87+
run: |
88+
if [ -f crates/pecos-python/README.md.bak ]; then
89+
mv crates/pecos-python/README.md.bak crates/pecos-python/README.md
90+
echo "Restored README.md from backup"
91+
else
92+
echo "No README.md backup found"
93+
fi
94+
95+
- name: Test pecos-rslib SDist
96+
run: |
97+
pip install --force-reinstall --verbose python/pecos-rslib/dist/*.tar.gz
98+
python -c 'import pecos_rslib; print(pecos_rslib.__version__)'
99+
100+
- name: Upload pecos-rslib SDist
101+
uses: actions/upload-artifact@v4
102+
with:
103+
name: sdist-pecos-rslib
104+
path: python/pecos-rslib/dist/*.tar.gz
105+
106+
build_wheels_pecos_rslib:
107+
needs: check_pr_push
108+
if: |
109+
always() &&
110+
(needs.check_pr_push.result == 'success' && needs.check_pr_push.outputs.run == 'true' || needs.check_pr_push.result == 'skipped') &&
111+
(github.event_name != 'pull_request' || github.event.pull_request.merged == true || github.event.action == 'opened' || github.event.action == 'synchronize')
112+
runs-on: ${{ matrix.os }}
113+
strategy:
114+
fail-fast: false
115+
matrix:
116+
os: [ubuntu-latest, macos-latest, windows-latest]
117+
python-version: ['3.10', '3.11', '3.12', '3.13']
118+
architecture: [ x86_64, aarch64 ]
119+
exclude:
120+
- os: windows-latest
121+
architecture: aarch64
122+
123+
steps:
124+
- uses: actions/checkout@v4
125+
with:
126+
ref: ${{ inputs.sha || github.sha }}
127+
128+
- name: Set up Python
129+
uses: actions/setup-python@v5
130+
with:
131+
python-version: ${{ matrix.python-version }}
132+
133+
- name: Remove conflicting README.md
134+
run: |
135+
if [ -f crates/pecos-python/README.md ]; then
136+
mv crates/pecos-python/README.md crates/pecos-python/README.md.bak
137+
echo "Moved conflicting README.md to README.md.bak"
138+
else
139+
echo "No conflicting README.md found"
140+
fi
141+
142+
- name: Build wheel
143+
uses: PyO3/maturin-action@v1
144+
with:
145+
command: build
146+
args: --release --out dist --interpreter python${{ matrix.python-version }}
147+
working-directory: python/pecos-rslib
148+
target: ${{ matrix.architecture == 'aarch64' && (matrix.os == 'macos-latest' && 'aarch64-apple-darwin' || 'aarch64-unknown-linux-gnu') || '' }}
149+
manylinux: auto
150+
151+
- name: Restore README.md
152+
if: always()
153+
run: |
154+
if [ -f crates/pecos-python/README.md.bak ]; then
155+
mv crates/pecos-python/README.md.bak crates/pecos-python/README.md
156+
echo "Restored README.md from backup"
157+
else
158+
echo "No README.md backup found"
159+
fi
160+
161+
- name: Test wheel
162+
if: matrix.architecture == 'x86_64'
163+
run: |
164+
pip install --force-reinstall --verbose python/pecos-rslib/dist/*.whl
165+
python -c 'import pecos_rslib; print(pecos_rslib.__version__)'
166+
167+
- name: Upload wheel
168+
uses: actions/upload-artifact@v4
169+
with:
170+
name: wheel-pecos-rslib-${{ matrix.os }}-${{ matrix.architecture }}-py${{ matrix.python-version }}
171+
path: python/pecos-rslib/dist/*.whl
172+
173+
build_sdist_quantum_pecos:
174+
needs: [check_pr_push, build_sdist_pecos_rslib, build_wheels_pecos_rslib]
175+
if: |
176+
always() &&
177+
(needs.check_pr_push.result == 'success' && needs.check_pr_push.outputs.run == 'true' || needs.check_pr_push.result == 'skipped') &&
178+
(github.event_name != 'pull_request' || github.event.pull_request.merged == true || github.event.action == 'opened' || github.event.action == 'synchronize')
179+
runs-on: ubuntu-latest
180+
steps:
181+
- uses: actions/checkout@v4
182+
with:
183+
ref: ${{ inputs.sha || github.sha }}
184+
185+
- name: Set up Python
186+
uses: actions/setup-python@v5
187+
with:
188+
python-version: ${{ env.PYTHON_VERSION }}
189+
190+
- name: Download pecos-rslib wheel
191+
uses: actions/download-artifact@v4
192+
with:
193+
name: wheel-pecos-rslib-ubuntu-latest-x86_64-py${{ env.PYTHON_VERSION }}
194+
path: ./pecos-rslib-wheel
195+
196+
- name: Install pecos-rslib
197+
run: pip install ./pecos-rslib-wheel/*.whl
198+
199+
- name: Install build dependencies
200+
run: |
201+
python -m pip install --upgrade pip
202+
pip install build
203+
204+
- name: Build quantum-pecos SDist
205+
run: |
206+
cd python/quantum-pecos
207+
python -m build --sdist --outdir dist
208+
209+
- name: Test quantum-pecos SDist
210+
run: |
211+
pip install python/quantum-pecos/dist/*.tar.gz
212+
python -c 'import pecos; print(pecos.__version__)'
213+
214+
- name: Upload quantum-pecos SDist
215+
uses: actions/upload-artifact@v4
216+
with:
217+
name: sdist-quantum-pecos
218+
path: python/quantum-pecos/dist/*.tar.gz
219+
220+
build_wheels_quantum_pecos:
221+
needs: [check_pr_push, build_wheels_pecos_rslib, build_sdist_quantum_pecos]
222+
if: |
223+
always() &&
224+
(needs.check_pr_push.result == 'success' && needs.check_pr_push.outputs.run == 'true' || needs.check_pr_push.result == 'skipped') &&
225+
(github.event_name != 'pull_request' || github.event.pull_request.merged == true || github.event.action == 'opened' || github.event.action == 'synchronize')
226+
runs-on: ubuntu-latest
227+
strategy:
228+
matrix:
229+
python-version: ['3.10', '3.11', '3.12', '3.13']
230+
231+
steps:
232+
- uses: actions/checkout@v4
233+
with:
234+
ref: ${{ inputs.sha || github.sha }}
235+
236+
- name: Set up Python ${{ matrix.python-version }}
237+
uses: actions/setup-python@v5
238+
with:
239+
python-version: ${{ matrix.python-version }}
240+
241+
- name: Download pecos-rslib wheel
242+
uses: actions/download-artifact@v4
243+
with:
244+
name: wheel-pecos-rslib-ubuntu-latest-x86_64-py${{ matrix.python-version }}
245+
path: ./pecos-rslib-wheel
246+
247+
- name: Install pecos-rslib
248+
run: pip install ./pecos-rslib-wheel/*.whl
249+
250+
- name: Install build dependencies
251+
run: |
252+
python -m pip install --upgrade pip
253+
pip install build
254+
255+
- name: Build quantum-pecos wheel
256+
run: |
257+
cd python/quantum-pecos
258+
python -m build --wheel --outdir dist
259+
260+
- name: Test quantum-pecos wheel
261+
run: |
262+
pip install python/quantum-pecos/dist/*.whl
263+
python -c 'import pecos; print(pecos.__version__)'
264+
265+
- name: Upload quantum-pecos wheel
266+
uses: actions/upload-artifact@v4
267+
with:
268+
name: wheel-quantum-pecos-py${{ matrix.python-version }}
269+
path: python/quantum-pecos/dist/*.whl

0 commit comments

Comments
 (0)