Skip to content

Commit fa969df

Browse files
author
me
committed
Tidy python.sh a bit
1 parent 98f254c commit fa969df

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

2.7.10/package-pythonhome.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ if [ "$1" == "--lz4" ]; then LZ4="--lz4"; shift; fi
2424
rm -rf $PACKAGEDIR/
2525
mkdir -p $PACKAGEDIR
2626

27-
# Hard-coded modules: for 'print "hello, world."'
27+
# Hard-coded modules: for 'print("hello, world.")'
2828
# $@: additional, app-specific modules
29-
for i in site.py os.py posixpath.py stat.py genericpath.py warnings.py linecache.py types.py UserDict.py _abcoll.py abc.py _weakrefset.py copy_reg.py traceback.py sysconfig.py re.py sre_compile.py sre_parse.py sre_constants.py _sysconfigdata.py encodings/__init__.py codecs.py encodings/aliases.py encodings/utf_8.py __future__.py ast.py copy.py weakref.py platform.py string.py io.py tempfile.py random.py hashlib.py struct.py dummy_thread.py collections.py keyword.py heapq.py argparse.py textwrap.py gettext.py locale.py functools.py importlib/__init__.py glob.py fnmatch.py pickle.py colorsys.py contextlib.py zipfile.py shutil.py json/__init__.py json/decoder.py json/scanner.py encodings/hex_codec.py json/encoder.py difflib.py inspect.py dis.py opcode.py tokenize.py token.py xml/__init__.py xml/etree/__init__.py xml/etree/ElementTree.py xml/etree/ElementPath.py encodings/zlib_codec.py tarfile.py urlparse.py StringIO.py encodings/latin_1.py \
29+
for i in site.py os.py posixpath.py stat.py genericpath.py warnings.py linecache.py types.py UserDict.py _abcoll.py abc.py _weakrefset.py copy_reg.py traceback.py sysconfig.py re.py sre_compile.py sre_parse.py sre_constants.py _sysconfigdata.py encodings/__init__.py codecs.py encodings/aliases.py encodings/utf_8.py __future__.py ast.py copy.py weakref.py platform.py string.py io.py tempfile.py random.py hashlib.py struct.py dummy_thread.py collections.py keyword.py heapq.py argparse.py textwrap.py gettext.py locale.py functools.py importlib/__init__.py glob.py fnmatch.py pickle.py colorsys.py contextlib.py zipfile.py shutil.py json/__init__.py json/decoder.py json/scanner.py encodings/hex_codec.py json/encoder.py difflib.py inspect.py dis.py opcode.py tokenize.py token.py xml/__init__.py xml/etree/__init__.py xml/etree/ElementTree.py xml/etree/ElementPath.py encodings/zlib_codec.py tarfile.py urlparse.py StringIO.py encodings/latin_1.py encodings/ascii.py \
3030
"$@"; do
3131
if [ $PREFIX/lib/python2.7/$i -nt $PREFIX/lib/python2.7/${i%.py}.pyo ]; then
3232
(cd $PREFIX && python -OO -m py_compile lib/python2.7/$i)
@@ -35,6 +35,7 @@ for i in site.py os.py posixpath.py stat.py genericpath.py warnings.py linecache
3535
cp -au $PREFIX/lib/python2.7/${i%.py}.pyo $PACKAGEDIR/lib/python2.7/${i%.py}.pyo
3636
done
3737

38+
# --no-heap-copy: suited for ALLOW_MEMORY_GROWTH=1
3839
PACKAGEDIR_FULLPATH=$(readlink -f $PACKAGEDIR)
3940
(
4041
cd $OUTDIR; # use relative path in xxx-data.js

2.7.10/python.sh

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# notice and this notice are preserved. This file is offered as-is,
1010
# without any warranty.
1111

12+
VERSION=2.7.10 # for end-of-life Python2, support Ren'Py's version only
1213
DESTDIR=${DESTDIR:-$(dirname $(readlink -f $0))/destdir}
1314
SETUPLOCAL=${SETUPLOCAL:-'/dev/null'}
1415

@@ -19,23 +20,23 @@ export QUILT_PATCHES=$(dirname $(readlink -f $0))/patches
1920
WGET=${WGET:-wget}
2021

2122
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/
2324
mkdir -p $BUILD
2425
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/
2829
quilt push -a
2930
}
3031

3132
# 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)
3435
# - building static/dynamic wasm modules (but lacks setuptools and its
3536
# threads dependency)
3637
# Make several builds?
3738
native () {
38-
cd $BUILD/Python-2.7.10/
39+
cd $BUILD/Python-$VERSION/
3940
mkdir -p native
4041
(
4142
cd native/
@@ -48,27 +49,31 @@ native () {
4849
echo '*static*' > Modules/Setup.local
4950
cat $SETUPLOCAL >> Modules/Setup.local
5051

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+
5156
make -j$(nproc) Parser/pgen python
5257

5358
make -j$(nproc)
5459
DESTDIR= make install
5560

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
5964
)
6065
}
6166

6267
emscripten () {
63-
cd $BUILD/Python-2.7.10/
68+
cd $BUILD/Python-$VERSION/
6469
mkdir -p emscripten
6570
(
6671
cd emscripten/
6772
# OPT=-Oz: TODO
6873
# CONFIG_SITE: deals with cross-compilation https://bugs.python.org/msg136962
6974
# 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
7277

7378
if [ ! -e config.status ]; then
7479
CONFIG_SITE=../config.site BASECFLAGS='-s USE_ZLIB=1' \
@@ -79,22 +84,26 @@ emscripten () {
7984
--disable-shared
8085
fi
8186
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
8892
\cp --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)
9197
sed -i -e 's,\(PYTHON_FOR_BUILD=.*\) python2.7,\1 $(abs_srcdir)/native/python,' Makefile
98+
99+
# Modules/Setup.local
92100
echo '*static*' > Modules/Setup.local
93101
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)
95103
sed -i -e 's/^\(zlib zlibmodule.c\).*/\1/' Modules/Setup.local
96104

97105
emmake make -j$(nproc)
106+
98107
# setup.py install_lib doesn't respect DESTDIR
99108
echo -e 'sharedinstall:\n\ttrue' >> Makefile
100109
# decrease .pyo size by dropping docstrings

0 commit comments

Comments
 (0)