This repository has been archived by the owner on Jun 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gtk3-venv.sh
179 lines (160 loc) · 5.37 KB
/
gtk3-venv.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/usr/bin/env bash
# script for pyenv installation of pygtk3 in ubuntu 12.04
# Adapted from https://gist.github.com/mehcode/6172694
system_package_installed() {
if ! dpkg -l | grep -q $1; then
sudo apt-get install $1
fi
}
python_module_installed() {
local mod=$1
if ! python <<- EOF
try:
import $mod
raise SystemExit(0)
except ImportError:
raise SystemExit(-1)
EOF
then
return 1
fi
}
set -e
PYGTK_PREFIX="${VIRT_ROOT}"
# NOTE: "pyenv prefix" can return multiple.
PYGTK_PREFIX=${PYGTK_PREFIX%%:*}
echo -e "\E[1m * Using prefix: $PYGTK_PREFIX\E[0m"
export PATH="$PYGTK_PREFIX/bin:$PATH"
export PKG_CONFIG_PATH="$PYGTK_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"
system_package_installed libcairo2-dev
system_package_installed libglib2.0-dev
system_package_installed libgirepository1.0-dev
# Setup variables.
CACHE="${MAIN_DIR}/install-pygtk-$$"
echo -e "\E[1m * Building in $CACHE\E[0m"
PYTHON_VERSION="$(python -c 'import sys; print(sys.version_info[0])')"
if [[ "$PYTHON_VERSION" == 2 ]]; then
echo "[USING: python2]"
PYCAIRO_BASENAME=py2cairo
else
echo "[USING: python3]"
PYCAIRO_BASENAME=pycairo
fi
# Make temp directory.
mkdir -p $CACHE
# Test for pycairo/py2cairo.
echo -e "\E[1m * Checking for cairo...\E[0m"
if ! python_module_installed cairo; then
echo -e "\E[1m * Installing ${PYCAIRO_BASENAME}...\E[0m"
# Fetch, build, and install pycairo/py2cairo.
( cd $CACHE
if [[ $PYCAIRO_BASENAME == py2cairo ]]; then
curl 'http://cairographics.org/releases/py2cairo-1.10.0.tar.bz2' > "py2cairo.tar.bz2"
tar -xvf py2cairo.tar.bz2
( cd py2cairo*
touch ChangeLog
autoreconf -ivf
./configure --prefix=$PYGTK_PREFIX
make
make install
)
else
git clone --depth=10 git://git.cairographics.org/git/${PYCAIRO_BASENAME}
( cd ${PYCAIRO_BASENAME}*
python3 setup.py install
)
fi
)
fi
# # Test for gobject-introspection
# echo -e "\E[1m * Checking for cairo...\E[0m"
# if ! python_module_installed cairo; then
# echo -e "\E[1m * Installing ${PYCAIRO_BASENAME}...\E[0m"
# # Fetch, build, and install pycairo/py2cairo.
# ( cd $CACHE
# if [[ $PYCAIRO_BASENAME == py2cairo ]]; then
# curl 'http://cairographics.org/releases/py2cairo-1.10.0.tar.bz2' > "py2cairo.tar.bz2"
# tar -xvf py2cairo.tar.bz2
# ( cd py2cairo*
# touch ChangeLog
# autoreconf -ivf
# ./configure --prefix=$PYGTK_PREFIX
# make
# make install
# )
# else
# git clone --depth=10 git://git.cairographics.org/git/${PYCAIRO_BASENAME}
# ( cd ${PYCAIRO_BASENAME}*
# python3 setup.py install
# )
# fi
# )
# fi
# (cd "${JHBUILD}" &&
# git clone https://github.com/GNOME/gobject-introspection.git &&
# cd gobject-introspection && git checkout 1.46.0 &&
# jhbuild buildone -n gobject-introspection)
#
# - (cd "${JHBUILD}" &&
# git clone --depth 1 https://github.com/GNOME/glib.git &&
# jhbuild buildone -n glib)
# - curl -L "http://ftp.acc.umu.se/pub/gnome/sources/glib/2.32/glib-2.32.4.tar.xz" > glib-2.32.4.tar.xz
# - tar xf glib-2.32.4.tar.xz
# - cd glib-2.32.4
# - ./configure --prefix=$VIRT_ROOT > /dev/null
# - make > /dev/null
# - make install > /dev/null
# - cd $MAIN_DIR
# - sudo apt-get install -qq libtheora-dev libogg-dev libvorbis-dev libasound2-dev libjack-dev
# source: https://github.com/apache/celix/blob/master/Dockerfile.Android
# source: http://www.linuxfromscratch.org/blfs/view/svn/general/libffi.html
echo -e "\E[1m * Installing libffi...\E[0m"
curl -L -O ftp://sourceware.org/pub/libffi/libffi-3.2.1.tar.gz && \
tar -xvzf libffi-3.2.1.tar.gz && \
cd libffi-3.2.1 && \
sed -e '/^includesdir/ s/$(libdir).*$/$(includedir)/' \
-i include/Makefile.in &&
sed -e '/^includedir/ s/=.*$/=@includedir@/' \
-e 's/^Cflags: -I${includedir}/Cflags:/' \
-i libffi.pc.in &&
./configure --prefix=$PYGTK_PREFIX --disable-static &&
make && \
sudo make install && \
# ldconfig
echo -e "\E[1m * Installing pcre...\E[0m"
( cd $CACHE
curl --remote-name ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
tar -xvzf pcre-8.39.tar.gz
cd pcre-8.39
./configure --prefix=$PYGTK_PREFIX --enable-utf
make && sudo make install
# ldconfig
)
echo -e "\E[1m * Installing glib...\E[0m"
# Fetch, build, and install glib. v3.18.2
( cd $CACHE
git clone --depth=10 git://git.gnome.org/glib
( cd glib*
# git reset --hard 7dc01c05fc07433161be74509b985647f6bedd19
./autogen.sh --prefix=$PYGTK_PREFIX
make
make install
)
)
# Test for gobject.
echo -e "\E[1m * Checking for gobject...\E[0m"
if ! python_module_installed gi; then
echo -e "\E[1m * Installing gobject...\E[0m"
# Fetch, build, and install gobject. v3.18.2
( cd $CACHE
git clone --depth=10 git://git.gnome.org/pygobject
( cd pygobject*
git reset --hard 7dc01c05fc07433161be74509b985647f6bedd19
# Fix include (reported at https://bugzilla.gnome.org/show_bug.cgi?id=746742).
sed -i 's~^#include <pycairo/py3cairo.h>~#include <py3cairo.h>~' gi/pygi-foreign-cairo.c
./autogen.sh --prefix=$PYGTK_PREFIX
make
make install
)
)
fi