9
9
# notice and this notice are preserved. This file is offered as-is,
10
10
# without any warranty.
11
11
12
+ VERSION=2.7.10 # for end-of-life Python2, support Ren'Py's version only
12
13
DESTDIR=${DESTDIR:- $(dirname $(readlink -f $0 ))/ destdir}
13
14
SETUPLOCAL=${SETUPLOCAL:- ' /dev/null' }
14
15
@@ -19,23 +20,23 @@ export QUILT_PATCHES=$(dirname $(readlink -f $0))/patches
19
20
WGET=${WGET:- wget}
20
21
21
22
unpack () {
22
- $WGET -c https://www.python.org/ftp/python/2.7.10 /Python-2.7.10 .tgz -P $CACHEROOT /
23
+ $WGET -c https://www.python.org/ftp/python/$VERSION /Python-$VERSION .tgz -P $CACHEROOT /
23
24
mkdir -p $BUILD
24
25
cd $BUILD /
25
- rm -rf Python-2.7.10 /
26
- tar xf $CACHEROOT /Python-2.7.10 .tgz
27
- cd Python-2.7.10 /
26
+ rm -rf Python-$VERSION /
27
+ tar xf $CACHEROOT /Python-$VERSION .tgz
28
+ cd Python-$VERSION /
28
29
quilt push -a
29
30
}
30
31
31
32
# TODO: multiple partially supported use cases:
32
- # - emscripten() below
33
- # - mock-ing emscripten (but with signal module)
33
+ # - python and pgen for emscripten() below
34
+ # - mock-ing emscripten environment through static desktop python (but with signal module)
34
35
# - building static/dynamic wasm modules (but lacks setuptools and its
35
36
# threads dependency)
36
37
# Make several builds?
37
38
native () {
38
- cd $BUILD /Python-2.7.10 /
39
+ cd $BUILD /Python-$VERSION /
39
40
mkdir -p native
40
41
(
41
42
cd native/
@@ -48,27 +49,31 @@ native () {
48
49
echo ' *static*' > Modules/Setup.local
49
50
cat $SETUPLOCAL >> Modules/Setup.local
50
51
52
+ # used by a Python script in 'make install' - or not
53
+ # echo '_struct _struct.c' >> Modules/Setup.local
54
+ # echo 'unicodedata unicodedata.c' >> Modules/Setup.local
55
+
51
56
make -j$( nproc) Parser/pgen python
52
57
53
58
make -j$( nproc)
54
59
DESTDIR= make install
55
60
56
- # emcc should disregard '-fPIC' during non-SIDE_MODULE builds,
57
- # otherwise _sysconfigdata.build_time_vars['CCSHARED'] is the culprit:
58
- # sed -i -e 's/-fPIC//' $BUILD/hostpython/lib/python2.7/_sysconfigdata.py
61
+ # emcc should disregard '-fPIC' during non-SIDE_MODULE builds,
62
+ # otherwise _sysconfigdata.build_time_vars['CCSHARED'] is the culprit:
63
+ # sed -i -e 's/-fPIC//' $BUILD/hostpython/lib/python2.7/_sysconfigdata.py
59
64
)
60
65
}
61
66
62
67
emscripten () {
63
- cd $BUILD /Python-2.7.10 /
68
+ cd $BUILD /Python-$VERSION /
64
69
mkdir -p emscripten
65
70
(
66
71
cd emscripten/
67
72
# OPT=-Oz: TODO
68
73
# CONFIG_SITE: deals with cross-compilation https://bugs.python.org/msg136962
69
74
# not needed as emcc has a single arch: BASECFLAGS=-m32 LDFLAGS=-m32
70
- # --without-threads: pthreads currently not yet usable in emscripten as of 2018-12
71
- # cf. https://kripken.github.io/ emscripten-site /docs/porting/pthreads.html
75
+ # --without-threads: pthreads experimental as of 2019-11
76
+ # cf. https://emscripten.org /docs/porting/pthreads.html
72
77
73
78
if [ ! -e config.status ]; then
74
79
CONFIG_SITE=../config.site BASECFLAGS=' -s USE_ZLIB=1' \
@@ -79,22 +84,26 @@ emscripten () {
79
84
--disable-shared
80
85
fi
81
86
sed -i -e ' s,^#define HAVE_GCC_ASM_FOR_X87.*,/* & */,' pyconfig.h
82
- # Work-around network functions detection
83
- # https://github.com/emscripten-core/emscripten/issues/9154
84
- sed -i -e ' s,^/\* #undef HAVE_GETPEERNAME \*/,#define HAVE_GETPEERNAME 1,' pyconfig.h
85
- sed -i -e ' s,^/\* #undef HAVE_GETNAMEINFO \*/,#define HAVE_GETNAMEINFO 1,' pyconfig.h
86
- # Modules/Setup.local
87
- emmake make Parser/pgen # need to build it once before overwriting it with the native one
87
+
88
+ # pgen native setup
89
+ # note: need to build 'pgen' once before overwriting it with the native one
90
+ # note: PGEN=../native/Parser/pgen doesn't work, make overwrites it
91
+ emmake make Parser/pgen
88
92
\c p --preserve=mode ../native/Parser/pgen Parser/
89
- # note: PGEN=../native/Parser/pgen doesn't work, make just overwrites it
90
- # note: PYTHON_FOR_BUILD=../native/python, PATH=... doesn't work, it breaks emcc's Python
93
+ # python native setup
94
+ # note: PATH=... doesn't work, it breaks emcc's /usr/bin/env python
95
+ # note: PYTHON_FOR_BUILD=../native/python neither, it's a more complex call
96
+ # emmake env PATH=../../hostpython/bin:$PATH make -j$(nproc)
91
97
sed -i -e ' s,\(PYTHON_FOR_BUILD=.*\) python2.7,\1 $(abs_srcdir)/native/python,' Makefile
98
+
99
+ # Modules/Setup.local
92
100
echo ' *static*' > Modules/Setup.local
93
101
cat $SETUPLOCAL >> Modules/Setup.local
94
- # drop -lz, we USE_ZLIB=1:
102
+ # drop -I/-L/- lz, we USE_ZLIB=1 (keep it in SETUPLOCAL for mock)
95
103
sed -i -e ' s/^\(zlib zlibmodule.c\).*/\1/' Modules/Setup.local
96
104
97
105
emmake make -j$( nproc)
106
+
98
107
# setup.py install_lib doesn't respect DESTDIR
99
108
echo -e ' sharedinstall:\n\ttrue' >> Makefile
100
109
# decrease .pyo size by dropping docstrings
0 commit comments