Skip to content

Commit 92e93b4

Browse files
authored
snap: ensure cryptography builds correctly on all architectures (#1091)
1 parent 0bf3cc0 commit 92e93b4

File tree

2 files changed

+48
-9
lines changed

2 files changed

+48
-9
lines changed

.github/workflows/tests.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,28 @@ jobs:
7171
name: snap
7272
path: ${{ steps.snapcraft.outputs.snap }}
7373

74+
# Commented out until we can provide the necessary launchpad credentials.
75+
# snap-remote-build:
76+
# runs-on: ubuntu-latest
77+
# steps:
78+
# - name: Start installing snapcraft
79+
# run: echo SNAP_JOB=$(sudo snap install --classic --no-wait snapcraft) >> $GITHUB_OUTPUT
80+
# id: install
81+
# - name: Checkout code
82+
# uses: actions/checkout@v3
83+
# with:
84+
# fetch-depth: 0
85+
# - name: Remote-build snap
86+
# id: snapcraft
87+
# run: |
88+
# sudo snap watch ${{ steps.install.outputs.SNAP_JOB }}
89+
# snapcraft remote-build --launchpad-accept-public-upload
90+
# - name: Upload snap artifacts
91+
# uses: actions/upload-artifact@v3
92+
# with:
93+
# name: snap
94+
# path: ./*.snap
95+
7496
snap-tests:
7597
needs: [snap-build]
7698
strategy:

snap/snapcraft.yaml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,31 @@ grade: stable
7171
confinement: classic
7272

7373
parts:
74+
# The cryptography library (indirect dependency via craft-store) requires rust, but only ships wheels for amd64 and arm64.
75+
# As of cryptography 39, it requires rust v1.48.0 or newer, which is available from focal-updates.
76+
# This part builds the wheel for cryptography.
77+
cryptography-deps:
78+
plugin: dump
79+
source: .
80+
build-packages:
81+
- cargo
82+
- rustc
83+
- pkg-config
84+
- python3.8-dev
85+
- libpython3.8-dev
86+
- libssl-dev
87+
- libffi-dev
88+
- python3-wheel
89+
- python3-pip
90+
- python3-setuptools-scm
91+
override-build: |
92+
# Dirty workaround - builds the cryptography wheel for later installation.
93+
# This must be exactly the version referenced in requirements.txt, so this is fragile.
94+
pip wheel $(grep '^cryptography[<=>]' requirements.txt)
95+
7496
# Classic core20 snaps require staged python.
7597
python3:
98+
after: [cryptography-deps]
7699
plugin: nil
77100
build-packages:
78101
- python3-dev
@@ -92,16 +115,8 @@ parts:
92115
snapcraftctl build
93116
install -D -m 0755 $SNAPCRAFT_PROJECT_DIR/snap/local/sitecustomize.py $SNAPCRAFT_PART_INSTALL/usr/lib/python3.8/sitecustomize.py
94117
95-
# The cryptography library (indirect dependency via craft-store) requires rust, but only ships wheels for amd64 and arm64.
96-
# As of cryptography 39, it requires rust v1.48.0 or newer, which is available from focal-updates.
97-
rust-deps:
98-
plugin: nil
99-
build-packages:
100-
- cargo
101-
- rustc
102-
103118
charmcraft:
104-
after: [python3, rust-deps]
119+
after: [python3, cryptography-deps]
105120
source: .
106121
plugin: python
107122
requirements:
@@ -125,6 +140,8 @@ parts:
125140
override-pull: |
126141
# do the usual pull stuff
127142
snapcraftctl pull
143+
# Ensure we don't have a dubious ownership error from git with a remote build.
144+
git config --global --add safe.directory $SNAPCRAFT_PART_SRC
128145
# set the version
129146
version="$(python3 setup.py --version)"
130147
snapcraftctl set-version "$version"

0 commit comments

Comments
 (0)