Skip to content

Commit b21c735

Browse files
committed
Fix run.sh due to weird sysconfig change, hope nothing breaks
Fixes #11
1 parent 8581031 commit b21c735

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

run.sh

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -euo pipefail
23
C_MODULES=(uinput hiddrv sc_by_bt remotepad cemuhook)
34
C_VERSION_uinput=9
45
C_VERSION_hiddrv=5
@@ -7,27 +8,29 @@ C_VERSION_remotepad=1
78
C_VERSION_cemuhook=1
89

910
function rebuild_c_modules() {
10-
echo "lib$1.so is outdated or missing, building one"
11+
echo "lib${1}.so is outdated or missing, building one"
1112
echo "Please wait, this should be done only once."
1213
echo ""
13-
14-
# Next line generates string like 'lib.linux-x86_64-2.7', directory where libuinput.so was just generated
15-
LIB=$( python3 -c 'import platform ; print("lib.linux-%s-%s.%s" % ((platform.machine(),) + platform.python_version_tuple()[0:2]))' )
14+
# cpython-312-x86_64-linux-gnu
15+
# SOABI=$(python3 -c 'import sysconfig; print(sysconfig.get_config_var("SOABI").split("-")[0:2])');
16+
17+
# lib.linux-x86_64-cpython-312 - directory where libuinput.so was just generated
18+
LIB=$( python3 -c 'import platform; import sysconfig; soabi = sysconfig.get_config_var("SOABI").split("-")[0:2]; print(f"lib.linux-{platform.machine()}-{soabi[0]}-{soabi[1]}")' )
19+
# .cpython-312-x86_64-linux-gnu.so
1620
EXT_SUFFIX=$( python3 -c 'import sysconfig ; print(sysconfig.get_config_var("EXT_SUFFIX"))' )
17-
1821
for cmod in ${C_MODULES[@]}; do
19-
if [ -e build/$LIB/lib${cmod}${EXT_SUFFIX} ] ; then
20-
rm build/$LIB/lib${cmod}${EXT_SUFFIX} || exit 1
22+
if [[ -e build/${LIB}/lib${cmod}${EXT_SUFFIX} ]]; then
23+
rm "build/${LIB}/lib${cmod}${EXT_SUFFIX}"
2124
fi
2225
done
23-
24-
python3 setup.py build || exit 1
26+
27+
python3 setup.py build
2528
echo ""
26-
29+
2730
for cmod in ${C_MODULES[@]}; do
28-
if [ ! -e lib${cmod}.so ] ; then
29-
ln -s build/$LIB/lib${cmod}${EXT_SUFFIX} ./lib${cmod}.so || exit 1
30-
echo Symlinked ./lib${cmod}${EXT_SUFFIX} '->' build/$LIB/lib${cmod}.so
31+
if [[ ! -e lib${cmod}.so ]] ; then
32+
ln -s "build/${LIB}/lib${cmod}${EXT_SUFFIX}" "./lib${cmod}.so"
33+
echo "Symlinked ./lib${cmod}.so '->' build/${LIB}/lib${cmod}${EXT_SUFFIX}"
3134
fi
3235
done
3336
echo ""
@@ -39,17 +42,19 @@ cd "$(dirname "$0")"
3942

4043
# Check if c modules are compiled and actual
4144
for cmod in ${C_MODULES[@]}; do
42-
eval expected_version=\$C_VERSION_${cmod}
43-
reported_version=$(PYTHONPATH="." python3 -c 'import os, ctypes; lib=ctypes.CDLL("./'lib${cmod}'.so"); print(lib.'${cmod}'_module_version())')
44-
if [ x"$reported_version" != x"$expected_version" ] ; then
45-
rebuild_c_modules ${cmod}
45+
expected_version=\$C_VERSION_${cmod}
46+
if ! reported_version=$(PYTHONPATH="." python3 -c 'import os, ctypes; lib=ctypes.CDLL("./'lib${cmod}'.so"); print(lib.'${cmod}'_module_version())'); then
47+
echo "Failed to check module version for ${cmod}, this is normal"
48+
fi
49+
if [[ "$reported_version" != "${expected_version}" ]] ; then
50+
rebuild_c_modules "${cmod}"
4651
fi
4752
done
4853

4954
# Set PATH
5055
SCRIPTS="$(pwd)/scripts"
5156
export PATH="$SCRIPTS":"$PATH"
52-
export PYTHONPATH=".":"$PYTHONPATH"
57+
export PYTHONPATH=".":"${PYTHONPATH-}"
5358
export SCC_SHARED="$(pwd)"
5459

5560
# Execute

scripts/appimage-AppRun.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function dependency_check_failed() {
1212
# This checks 4 different ways to open error message in addition to
1313
# throwing it to screen directly
1414
>&2 cat /tmp/scc.depcheck.$$.txt
15-
15+
1616
[ -e /usr/bin/zenity ] && run_and_die /usr/bin/zenity --error --no-wrap --text "$(cat /tmp/scc.depcheck.$$.txt)"
1717
[ -e /usr/bin/yad ] && run_and_die /usr/bin/yad --error --text "$(cat /tmp/scc.depcheck.$$.txt)"
1818
[ -e /usr/bin/Xdialog ] && run_and_die /usr/bin/Xdialog --textbox "/tmp/scc.depcheck.$$.txt" 10 100
@@ -32,7 +32,7 @@ rm /tmp/scc.depcheck.$$.txt || true
3232

3333
# Pre-parse arguments
3434
ARG1=$1
35-
if [ "x$ARG1" == "x" ] ; then
35+
if [ "$ARG1" == "" ] ; then
3636
# Start gui if no arguments are passed
3737
ARG1="gui"
3838
else
@@ -44,4 +44,3 @@ export GDK_PIXBUF_MODULE_FILE=${APPDIR}/../$$-gdk-pixbuf-loaders.cache
4444
gdk-pixbuf-query-loaders >"$GDK_PIXBUF_MODULE_FILE"
4545
python3 ${APPDIR}/usr/bin/scc $ARG1 $@
4646
rm "$GDK_PIXBUF_MODULE_FILE" &>/dev/null
47-

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
packages = [
3838
# Required
3939
'scc', 'scc.drivers', 'scc.lib',
40-
# Usefull
40+
# Useful
4141
'scc.x11', 'scc.osd', 'scc.foreign',
4242
# GUI
4343
'scc.gui', 'scc.gui.ae', 'scc.gui.importexport', "scc.gui.creg"

0 commit comments

Comments
 (0)