Skip to content

Commit 5656225

Browse files
committed
Fix pyodide#71: Upgrade to Python 3.7
1 parent d4660f1 commit 5656225

32 files changed

+439
-440
lines changed

.circleci/config.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2
33
defaults: &defaults
44
working_directory: ~/repo
55
docker:
6-
- image: circleci/python:3.6.5-stretch-browsers
6+
- image: circleci/python:3.7.0-stretch-browsers
77

88
jobs:
99
build:
@@ -27,11 +27,11 @@ jobs:
2727
sudo ln -s /usr/bin/clang-format-6.0 /usr/bin/clang-format
2828
2929
sudo pip install virtualenv
30-
30+
3131
virtualenv pyodide-env
3232
3333
source pyodide-env/bin/activate
34-
34+
3535
pip install pytest pytest-xdist pytest-instafail selenium PyYAML
3636
3737
# Get recent version of Firefox and geckodriver

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ indent_size = 4
1616

1717
[Makefile]
1818
indent_style = tab
19+
20+
[**.patch]
21+
trim_trailing_whitespace = false

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ all: build/pyodide.asm.js \
5656

5757
build/pyodide.asm.js: src/main.bc src/jsimport.bc src/jsproxy.bc src/js2python.bc \
5858
src/pyimport.bc src/pyproxy.bc src/python2js.bc \
59-
src/runpython.bc src/dummy_thread.bc src/hiwire.bc
59+
src/runpython.bc src/hiwire.bc
6060
[ -d build ] || mkdir build
6161
$(CXX) -s EXPORT_NAME="'pyodide'" -o build/pyodide.asm.html $(filter %.bc,$^) \
6262
$(LDFLAGS) -s FORCE_FILESYSTEM=1
@@ -143,7 +143,7 @@ build/test.data: $(CPYTHONLIB)
143143
)
144144
( \
145145
cd build; \
146-
python $(FILEPACKAGER) test.data --preload ../$(CPYTHONLIB)/test@/lib/python3.6/test --js-output=test.js --export-name=pyodide --exclude \*.wasm.pre --exclude __pycache__ \
146+
python $(FILEPACKAGER) test.data --preload ../$(CPYTHONLIB)/test@/lib/python3.7/test --js-output=test.js --export-name=pyodide --exclude \*.wasm.pre --exclude __pycache__ \
147147
)
148148
uglifyjs build/test.js -o build/test.js
149149

Makefile.envs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export EM_CACHE = $(PYODIDE_ROOT)/emsdk/emsdk/.emscripten_cache
66
export EMSCRIPTEN = $(PYODIDE_ROOT)/emsdk/emsdk/emscripten/tag-1.38.10
77
export BINARYEN_ROOT = $(PYODIDE_ROOT)/emsdk/emsdk/binaryen/tag-1.38.10_64bit_binaryen
88

9-
export PYVERSION=3.6.4
9+
export PYVERSION=3.7.0
1010
export PYMINOR=$(basename $(PYVERSION))
1111
export HOSTPYTHONROOT=$(PYODIDE_ROOT)/cpython/build/$(PYVERSION)/host
1212
export HOSTPYTHON=$(HOSTPYTHONROOT)/bin/python3

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ need to build it yourself prior.
2424
Additional build prerequisites are:
2525

