Skip to content

Commit a65347c

Browse files
committed
Merge branch 'python3' into feature/daemon-version
2 parents 91aad05 + a96b9de commit a65347c

Some content is hidden

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

78 files changed

+4918
-4035
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# In case we were about to copy dist files from existing local builds, remove them
2+
dist

.github/workflows/appimage.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,15 @@ jobs:
8888
printenv | grep ^APPIMAGE_ >>"${GITHUB_ENV}"
8989
9090
- name: Build AppImage
91-
uses: AppImageCrafters/[email protected]
91+
uses: git-developer/[email protected]
9292
with:
93-
recipe: "${{ matrix.base.recipe }}"
93+
command: ${{
94+
format('sh -c "set -eu; {0}; {1}; {2}; appimage-builder --recipe {3}"',
95+
'pip install --upgrade setuptools packaging packaging-legacy',
96+
'pip install --extra-index-url https://lief.s3-website.fr-par.scw.cloud/latest \"lief>=0.16.0.dev0\"',
97+
'find /usr/local/lib -name package.py | while read -r file; do sed -i -e \"s/^from.packaging/&_legacy/\" \"${file}\"; done',
98+
matrix.base.recipe)
99+
}}
94100

95101
- name: Upload artifacts
96102
uses: actions/upload-artifact@v4
@@ -160,7 +166,6 @@ jobs:
160166
BASE_CODENAME=${{ matrix.base.codename }}
161167
162168
release:
163-
if: startsWith(github.ref, 'refs/tags/')
164169
runs-on: ubuntu-latest
165170

