Last active
April 30, 2024 22:36
-
-
Save somelinguist/a6cdfdf42d8ab15a163ee6496148a896 to your computer and use it in GitHub Desktop.
attempt flextools compatibility with flatpak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Be sure to set execute permission for the script. | |
# Configure how to call python here: | |
CALLPYTHON=python | |
# Configure the prefix to the path where FieldWorks is installed. | |
# /usr is the default for installing via the apt package manager on Ubuntu: | |
# /app is the default for flatpak | |
prefix=/app | |
# In order to function correctly on Linux, | |
# we need to source a shell script (environ), which | |
# erases the path and several other environment variables. | |
# This function is called after the variables needed by FLEx | |
# are sourced in order to reset any variables needed by | |
# the caller which were erased. | |
resetenviron() { | |
echo "Resetting environment" | |
# Reset pyenv variables | |
export PATH="$HOME/.pyenv/bin:$PATH" | |
# Try setting path to libc.so.6, etc needed by python installed by pyenv (2.34), | |
# otherwise flatpack only finds its internal version of libc (2.30) | |
# However, after setting this, it crashes with "Segmentation fault (core dumped)" | |
export LD_LIBRARY_PATH="/var/run/host/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH" | |
eval "$(pyenv init --path)" | |
eval "$(pyenv virtualenv-init -)" | |
} | |
# The following is adapted from the run-app shell script | |
# used to run an installed version of FLEx on Linux. | |
scriptdir=$(/bin/pwd) | |
lib=$prefix/lib/fieldworks | |
share=$prefix/share/fieldworks | |
sharedWsRoot=/var/lib/fieldworks | |
sharedWs=$sharedWsRoot/SIL/WritingSystemStore | |
# "$share/setup-user" | |
cd "$lib"; RUNMODE="INSTALLED" . environ; | |
cd $scriptdir | |
# reset environment as defined above | |
resetenviron | |
exec $CALLPYTHON ../scripts/RunFlexTools.py DEBUG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See this issue with PyCharm for related bugs when trying to use pyenv with its flatpak version: flathub/com.jetbrains.PyCharm-Community#14