FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Make build script more self-contained and generic · python-emscripten/python@997cd7f · GitHub

Repository navigation

Commit 997cd7f

Browse files
committed
Make build script more self-contained and generic
1 parent d8720f8 commit 997cd7f

2 files changed

Lines changed: 35 additions & 68 deletions

File tree

‎.fossil-settings/ignore-glob‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*/data/
2+
*/build/
3+
*/Python-*.tgz

‎2.7.10/python.sh‎

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

12-
CACHEROOT=$(dirname $(readlink -f $0))/../../cache
13-
BUILD=$(dirname $(readlink -f $0))/../../build
14-
INSTALLDIR=$(dirname $(readlink -f $0))/../../install
15-
PATCHESDIR=$(dirname $(readlink -f $0))/patches
12+
PREFIX=${PREFIX:-$(dirname $(readlink -f $0))/install}
13+
SETUPLOCAL=${SETUPLOCAL:-'/dev/null'}
14+
15+
CACHEROOT=$(dirname $(readlink -f $0))
16+
BUILD=$(dirname $(readlink -f $0))/build
17+
export QUILT_PATCHES=$(dirname $(readlink -f $0))/patches
18+
19+
WGET=${WGET:-wget}
1620

1721
unpack () {
22+
$WGET -c https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz -P $CACHEROOT/
23+
mkdir -p $BUILD
1824
cd $BUILD/
1925
rm -rf Python-2.7.10/
2026
tar xf $CACHEROOT/Python-2.7.10.tgz
2127
cd Python-2.7.10/
22-
QUILT_PATCHES=$PATCHESDIR quilt push -a
28+
quilt push -a
2329
}
2430