2626
- A working native compiler toolchain, enough to build CPython.
27-
- A native Python 3.6 or later to run the build scripts.
27+
- A native Python 3.7 to run the build scripts.
2828
- PyYAML
2929
- [lessc](https://lesscss.org/) to compile less to css.
3030
- [uglifyjs](https://github.com/mishoo/UglifyJS) to minify Javascript builds.

cpython/Makefile

+19-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ URL=https://www.python.org/ftp/python/$(PYVERSION)/Python-$(PYVERSION).tgz
1515
LIB=libpython$(PYMINOR).a
1616

1717

18+
ZLIBVERSION = 1.2.11
19+
ZLIBTARBALL=$(ROOT)/downloads/zlib-$(ZLIBVERSION).tar.gz
20+
ZLIBBUILD=$(ROOT)/build/zlib-$(ZLIBVERSION)
21+
ZLIBURL=https://zlib.net/zlib-1.2.11.tar.gz
22+
23+
1824
all: $(INSTALL)/lib/$(LIB)
1925

2026

@@ -42,6 +48,11 @@ $(TARBALL):
4248
md5sum --quiet --check checksums || (rm $@; false)
4349

4450

51+
$(ZLIBTARBALL):
52+
[ -d $(ROOT)/downloads ] || mkdir $(ROOT)/downloads
53+
wget -q -O $@ $(ZLIBURL)
54+
55+
4556
$(HOSTPYTHON) $(HOSTPGEN): $(TARBALL)
4657
mkdir -p $(HOSTINSTALL)
4758
[ -d $(HOSTBUILD) ] || tar -C $(HOSTINSTALL) -xf $(TARBALL)
@@ -61,7 +72,14 @@ $(BUILD)/.patched: $(TARBALL)
6172
touch $@
6273

6374

64-
$(BUILD)/Makefile: $(BUILD)/.patched
75+
$(ZLIBBUILD)/.patched: $(ZLIBTARBALL)
76+
[ -d $(ROOT)/build ] || (mkdir $(ROOT)/build)
77+
tar -C $(ROOT)/build/ -xf $(ROOT)/downloads/zlib-1.2.11.tar.gz
78+
cat patches/zlib/*.patch | (cd $(ZLIBBUILD) ; patch -p1)
79+
touch $@
80+
81+
82+
$(BUILD)/Makefile: $(BUILD)/.patched $(ZLIBBUILD)/.patched
6583
cp config.site $(BUILD)/
6684
( \
6785
cd $(BUILD); \
@@ -71,10 +89,6 @@ $(BUILD)/Makefile: $(BUILD)/.patched
7189

7290
$(BUILD)/$(LIB): $(BUILD)/Makefile $(HOSTPYTHON) $(HOSTPGEN) Setup.local
7391
cp Setup.local $(BUILD)/Modules/
74-
( \
75-
cd $(BUILD)/Modules/zlib; \
76-
emconfigure ./configure --static \
77-
)
7892
( \
7993
cp build/$(PYVERSION)/host/lib/python$(PYMINOR)/`$(HOSTPYTHON) -c "import sysconfig; print(sysconfig._get_sysconfigdata_name())"`.py build/$(PYVERSION)/Python-$(PYVERSION)/Lib/_sysconfigdata__emscripten_.py; \
8094
cd $(BUILD); \

cpython/Setup.local

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
array arraymodule.c # array objects
88
math mathmodule.c _math.c # -lm # math library functions, e.g. sin()
99
cmath cmathmodule.c # complex math functions
10+
_contextvars _contextvarsmodule.c
1011
_struct _struct.c # binary structure packing/unpacking
1112
_random _randommodule.c # Random number generator
1213
_bisect _bisectmodule.c # Bisection algorithms
@@ -21,10 +22,9 @@ parser parsermodule.c
2122
_socket socketmodule.c
2223
select selectmodule.c
2324
_posixsubprocess _posixsubprocess.c
24-
2525
binascii binascii.c
2626

27-
zlib zlibmodule.c -IModules/zlib
27+
zlib zlibmodule.c -I../../zlib-1.2.11
2828

2929
pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI -DXML_POOR_ENTROPY
3030

@@ -33,7 +33,9 @@ _sha256 sha256module.c
3333
_sha512 sha512module.c
3434
_sha3 _sha3/sha3module.c
3535
_md5 md5module.c
36-
_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c ../../host/Python-3.6.4/Modules/_blake2/blake2s_impl.c
36+
_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c ../../host/Python-3.7.0/Modules/_blake2/blake2s_impl.c
37+
38+
_queue _queuemodule.c
3739

3840
#future_builtins future_builtins.c
3941

cpython/checksums

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9de6494314ea199e3633211696735f65 ./downloads/Python-3.6.4.tgz
1+
41b6595deb4147a1ed517a7d9a580271 downloads/Python-3.7.0.tgz

cpython/config.site

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ ac_cv_file__dev_ptmx=no
22
ac_cv_file__dev_ptc=no
33
ac_cv_func_dlopen=yes
44
ac_cv_lib_socket_socket=no
5-
ac_cv_little_endian_double=yes
5+
ac_cv_header_linux_vm_sockets_h=yes
6+
ac_cv_little_endian_double=yes
+37-37
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,39 @@
1+
diff --git a/config.sub b/config.sub
2+
index ba37cf99e2..d772f33065 100755
3+
--- a/config.sub
4+
+++ b/config.sub
5+
@@ -118,7 +118,8 @@ case $maybe_os in
6+
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
7+
knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
8+
kopensolaris*-gnu* | cloudabi*-eabi* | \
9+
- storm-chaos* | os2-emx* | rtmk-nova*)
10+
+ storm-chaos* | os2-emx* | rtmk-nova* | \
11+
+ emscripten)
12+
os=-$maybe_os
13+
basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
14+
;;
15+
@@ -377,6 +378,7 @@ case $basic_machine in
16+
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
17+
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
18+
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
19+
+ | asmjs \
20+
| avr-* | avr32-* \
21+
| ba-* \
22+
| be32-* | be64-* \
23+
@@ -1522,6 +1524,8 @@ case $os in
24+
;;
25+
esac
26+
;;
27+
+ -emscripten)
28+
+ ;;
29+
-nacl*)
30+
;;
31+
-ios)
132
diff --git a/configure b/configure
2-
index 8cf777e..263719f 100755
33+
index e0389649ae..e6ab1613cf 100755
334
--- a/configure
435
+++ b/configure
5-
@@ -3202,6 +3202,9 @@ then
36+
@@ -3257,6 +3257,9 @@ then
637
*-*-cygwin*)
738
ac_sys_system=Cygwin
839
;;
@@ -12,7 +43,7 @@ index 8cf777e..263719f 100755
1243
*)
1344
# for now, limit cross builds to known configurations
1445
MACHDEP="unknown"
15-
@@ -3248,6 +3251,9 @@ if test "$cross_compiling" = yes; then
46+
@@ -3301,6 +3304,9 @@ if test "$cross_compiling" = yes; then
1647
*-*-cygwin*)
1748
_host_cpu=
1849
;;
@@ -23,10 +54,10 @@ index 8cf777e..263719f 100755
2354
# for now, limit cross builds to known configurations
2455
MACHDEP="unknown"
2556
diff --git a/configure.ac b/configure.ac
26-
index 78fe3c7..d7665b4 100644
57+
index b5beb08574..8051e5a8ed 100644
2758
--- a/configure.ac
2859
+++ b/configure.ac
29-
@@ -322,6 +322,9 @@ then
60+
@@ -379,6 +379,9 @@ then
3061
*-*-cygwin*)
3162
ac_sys_system=Cygwin
3263
;;
@@ -36,7 +67,7 @@ index 78fe3c7..d7665b4 100644
3667
*)
3768
# for now, limit cross builds to known configurations
3869
MACHDEP="unknown"
39-
@@ -368,6 +371,9 @@ if test "$cross_compiling" = yes; then
70+
@@ -423,6 +426,9 @@ if test "$cross_compiling" = yes; then
4071
*-*-cygwin*)
4172
_host_cpu=
4273
;;
@@ -46,34 +77,3 @@ index 78fe3c7..d7665b4 100644
4677
*)
4778
# for now, limit cross builds to known configurations
4879
MACHDEP="unknown"
49-
diff --git a/config.sub b/config.sub
50-
index d654d03..0d8236f 100755
51-
--- a/config.sub
52-
+++ b/config.sub
53-
@@ -119,7 +119,8 @@ case $maybe_os in
54-
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
55-
knetbsd*-gnu* | netbsd*-gnu* | \
56-
kopensolaris*-gnu* | cloudabi*-eabi* | \
57-
- storm-chaos* | os2-emx* | rtmk-nova*)
58-
+ storm-chaos* | os2-emx* | rtmk-nova* | \
59-
+ emscripten)
60-
os=-$maybe_os
61-
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
62-
;;
63-
@@ -254,6 +255,7 @@ case $basic_machine in
64-
| am33_2.0 \
65-
| arc | arceb \
66-
| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
67-
+ | asmjs \
68-
| avr | avr32 \
69-
| be32 | be64 \
70-
| bfin \
71-
@@ -1510,6 +1512,8 @@ case $os in
72-
-dicos*)
73-
os=-dicos
74-
;;
75-
+ -emscripten)
76-
+ ;;
77-
-nacl*)
78-
;;
79-
-none)
+22-24
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
*** a/Python/fileutils.c 2016-10-25 02:01:16.270148214 +0100
2-
--- b/Python/fileutils.c 2016-10-25 02:01:27.086148626 +0100
3-
***************
4-
*** 785,790 ****
5-
--- 785,793 ----
6-
static int
7-
set_inheritable(int fd, int inheritable, int raise, int *atomic_flag_works)
8-
{
9-
+ #ifdef EMSCRIPTEN
10-
+ return 0;
11-
+ #else
12-
#ifdef MS_WINDOWS
13-
HANDLE handle;
14-
DWORD flags;
15-
***************
16-
*** 897,902 ****
17-
--- 900,906 ----
18-
}
19-
return 0;
20-
#endif
21-
+ #endif
22-
}
23-
24-
/* Make the file descriptor non-inheritable.
1+
diff --git a/Python/fileutils.c b/Python/fileutils.c
2+
index 35869c81ac..1af4ead7f5 100644
3+
--- a/Python/fileutils.c
4+
+++ b/Python/fileutils.c
5+
@@ -964,6 +964,9 @@ _Py_get_inheritable(int fd)
6+
static int
7+
set_inheritable(int fd, int inheritable, int raise, int *atomic_flag_works)
8+
{
9+
+#ifdef EMSCRIPTEN
10+
+ return 0;
11+
+#else
12+
#ifdef MS_WINDOWS
13+
HANDLE handle;
14+
DWORD flags;
15+
@@ -1080,6 +1083,7 @@ set_inheritable(int fd, int inheritable, int raise, int *atomic_flag_works)
16+
}
17+
return 0;
18+
#endif
19+
+#endif
20+
}
21+
22+
/* Make the file descriptor non-inheritable.

cpython/patches/no_af_vsock.patch

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/Modules/socketmodule.h b/Modules/socketmodule.h
2+
index fdb4e871ce..c990003ff3 100644
3+
--- a/Modules/socketmodule.h
4+
+++ b/Modules/socketmodule.h
5+
@@ -144,6 +144,8 @@ typedef int socklen_t;
6+
extern "C" {
7+
#endif
8+
9+
+#undef AF_VSOCK
10+
+
11+
/* Python module and C API name */
12+
#define PySocket_MODULE_NAME "_socket"
13+
#define PySocket_CAPI_NAME "CAPI"

cpython/patches/testing.patch

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/Lib/platform.py b/Lib/platform.py
2-
index cc2db9870d..ac4e3c538f 100755
2+
index 20f9817f4f..bcf96874c0 100755
33
--- a/Lib/platform.py
44
+++ b/Lib/platform.py
55
@@ -748,7 +748,7 @@ def _syscmd_uname(option, default=''):
@@ -21,35 +21,35 @@ index cc2db9870d..ac4e3c538f 100755
2121
return default
2222
target = _follow_symlinks(target)
2323
diff --git a/Lib/test/support/script_helper.py b/Lib/test/support/script_helper.py
24-
index ca5f9c20dd..97934039ee 100644
24+
index 64b25aab80..7cf67fd149 100644
2525
--- a/Lib/test/support/script_helper.py
2626
+++ b/Lib/test/support/script_helper.py
27-
@@ -11,6 +11,7 @@ import subprocess
27+
@@ -9,6 +9,7 @@ import os.path
28+
import subprocess
2829
import py_compile
29-
import contextlib
30-
import shutil
31-
+import unittest
3230
import zipfile
31+
+import unittest
3332

3433
from importlib.util import source_from_cache
35-
@@ -37,6 +38,8 @@ def interpreter_requires_environment():
34+
from test.support import make_legacy_pyc, strip_python_stderr
35+
@@ -34,6 +35,8 @@ def interpreter_requires_environment():
3636
situation. PYTHONPATH or PYTHONUSERSITE are other common environment
3737
variables that might impact whether or not the interpreter can start.
3838
"""
3939
+ raise unittest.SkipTest('no subprocess')
4040
+
4141
global __cached_interp_requires_environment
4242
if __cached_interp_requires_environment is None:
43-
# Try running an interpreter with -E to see if it works or not.
44-
@@ -165,6 +168,8 @@ def spawn_python(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw):
43+
# If PYTHONHOME is set, assume that we need it
44+
@@ -172,6 +175,8 @@ def spawn_python(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw):
4545
kw is extra keyword args to pass to subprocess.Popen. Returns a Popen
4646
object.
4747
"""
4848
+ raise unittest.SkipTest("no subprocess")
4949
+
50-
cmd_line = [sys.executable, '-E']
51-
cmd_line.extend(args)
52-
# Under Fedora (?), GNU readline can output junk on stderr when initialized,
50+
cmd_line = [sys.executable]
51+
if not interpreter_requires_environment():
52+
cmd_line.append('-E')
5353
diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py
5454
index 55faf4c427..b2201c09e7 100644
5555
--- a/Lib/test/test_code.py
@@ -67,7 +67,7 @@ index 55faf4c427..b2201c09e7 100644
6767
import weakref
6868
try:
6969
diff --git a/Lib/test/test_import/__init__.py b/Lib/test/test_import/__init__.py
70-
index b73a96f757..0d1c411f9a 100644
70+
index 1fc4de11e1..e6c91707ae 100644
7171
--- a/Lib/test/test_import/__init__.py
7272
+++ b/Lib/test/test_import/__init__.py
7373
@@ -10,7 +10,10 @@ import py_compile

0 commit comments

Comments
 (0)