Skip to content

Commit cc5193a

Browse files
committed
Add explicit build recipes & support for tkinter
1 parent ad0c8df commit cc5193a

14 files changed

Lines changed: 203 additions & 103 deletions

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ branches:
1212

1313
matrix:
1414
include:
15-
- env: ARCH=x86_64 OPENSSL=1.1.1c
15+
- env: ARCH=x86_64
1616

1717
install:
18-
- docker build -t python-${ARCH} --build-arg Arch=${ARCH} --build-arg OpenSLL=${OPENSSL} .travis
18+
- docker build -t python-${ARCH} --build-arg Arch=${ARCH} .travis
1919

2020
script:
2121
- docker run --cap-add SYS_ADMIN --device /dev/fuse --mount src=$PWD,dst=/work,type=bind python-${ARCH}

.travis/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ FROM ubuntu:trusty
22
LABEL maintainer="https://github.com/niess"
33

44
ARG Arch=x86_64
5-
ARG OpenSLL=1.1.1c
6-
ENV ARCH=${Arch} OPENSSL=${OpenSLL}
5+
ENV ARCH="${Arch}" OPENSSL="1.1.1c"
76

87
RUN apt update -y -qq && \
98
apt install --no-install-recommends -y -qq \
109
build-essential libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev \
1110
libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev \
12-
libexpat1-dev liblzma-dev libffi-dev libfuse2 wget && \
11+
libexpat1-dev liblzma-dev libffi-dev tk-dev libfuse2 wget && \
1312
rm -rf /var/lib/apt/lists/*
1413

1514
COPY . /work/.travis

.travis/script.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@ if [ -n "${OPENSSL}" ]; then
1212
fi
1313

1414

15-
DEBUG=true ./appimage/build-appimage.sh
15+
DEBUG=true ./appimage/build-plugin.sh
16+
DEBUG=true ./appimage/build-python.sh python2
17+
DEBUG=true ./appimage/build-python.sh python3
18+
DEBUG=true ./appimage/build-python.sh scipy
19+
1620
python3 -m tests
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pushd $BUILD_DIR
3131

3232

3333
# Build the AppImage
34-
appimagetool="appimagetool-$(arch).AppImage"
34+
appimagetool="appimagetool-${ARCH}.AppImage"
3535

3636
if [ ! -f "${appimagetool}" ]; then
3737
url="https://github.com/AppImage/AppImageKit/releases/download/continuous"
@@ -46,11 +46,11 @@ cp -r "${REPO_ROOT}/share" "AppDir"
4646

4747
pushd "AppDir"
4848
cp "${REPO_ROOT}/${EXEC_NAME}.sh" "."
49-
cp "${REPO_ROOT}/appimage/resources/"* "."
49+
cp "${REPO_ROOT}/appimage/resources/python.png" "${EXEC_NAME}.png"
50+
cp "${REPO_ROOT}/appimage/resources/plugin.desktop" "${EXEC_NAME}.desktop"
5051
ln -s "${EXEC_NAME}.png" ".DirIcon"
5152
popd
5253

5354
ARCH="${ARCH}" ./"${appimagetool}" AppDir
54-
ls -lh
5555
popd
56-
mv "${BUILD_DIR}/${EXEC_NAME}-${ARCH}.AppImage" "appimage"
56+
mv "${BUILD_DIR}/${EXEC_NAME}-${ARCH}.AppImage" "${REPO_ROOT}/appimage"

appimage/build-python.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
3+
if [ -z "$DEBUG" ] || [ "$DEBUG" -eq "0" ]; then
4+
set -e
5+
else
6+
set -ex
7+
fi
8+
9+
10+
REPO_ROOT=$(readlink -f $(dirname "$0")"/..")
11+
12+
13+
if [ -z "$1" ]; then
14+
echo "no recipe specified. Aborting..."
15+
exit 1
16+
fi
17+
if [ -f "$1" ]; then
18+
source "$1"
19+
filename=$(basename "$1")
20+
name="${filename%.*}"
21+
else
22+
source "${REPO_ROOT}/appimage/recipes/${1}.sh"
23+
name="$1"
24+
fi
25+
26+
export PYTHON_SOURCE="${PYTHON_SOURCE:-https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz}"
27+
export PIP_REQUIREMENTS
28+
29+
30+
ARCH="${ARCH:-$(arch)}"
31+
export ARCH="${ARCH}"
32+
33+
34+
# Setup a temporary work space
35+
if [ -z "${BUILD_DIR}" ]; then
36+
BUILD_DIR=$(mktemp -d)
37+
38+
_cleanup() {
39+
rm -rf "${BUILD_DIR}"
40+
}
41+
42+
trap _cleanup EXIT
43+
else
44+
BUILD_DIR=$(readlink -m "${BUILD_DIR}")
45+
mkdir -p "${BUILD_DIR}"
46+
fi
47+
48+
pushd $BUILD_DIR
49+
50+
51+
# Build the AppImage
52+
linuxdeploy="linuxdeploy-${ARCH}.AppImage"
53+
plugin="linuxdeploy-plugin-python-${ARCH}.AppImage"
54+
55+
if [ ! -f "${linuxdeploy}" ]; then
56+
url="https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous"
57+
wget --no-check-certificate -q "${url}/${linuxdeploy}"
58+
chmod u+x "${linuxdeploy}"
59+
fi
60+
61+
if [ ! -f "${REPO_ROOT}/appimage/${plugin}" ]; then
62+
${REPO_ROOT}/appimage/build-plugin.sh
63+
fi
64+
cp "${REPO_ROOT}/appimage/${plugin}" "."
65+
66+
exe="python${PYTHON_VERSION::3}"
67+
68+
cp "${REPO_ROOT}/appimage/resources/python.desktop" "${name}.desktop"
69+
sed -i "s|[{][{]exe[}][}]|${exe}|g" "${name}.desktop"
70+
sed -i "s|[{][{]name[}][}]|${name}|g" "${name}.desktop"
71+
72+
./"${linuxdeploy}" --appdir AppDir \
73+
--plugin python
74+
./"${linuxdeploy}" --appdir AppDir \
75+
-i "${REPO_ROOT}/appimage/resources/python.png" \
76+
-d "${name}.desktop" \
77+
-e "AppDir/usr/bin/.${exe}" \
78+
--custom-apprun "AppDir/usr/bin/${exe}" \
79+
--output "appimage"
80+
81+
popd
82+
mv "${BUILD_DIR}/${name}-${ARCH}.AppImage" "${REPO_ROOT}/appimage"

appimage/recipes/python2.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export PYTHON_VERSION="2.7.16"
2+
export PIP_REQUIREMENTS=

appimage/recipes/python3.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export PYTHON_VERSION="3.7.3"
2+
export PIP_REQUIREMENTS=

appimage/recipes/scipy.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export PYTHON_VERSION="3.7.3"
2+
export PIP_REQUIREMENTS="numpy scipy matplotlib"
3+
4+
export LD_LIBRARY_PATH="AppDir/usr/lib/python3.7/site-packages/numpy/.libs:${LD_LIBRARY_PATH}"
5+
export LD_LIBRARY_PATH="AppDir/usr/lib/python3.7/site-packages/matplotlib/.libs:${LD_LIBRARY_PATH}"
File renamed without changes.

appimage/resources/python.desktop

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[Desktop Entry]
2+
Categories=Science;Engineering;
3+
Type=Application
4+
Icon=python
5+
Exec={{exe}}
6+
Name={{name}}

0 commit comments

Comments
 (0)