166171
needs:
@@ -187,4 +192,5 @@ jobs:
187192
- name: Upload artifacts to GitHub release
188193
uses: softprops/action-gh-release@v2
189194
with:
195+
draft: ${{ !startsWith(github.ref, 'refs/tags/') }}
190196
files: assets/*

.github/workflows/scc-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
with:
2323
python-version: '3.11'
2424
# Install dependencies
25-
- run: pip install pytest vdf libusb1 ioctl-opt
25+
- run: pip install ioctl-opt libusb1 toml vdf pytest
2626
# Build
2727
- run: python setup.py build
2828
# Test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
test.*
88
test[0-9].*
99
build/
10+
build-output/
1011
venv/
1112
.atomignore
1213
commit*

AppImageBuilder.debian-bullseye.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ AppDir:
7676
pip install --target "${TARGET_APPDIR}/usr/lib/python3/dist-packages/" vdf
7777
fi
7878
79+
# python3-usb1 expects 'libusb-1.0.so', see https://github.com/vpelletier/python-libusb1/issues/78
80+
find "${TARGET_APPDIR}" -name 'libusb-1.0.so.[0-9]' | while read -r file; do
81+
path="$(dirname "${file}")"
82+
link="${file%.[0-9]}"
83+
[ -e "${link}" ] || ln -sr "${file}" "${link}"
84+
done
85+
7986
apt:
8087
arch:
8188
- "{{APPIMAGE_APT_ARCH}}"
@@ -93,6 +100,7 @@ AppDir:
93100
- libbluetooth3
94101
- libgtk-3-0
95102
- librsvg2-common
103+
- python-is-python3
96104
- python3-evdev
97105
- python3-gi-cairo
98106
- python3-pylibacl
@@ -104,8 +112,6 @@ AppDir:
104112

105113
exclude:
106114
# coreutils
107-
- libacl* # filesystem
108-
- libattr* # filesystem
109115
- libgmp* # arithmetics
110116

111117
# gir1.2-rsvg-2.0

AppImageBuilder.debian.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,21 @@ AppDir:
7171
printf '[Settings]\ngtk-icon-theme-name = %s\n' "${theme}" >"${xdg_settings}"
7272
fi
7373
74+
# python3-usb1 expects 'libusb-1.0.so', see https://github.com/vpelletier/python-libusb1/issues/78
75+
find "${TARGET_APPDIR}" -name 'libusb-1.0.so.[0-9]' | while read -r file; do
76+
path="$(dirname "${file}")"
77+
link="${file%.[0-9]}"
78+
[ -e "${link}" ] || ln -sr "${file}" "${link}"
79+
done
80+
81+
# Trixie expects libpixbufloader libs with a dash suffix, not underscore
82+
# see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1082676
83+
find "${TARGET_APPDIR}" -type f -name 'libpixbufloader_*' | while read -r file; do
84+
path="$(dirname "${file}")"
85+
link="${path}/$(echo "$(basename "${file}")" | tr _ -)"
86+
[ -e "${link}" ] || ln -sr "${file}" "${link}"
87+
done
88+
7489
after_runtime: |
7590
set -eu
7691
@@ -97,6 +112,7 @@ AppDir:
97112
- libbluetooth3
98113
- libgtk-3-0
99114
- librsvg2-common
115+
- python-is-python3
100116
- python3-evdev
101117
- python3-gi-cairo
102118
- python3-pylibacl
@@ -109,8 +125,6 @@ AppDir:
109125

110126
exclude:
111127
# coreutils
112-
- libacl* # filesystem
113-
- libattr* # filesystem
114128
- libgmp* # arithmetics
115129

116130
# gir1.2-rsvg-2.0
@@ -134,7 +148,6 @@ AppDir:
134148
- libfribidi* # i18n
135149
- libgtk-3-common # gui
136150
- liblz* # codec
137-
- libmount* # filesystem
138151
- libtiff* # codec
139152
- libwebp* # codec
140153

@@ -156,7 +169,6 @@ AppDir:
156169
- libgprofng* # development
157170
- libjansson* # codec
158171
- libsframe* # development
159-
- libcloudproviders* # networking
160172
- netbase # network
161173
- tzdata # date/time
162174

AppImageBuilder.test.Dockerfile

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,6 @@ RUN <<EOR
1616
return 1
1717
}
1818

19-
handle_failure() {
20-
return_code="${1}"
21-
file="${2}"
22-
if [ "${return_code}" = 139 ] && echo "${file}" | grep -q -P -- '-(noble|trixie|bookworm)-'; then
23-
log "Ignoring failure ${return_code} for ${file}" \
24-
"which is currently known to cause a segmentation fault"
25-
else
26-
return "${return_code}"
27-
fi
28-
}
29-
3019
prepare() {
3120
if command -v apt-get >/dev/null; then
3221
apt-get update && apt-get install -y --no-install-recommends libx11-6
@@ -43,14 +32,19 @@ RUN <<EOR
4332
cancel "Error: No AppImage file found."
4433
fi
4534
prepare
35+
config_path="${HOME}/.config/scc"
36+
mkdir -p "${config_path}"
37+
echo '{}' >"${config_path}/config.json"
38+
4639
echo "${files}" | while read -r file; do
47-
log "${file}"
40+
log "Testing ${file}"
4841
chmod +x "${file}"
4942
rm -rf squashfs-root/
5043
"${file}" --appimage-extract >/dev/null
5144
(
5245
cd squashfs-root/runtime/compat
53-
{ ../../AppRun dependency-check && ../../AppRun daemon --help; } || handle_failure "$?" "${file}"
46+
../../AppRun dependency-check
47+
../../AppRun daemon --help
5448
)
5549
rm -f "${file}"
5650
done

AppImageBuilder.ubuntu-focal.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ AppDir:
7676
printf '[Settings]\ngtk-icon-theme-name = %s\n' "${theme}" >"${xdg_settings}"
7777
fi
7878
79+
# python3-usb1 expects 'libusb-1.0.so', see https://github.com/vpelletier/python-libusb1/issues/78
80+
find "${TARGET_APPDIR}" -name 'libusb-1.0.so.[0-9]' | while read -r file; do
81+
path="$(dirname "${file}")"
82+
link="${file%.[0-9]}"
83+
[ -e "${link}" ] || ln -sr "${file}" "${link}"
84+
done
85+
7986
apt:
8087
arch:
8188
- "{{APPIMAGE_APT_ARCH}}"
@@ -97,6 +104,7 @@ AppDir:
97104
- libbluetooth3
98105
- libgtk-3-0
99106
- librsvg2-common
107+
- python-is-python3
100108
- python3-evdev
101109
- python3-gi-cairo
102110
- python3-libusb1
@@ -108,8 +116,6 @@ AppDir:
108116

109117
exclude:
110118
# coreutils
111-
- libacl* # filesystem
112-
- libattr* # filesystem
113119
- libgmp* # arithmetics
114120

115121
# gir1.2-rsvg-2.0

AppImageBuilder.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ AppDir:
7171
printf '[Settings]\ngtk-icon-theme-name = %s\n' "${theme}" >"${xdg_settings}"
7272
fi
7373
74+
# python3-usb1 expects 'libusb-1.0.so', see https://github.com/vpelletier/python-libusb1/issues/78
75+
find "${TARGET_APPDIR}" -name 'libusb-1.0.so.[0-9]' | while read -r file; do
76+
path="$(dirname "${file}")"
77+
link="${file%.[0-9]}"
78+
[ -e "${link}" ] || ln -sr "${file}" "${link}"
79+
done
80+
7481
after_runtime: |
7582
set -eu
7683
@@ -99,6 +106,7 @@ AppDir:
99106
- libbluetooth3
100107
- libgtk-3-0
101108
- librsvg2-common
109+
- python-is-python3
102110
- python3-evdev
103111
- python3-gi-cairo
104112
- python3-pylibacl
@@ -111,8 +119,6 @@ AppDir:
111119

112120
exclude:
113121
# coreutils
114-
- libacl* # filesystem
115-
- libattr* # filesystem
116122
- libgmp* # arithmetics
117123

118124
# gir1.2-rsvg-2.0
@@ -136,7 +142,6 @@ AppDir:
136142
- libfribidi* # i18n
137143
- libgtk-3-common # gui
138144
- liblz* # codec
139-
- libmount* # filesystem
140145
- libtiff* # codec
141146
- libwebp* # codec
142147

Dockerfile

Lines changed: 75 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,73 +5,97 @@ FROM $BASE_OS:$BASE_CODENAME AS build-stage
55

66
# Download build dependencies
77
RUN <<EOR
8-
set -eu
8+
set -eu
99

10-
apt-get update
11-
apt-get install -y --no-install-recommends \
12-
gcc \
13-
librsvg2-bin \
14-
linux-headers-generic \
15-
python3-dev \
16-
python3-setuptools \
17-
python-is-python3
18-
apt-get clean && rm -rf /var/lib/apt/lists/*
10+
# Workaround for outstanding fix of https://bugs.launchpad.net/ubuntu/+source/python-build/+bug/1992108
11+
if grep -q ^UBUNTU_CODENAME=jammy /etc/os-release; then
12+
echo >>/etc/apt/sources.list.d/jammy-proposed.list 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-proposed universe'
13+
echo >>/etc/apt/sources.list.d/jammy-proposed.list 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-proposed universe'
14+
fi
15+
16+
apt-get update
17+
apt-get install -y --no-install-recommends \
18+
gcc \
19+
librsvg2-bin \
20+
linux-headers-generic \
21+
python3-dev \
22+
python3-setuptools \
23+
python3-venv \
24+
python-is-python3
25+
26+
# Workaround for Focal lacking an apt package for python3-build
27+
dep=build
28+
package="python3-${dep}"
29+
if apt-cache search --names-only "^${package}$" | grep -q .; then
30+
apt-get install -y --no-install-recommends "${package}"
31+
else
32+
apt-get install -y --no-install-recommends python3-pip
33+
pip install "${dep}"
34+
fi
35+
36+
apt-get clean && rm -rf /var/lib/apt/lists/*
1937
EOR
2038
# Prepare working directory and target
2139
COPY . /work
2240
WORKDIR /work
23-
ARG TARGET=/build/usr
41+
ARG TARGET=/build
2442
ARG DAEMON_VERSION
2543
ARG GIT_DESCRIPTION
2644

2745
# Build and install
2846
RUN <<EOR
29-
set -eu
47+
set -eu
48+
49+
##
50+
# Converts the output of `git describe` to a valid python version (PEP 440),
51+
# e.g. `v0.4.9.2` to `0.4.9.2` or `ver0.4.8.11-3-123-g030686f` to `0.4.8.11.3.123.dev3172463`
52+
##
53+
convert_git_description_to_python_version() {
54+
description="${1}"
55+
hash="${description##*-g}"
56+
version="$(printf %s "${description%-g*}" | tr -c -s [0-9.] .)"
57+
version="${version#.}"
58+
version="${version%.}"
59+
if [ "${hash}" != "${description}" ]; then
60+
version="${version}.dev$(printf %d "0x${hash}")"
61+
fi
62+
printf '%s\n' "${version}"
63+
}
64+
if [ -z "${DAEMON_VERSION-}" ] && [ "${GIT_DESCRIPTION-}" ]; then
65+
DAEMON_VERSION="$(convert_git_description_to_python_version "${GIT_DESCRIPTION}")"
66+
fi
67+
if [ "${DAEMON_VERSION-}" ]; then
68+
sed -i -E "s/^ *DAEMON_VERSION *= *.+/DAEMON_VERSION = \"${DAEMON_VERSION}\"/" scc/constants.py
69+
fi
3070

31-
##
32-
# Converts the output of `git describe` to a valid python version (PEP 440),
33-
# e.g. `v0.4.9.2` to `0.4.9.2` or `ver0.4.8.11-3-123-g030686f` to `0.4.8.11.3.123.dev3172463`
34-
##
35-
convert_git_description_to_python_version() {
36-
description="${1}"
37-
hash="${description##*-g}"
38-
version="$(printf %s "${description%-g*}" | tr -c -s [0-9.] .)"
39-
version="${version#.}"
40-
version="${version%.}"
41-
if [ "${hash}" != "${description}" ]; then
42-
version="${version}.dev$(printf %d "0x${hash}")"
43-
fi
44-
printf '%s\n' "${version}"
45-
}
46-
if [ -z "${DAEMON_VERSION-}" ] && [ "${GIT_DESCRIPTION-}" ]; then
47-
DAEMON_VERSION="$(convert_git_description_to_python_version "${GIT_DESCRIPTION}")"
48-
fi
49-
if [ "${DAEMON_VERSION-}" ]; then
50-
sed -i -E "s/^ *DAEMON_VERSION *= *.+/DAEMON_VERSION = \"${DAEMON_VERSION}\"/" scc/constants.py
51-
fi
71+
python -m build --wheel
72+
python -m venv .env
73+
.env/bin/activate
74+
pip install --prefix "${TARGET}/usr" dist/*.whl
75+
# fix shebangs of scripts from '#!/work/.env/bin/python'
76+
find "${TARGET}/usr/bin" -type f | xargs sed -i 's:work/.env:usr:'
5277

53-
python setup.py build --executable "/usr/bin/env python3"
54-
python setup.py install --single-version-externally-managed --home "${TARGET}" --record /dev/null
78+
# Provide input-event-codes.h as fallback for runtime systems without linux headers
79+
cp -a \
80+
"$(find /usr -type f -name input-event-codes.h -print -quit)" \
81+
"$(find "${TARGET}" -type f -name uinput.py -printf '%h\n' -quit)"
5582

56-
# Provide input-event-codes.h as fallback for runtime systems without linux headers
57-
cp -a \
58-
"$(find /usr -type f -name input-event-codes.h -print -quit)" \
59-
"$(find "${TARGET}" -type f -name uinput.py -printf '%h\n' -quit)"
83+
# Create short name symlinks for static libraries
84+
suffix=".cpython-*-$(uname -m)-linux-gnu.so"
85+
find "${TARGET}" -type f -path "*/site-packages/*${suffix}" \
86+
| while read -r path; do ln -sfr "${path}" "${path%${suffix}}.so"; done
6087

61-
# Create short name symlinks for static libraries
62-
suffix=".cpython-*-$(uname -m)-linux-gnu.so"
63-
find "${TARGET}" -type f -path "*/site-packages/*${suffix}" \
64-
| while read -r path; do ln -sfr "${path}" "${path%${suffix}}.so"; done
88+
share="${TARGET}/usr/share"
6589

66-
# Put AppStream metadata to required location according to https://wiki.debian.org/AppStream/Guidelines
67-
metainfo=/build/usr/share/metainfo
68-
mkdir -p "${metainfo}"
69-
cp -a scripts/sc-controller.appdata.xml "${metainfo}"
90+
# Put AppStream metadata to required location according to https://wiki.debian.org/AppStream/Guidelines
91+
metainfo="${share}/metainfo"
92+
mkdir -p "${metainfo}"
93+
cp -a scripts/sc-controller.appdata.xml "${metainfo}"
7094

71-
# Convert icon to png format (required for icons in .desktop file)
72-
iconpath="${TARGET}/share/icons/hicolor/512x512/apps"
73-
mkdir -p "${iconpath}"
74-
rsvg-convert --background-color none -o "${iconpath}/sc-controller.png" images/sc-controller.svg
95+
# Convert icon to png format (required for icons in .desktop file)
96+
iconpath="${share}/icons/hicolor/512x512/apps"
97+
mkdir -p "${iconpath}"
98+
rsvg-convert --background-color none -o "${iconpath}/sc-controller.png" images/sc-controller.svg
7599
EOR
76100

77101
# Store build metadata

0 commit comments

Comments
 (0)