Skip to content

Commit

Permalink
ci/appimage: fix python version issue
Browse files Browse the repository at this point in the history
 - link and bundle the same python version

Signed-off-by: Bindea Cristian <[email protected]>
  • Loading branch information
bindea-cristian committed May 29, 2024
1 parent d68f307 commit 30b15a7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
29 changes: 19 additions & 10 deletions CI/appimage/ubuntu_appimage_process.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#!/bin/bash
set -ex

## Set STAGING
USE_STAGING=ON
##

if [ "$CI_SCRIPT" == "ON" ]
then
SRC_DIR=$GITHUB_WORKSPACE
SRC_DIR=/home/runner/scopy
git config --global --add safe.directory '*'
USE_STAGING=OFF
else
SRC_DIR=$(git rev-parse --show-toplevel)
fi

export APPIMAGE=1

## Set STAGING
USE_STAGING=$1
[ -z $USE_STAGING ] && USE_STAGING=ON

LIBIIO_VERSION=v0.25
LIBAD9361_BRANCH=main
Expand All @@ -28,6 +30,9 @@ QWT_BRANCH=qwt-multiaxes-updated
LIBTINYIIOD_BRANCH=master
IIOEMU_BRANCH=master

# default python version used in CI scripts, can be changed to match locally installed python
PYTHON_VERSION=python3.8

QT_LOCATION=/opt/Qt/5.15.2/gcc_64

STAGING_AREA=$SRC_DIR/CI/appimage/staging
Expand Down Expand Up @@ -138,7 +143,7 @@ install_packages() {
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install \
python3 python-dev python3-pip libpython3-all-dev python3-numpy \
$PYTHON_VERSION-full python3-pip lib$PYTHON_VERSION-dev python3-numpy \
keyboard-configuration vim git wget unzip\
g++ build-essential cmake curl autogen autoconf autoconf-archive pkg-config flex bison swig \
subversion mesa-common-dev graphviz xserver-xorg gettext texinfo mm-common doxygen \
Expand Down Expand Up @@ -271,10 +276,11 @@ build_libsigrokdecode() {
if [ "$USE_STAGING" == "ON" ]
then
./configure --prefix $STAGING_AREA_DEPS
LD_RUN_PATH=$STAGING_AREA_DEPS/lib make $JOBS
else
./configure
make $JOBS
fi
make $JOBS
if [ "$USE_STAGING" == "ON" ]; then make install; else sudo make install; fi
popd
}
Expand Down Expand Up @@ -302,7 +308,8 @@ build_scopy() {
echo "### Building scopy"
pushd $SRC_DIR
CURRENT_BUILD_CMAKE_OPTS="\
-DCLONE_IIO_EMU=OFF
-DCLONE_IIO_EMU=OFF \
-DPYTOHN_EXECUTABLE=/usr/bin/$PYTHON_VERSION
"
build_with_cmake OFF
popd
Expand All @@ -326,23 +333,25 @@ create_appdir(){
pushd ${STAGING_AREA}
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$STAGING_AREA_DEPS/lib:$QT_LOCATION/lib
export PATH=$QT_LOCATION:$PATH
sudo ldconfig

rm -rf $APP_DIR
export QMAKE=$QMAKE_BIN # this is needed for deploy-plugin-qt.AppImage
# inside a docker image you can't run an appimage executable without privileges
# so the solution is to extract the appimage first and only then to run it
export APPIMAGE_EXTRACT_AND_RUN=1
${STAGING_AREA}/linuxdeploy-x86_64.AppImage \
--appdir $APP_DIR\
--appdir $APP_DIR \
--executable $SRC_DIR/build/scopy \
--custom-apprun $SRC_DIR/CI/appimage/AppRun \
--desktop-file $SRC_DIR/CI/appimage/scopy.desktop \
--icon-file $SRC_DIR/resources/Scopy.png \
--plugin qt

cp $STAGING_AREA/iio-emu/build/iio-emu $APP_DIR/usr/bin
python_path=$(python3 -c "import os as _; print(_.__file__)")
python_path=${python_path%/*}
# search for the python version linked by cmake and copy inside the appimage the same version
FOUND_PYTHON_VERSION=$(grep 'PYTHON_VERSION' $SRC_DIR/build/CMakeCache.txt | awk -F= '{print $2}' | grep -o 'python[0-9]\+\.[0-9]\+')
python_path=/usr/lib/$FOUND_PYTHON_VERSION
cp -r $python_path $APP_DIR/usr/lib
cp -r $QT_LOCATION/plugins $APP_DIR/usr

Expand Down
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ cmake_minimum_required(VERSION 3.5)
project(scopy LANGUAGES C CXX VERSION 1.4.1)

set(Python_ADDITIONAL_VERSIONS 3)
FIND_PACKAGE(PythonInterp REQUIRED)
set(PYTHON_VERSION python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})

if(PYTHON_EXECUTABLE)
message(STATUS "Using custom Python EXECUTABLE: ${PYTHON_EXECUTABLE}")
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
else()
message(STATUS "Using default Python EXECUTABLE")
endif()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
message (STATUS "Found Python " ${Python3_VERSION} " at " ${Python3_EXECUTABLE} " and " ${Python3_LIBRARY})
set(PYTHON_VERSION python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR} CACHE STRING "PYTHON_USED")

function(dump_cmake_variables)
get_cmake_property(_variableNames VARIABLES)
Expand Down

0 comments on commit 30b15a7

Please sign in to comment.