Skip to content

Commit 3e83452

Browse files
authored
build: Use a release profile that reduces binary size (#367)
* build: Use a release profile that reduces binary size * build: Don't build and publish Windows x86 wheels * add comment to the release profile
1 parent f1436e8 commit 3e83452

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

.github/workflows/release-python.yml

+33-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
strategy:
9595
matrix:
9696
python-version: ['3.8', '3.9', '3.10', '3.11']
97-
target: [x64, x86]
97+
target: [x64]
9898
steps:
9999
- uses: actions/checkout@v2
100100
- uses: actions/setup-python@v2
@@ -123,11 +123,42 @@ jobs:
123123
with:
124124
name: wheels
125125
path: dist
126+
sdist:
127+
runs-on: ubuntu-latest
128+
needs: is-python-release
129+
env:
130+
CXXFLAGS: "-std=c++11"
131+
steps:
132+
- uses: actions/checkout@v2
133+
- name: Install Rust
134+
uses: actions-rs/toolchain@v1
135+
with:
136+
toolchain: stable
137+
profile: minimal
138+
default: true
139+
- uses: actions/setup-python@v4
140+
with:
141+
python-version: '3.11'
142+
- name: Install protoc
143+
uses: arduino/setup-protoc@v1
144+
with:
145+
repo-token: ${{ secrets.GITHUB_TOKEN }}
146+
version: '3.20.1'
147+
- name: Build sdist
148+
uses: messense/maturin-action@v1
149+
with:
150+
command: sdist
151+
args: --manifest-path crates/python/Cargo.toml --out dist
152+
- name: Upload sdist
153+
uses: actions/upload-artifact@v3
154+
with:
155+
name: wheels
156+
path: dist
126157

127158
release:
128159
name: Release
129160
runs-on: ubuntu-latest
130-
needs: [ macos, linux, windows ]
161+
needs: [ macos, linux, windows, sdist ]
131162
steps:
132163
- uses: actions/download-artifact@v3
133164
- name: Publish to PyPi

Cargo.toml

+8
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,11 @@ pyo3-asyncio = { version = "0.19", features = ["tokio-runtime"] }
2929
pyo3-build-config = "0.19.2"
3030
rigetti-pyo3 = { version = "0.2.0", features = ["complex"] }
3131

32+
# The primary intent of these options is to reduce the binary size for Python wheels
33+
# since PyPi has limits on how much storage a project can use.
34+
# The LTO and codegen-units settings should have the added benefit of improving
35+
# performance. The only benefit of stripping symbols is reducing binary size.
36+
[profile.release]
37+
strip = true
38+
lto = true
39+
codegen-units = 1

0 commit comments

Comments
 (0)