2531
native () {
@@ -34,33 +40,7 @@ native () {
3440
--without-threads --without-pymalloc --disable-shared --disable-ipv6
3541
fi
3642
echo '*static*' > Modules/Setup.local
37-
# pygame_sdl2 deps:
38-
echo 'binascii binascii.c' >> Modules/Setup.local
39-
echo '_struct _struct.c' >> Modules/Setup.local
40-
echo '_collections _collectionsmodule.c' >> Modules/Setup.local
41-
echo 'operator operator.c' >> Modules/Setup.local
42-
echo 'itertools itertoolsmodule.c' >> Modules/Setup.local
43-
echo 'time timemodule.c' >> Modules/Setup.local
44-
echo 'math mathmodule.c _math.c' >> Modules/Setup.local
45-
# Ren'Py deps:
46-
echo 'cStringIO cStringIO.c' >> Modules/Setup.local
47-
echo 'cPickle cPickle.c' >> Modules/Setup.local
48-
#echo 'signal signalmodule.c' >> Modules/Setup.local # comment out 'import subprocess'
49-
echo '_io -I$(srcdir)/Modules/_io _io/bufferedio.c _io/bytesio.c _io/fileio.c _io/iobase.c _io/_iomodule.c _io/stringio.c _io/textio.c' >> Modules/Setup.local
50-
echo '_random _randommodule.c' >> Modules/Setup.local
51-
echo '_functools _functoolsmodule.c' >> Modules/Setup.local
52-
echo 'datetime datetimemodule.c' >> Modules/Setup.local
53-
echo 'zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz' >> Modules/Setup.local
54-
echo '_md5 md5module.c md5.c' >> Modules/Setup.local
55-
echo 'array arraymodule.c' >> Modules/Setup.local
56-
# avoid warnings from hashlib module
57-
echo '_sha shamodule.c' >> Modules/Setup.local
58-
echo '_sha256 sha256module.c' >> Modules/Setup.local
59-
echo '_sha512 sha512module.c' >> Modules/Setup.local
60-
61-
# enable _struct and unicodedata, used by a Python script in 'make install' - or not
62-
#echo '_struct _struct.c' >> Modules/Setup.local
63-
#echo 'unicodedata unicodedata.c' >> Modules/Setup.local
43+
cat $SETUPLOCAL >> Modules/Setup.local
6444

6545
make -j$(nproc) Parser/pgen python
6646

@@ -77,12 +57,13 @@ emscripten () {
7757
# OPT=-Oz: TODO
7858
# CONFIG_SITE: deals with cross-compilation https://bugs.python.org/msg136962
7959
# not needed as emcc has a single arch: BASECFLAGS=-m32 LDFLAGS=-m32
80-
# --without-threads: pthreads currently not usable in emscripten (tragically)
60+
# --without-threads: pthreads currently not yet usable in emscripten as of 2018-12
61+
# cf. https://kripken.github.io/emscripten-site/docs/porting/pthreads.html
8162

8263
if [ ! -e config.status ]; then
8364
CONFIG_SITE=../config.site BASECFLAGS='-s USE_ZLIB=1' emconfigure ../configure \
8465
--host=asmjs-unknown-emscripten --build=$(../config.guess) \
85-
--prefix=$INSTALLDIR \
66+
--prefix=$PREFIX \
8667
--without-threads --without-pymalloc --without-signal-module --disable-ipv6 \
8768
--disable-shared
8869
fi
@@ -94,37 +75,13 @@ emscripten () {
9475
# note: PYTHON_FOR_BUILD=../native/python, PATH=... doesn't work, it breaks emcc's Python
9576
sed -i -e 's,\(PYTHON_FOR_BUILD=.*\) python2.7,\1 $(abs_srcdir)/native/python,' Makefile
9677
echo '*static*' > Modules/Setup.local
97-
# pygame_sdl2 deps:
98-
echo 'binascii binascii.c' >> Modules/Setup.local
99-
echo '_struct _struct.c' >> Modules/Setup.local
100-
echo '_collections _collectionsmodule.c' >> Modules/Setup.local
101-
echo 'operator operator.c' >> Modules/Setup.local
102-
echo 'itertools itertoolsmodule.c' >> Modules/Setup.local
103-
echo 'time timemodule.c' >> Modules/Setup.local
104-
echo 'math mathmodule.c _math.c' >> Modules/Setup.local
105-
# Ren'Py deps:
106-
echo 'cStringIO cStringIO.c' >> Modules/Setup.local
107-
echo 'cPickle cPickle.c' >> Modules/Setup.local
108-
#echo 'signal signalmodule.c' >> Modules/Setup.local # comment out 'import subprocess'
109-
echo '_io -I$(srcdir)/Modules/_io _io/bufferedio.c _io/bytesio.c _io/fileio.c _io/iobase.c _io/_iomodule.c _io/stringio.c _io/textio.c' >> Modules/Setup.local
110-
echo '_random _randommodule.c' >> Modules/Setup.local
111-
echo '_functools _functoolsmodule.c' >> Modules/Setup.local
112-
echo 'datetime datetimemodule.c' >> Modules/Setup.local
113-
echo 'zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz' >> Modules/Setup.local
114-
echo '_md5 md5module.c md5.c' >> Modules/Setup.local
115-
echo 'array arraymodule.c' >> Modules/Setup.local
116-
# avoid warnings from hashlib module
117-
echo '_sha shamodule.c' >> Modules/Setup.local
118-
echo '_sha256 sha256module.c' >> Modules/Setup.local
119-
echo '_sha512 sha512module.c' >> Modules/Setup.local
120-
121-
#echo 'strop stropmodule.c' >> Modules/Setup.local # for platform module -> use sys.platform
122-
#echo 'zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz' >> Modules/Setup.local
78+
cat $SETUPLOCAL >> Modules/Setup.local
12379

12480
emmake make -j$(nproc)
12581
emmake make install
12682

12783
# Basic trimming
84+
# Disabled for now, better cherry-pick the files we need
12885
#emmake make install DESTDIR=$(pwd)/destdir
12986
#find destdir/ -name "*.py" -print0 | xargs -r0 rm
13087
#find destdir/ -name "*.pyo" -print0 | xargs -r0 rm # only keep .pyc, .pyo apparently don't work
@@ -135,16 +92,23 @@ emscripten () {
13592
#rm -rf destdir/usr/local/lib/*.a
13693
#rm -rf destdir/usr/local/lib/pkgconfig/
13794
#rm -rf destdir/usr/local/lib/python2.7/test/
138-
13995
# Ditch .so for now, they cause an abort() with dynamic
14096
# linking unless we recompile all of them as SIDE_MODULE-s
141-
rm -rf $INSTALLDIR/lib/python2.7/lib-dynload/
97+
#rm -rf $PREFIX/lib/python2.7/lib-dynload/
14298
)
14399
}
144100

145-
if [ "$1" = "" ]; then
146-
echo "Usage: $0 native|emscripten"
147-
exit 1
148-
fi
149-
150-
"$1"
101+
case "$1" in
102+
unpack|native|emscripten)
103+
"$1"
104+
;;
105+
'')
106+
unpack
107+
native
108+
emscripten
109+
;;
110+
*)
111+
echo "Usage: $0 unpack|native|emscripten"
112+
exit 1
113+
;;
114+
esac

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL