Skip to content

Commit e1ce2be

Browse files
committed
unix: initial support for building Python 3.10
I didn't spend much mental effort on this. There are likely bugs. Only Linux is supported for now. The extensions files were copied from 3.9 without changes. I did not audit upstream for changes that may need reflected in these files. In pursuit of #69.
1 parent 9e7a6af commit e1ce2be

File tree

9 files changed

+105
-17
lines changed

9 files changed

+105
-17
lines changed

.github/workflows/linux.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ jobs:
127127
py:
128128
- 'cpython-3.8'
129129
- 'cpython-3.9'
130+
- 'cpython-3.10'
130131
optimizations:
131132
- 'debug'
132133
- 'noopt'

cpython-unix/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,6 @@ $(OUTDIR)/cpython-$(CPYTHON_3.8_VERSION)-$(PACKAGE_SUFFIX).tar: $(ALL_PYTHON_DEP
336336

337337
$(OUTDIR)/cpython-$(CPYTHON_3.9_VERSION)-$(PACKAGE_SUFFIX).tar: $(ALL_PYTHON_DEPENDS)
338338
$(RUN_BUILD) cpython-3.9
339+
340+
$(OUTDIR)/cpython-$(CPYTHON_3.10_VERSION)-$(PACKAGE_SUFFIX).tar: $(ALL_PYTHON_DEPENDS)
341+
$(RUN_BUILD) cpython-3.10

cpython-unix/build-cpython.sh

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,6 @@ index 2d379feb4b..3eb8dbe9ea 100755
8989
*-*-vxworks*)
9090
_host_cpu=$host_cpu
9191
;;
92-
@@ -3426,6 +3448,12 @@ $as_echo "#define _BSD_SOURCE 1" >>confdefs.h
93-
define_xopen_source=no;;
94-
Darwin/[12][0-9].*)
95-
define_xopen_source=no;;
96-
+ iOS/*)
97-
+ define_xopen_source=no;;
98-
+ tvOS/*)
99-
+ define_xopen_source=no;;
100-
+ watchOS/*)
101-
+ define_xopen_source=no;;
102-
# On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
103-
# used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
104-
# or has another value. By not (re)defining it, the defaults come in place.
10592
@@ -5968,7 +5996,7 @@ $as_echo "#define Py_ENABLE_SHARED 1" >>confdefs.h
10693
BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)'
10794
RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
@@ -142,6 +129,49 @@ index 2d379feb4b..3eb8dbe9ea 100755
142129
LDCXXSHARED='$(CXX) -shared';;
143130
EOF
144131

132+
# This patch is slightly different on Python 3.10+.
133+
if [ "${PYTHON_MAJMIN_VERSION}" = "3.10" ]; then
134+
patch -p1 << "EOF"
135+
diff --git a/configure b/configure
136+
index 2d379feb4b..3eb8dbe9ea 100755
137+
--- a/configure
138+
+++ b/configure
139+
@@ -3426,6 +3448,12 @@ $as_echo "#define _BSD_SOURCE 1" >>confdefs.h
140+
define_xopen_source=no;;
141+
Darwin/[12][0-9].*)
142+
define_xopen_source=no;;
143+
+ iOS/*)
144+
+ define_xopen_source=no;;
145+
+ tvOS/*)
146+
+ define_xopen_source=no;;
147+
+ watchOS/*)
148+
+ define_xopen_source=no;;
149+
# On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
150+
# defining NI_NUMERICHOST.
151+
QNX/6.3.2)
152+
EOF
153+
else
154+
patch -p1 << "EOF"
155+
diff --git a/configure b/configure
156+
index 2d379feb4b..3eb8dbe9ea 100755
157+
--- a/configure
158+
+++ b/configure
159+
@@ -3426,6 +3448,12 @@ $as_echo "#define _BSD_SOURCE 1" >>confdefs.h
160+
define_xopen_source=no;;
161+
Darwin/[12][0-9].*)
162+
define_xopen_source=no;;
163+
+ iOS/*)
164+
+ define_xopen_source=no;;
165+
+ tvOS/*)
166+
+ define_xopen_source=no;;
167+
+ watchOS/*)
168+
+ define_xopen_source=no;;
169+
# On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
170+
# used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
171+
# or has another value. By not (re)defining it, the defaults come in place.
172+
EOF
173+
fi
174+
145175
# Add a make target to write the PYTHON_FOR_BUILD variable so we can
146176
# invoke the host Python on our own.
147177
patch -p1 << "EOF"
@@ -323,7 +353,7 @@ mv tmp Modules/readline-libedit.c
323353
# Modules/_hashopenssl.c redefines some libcrypto symbols on Python 3.9 and
324354
# this makes the linker unhappy. So rename the symbols to work around.
325355
# https://bugs.python.org/issue41949.
326-
if [ "${PYTHON_MAJMIN_VERSION}" = "3.9" ]; then
356+
if [ "${PYTHON_MAJMIN_VERSION}" != "3.8" ]; then
327357
patch -p1 <<EOF
328358
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
329359
index adc8653773..fc9070fc21 100644

cpython-unix/build-main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def main():
6666
)
6767
parser.add_argument(
6868
"--python",
69-
choices={"cpython-3.8", "cpython-3.9"},
69+
choices={"cpython-3.8", "cpython-3.9", "cpython-3.10"},
7070
default="cpython-3.9",
7171
help="Python distribution to build",
7272
)

cpython-unix/build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ def build_cpython(
840840
"CC": "clang",
841841
"PIP_VERSION": DOWNLOADS["pip"]["version"],
842842
"PYTHON_VERSION": entry["version"],
843-
"PYTHON_MAJMIN_VERSION": entry["version"][:3],
843+
"PYTHON_MAJMIN_VERSION": ".".join(entry["version"].split(".")[0:2]),
844844
"SETUPTOOLS_VERSION": DOWNLOADS["setuptools"]["version"],
845845
"TOOLCHAIN": "clang-%s" % host_platform,
846846
}
@@ -1178,7 +1178,7 @@ def main():
11781178
extra_archives=extra_archives,
11791179
)
11801180

1181-
elif action in ("cpython-3.8", "cpython-3.9"):
1181+
elif action in ("cpython-3.8", "cpython-3.9", "cpython-3.10"):
11821182
build_cpython(
11831183
client,
11841184
get_image(client, ROOT, BUILD, "build"),

cpython-unix/disabled-static-modules.3.10.linux64

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
_codecs
2+
_io
3+
_signal
4+
_thread
5+
_tracemalloc
6+
_weakref
7+
faulthandler
8+
posix
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Setup.dist doesn't have entries for all modules. This file defines
2+
# what's missing. The content here is reconstructed from logic in
3+
# setup.py and what was observed to execute in a normal build via setup.py.
4+
# We should audit this every time we upgrade CPython.
5+
6+
_bz2 _bz2module.c -lbz2
7+
_crypt _cryptmodule.c -lcrypt
8+
_curses _cursesmodule.c -DHAVE_NCURSESW=1 -I/tools/deps/include/ncursesw -L/tools/deps/lib -lncursesw
9+
_curses_panel _curses_panel.c -DHAVE_NCURSESW=1 -I/tools/deps/include/ncursesw -L/tools/deps/lib -lpanelw -lncursesw
10+
_ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c _ctypes/stgdict.c _ctypes/cfield.c -I/tools/deps/lib/libffi-3.2.1/include -lffi -ldl
11+
_decimal _decimal/_decimal.c _decimal/libmpdec/basearith.c _decimal/libmpdec/constants.c _decimal/libmpdec/context.c _decimal/libmpdec/convolute.c _decimal/libmpdec/crt.c _decimal/libmpdec/difradix2.c _decimal/libmpdec/fnt.c _decimal/libmpdec/fourstep.c _decimal/libmpdec/io.c _decimal/libmpdec/mpalloc.c _decimal/libmpdec/mpdecimal.c _decimal/libmpdec/numbertheory.c _decimal/libmpdec/sixstep.c _decimal/libmpdec/transpose.c -DCONFIG_64=1 -DASM=1 -IModules/_decimal/libmpdec
12+
_dbm _dbmmodule.c -DHAVE_BERKDB_H -DDB_DBM_HSEARCH -I/tools/deps/include -L/tools/deps/lib -ldb
13+
_elementtree _elementtree.c -DHAVE_EXPAT_CONFIG_H=1 -DXML_POOR_ENTROPY=1 -DUSE_PYEXPAT_CAPI -IModules/expat
14+
# Cannot build _gdbm due to use of bdb.
15+
#_gdbm _gdbmmodule.c -DHAVE_NDBM_H -I/tools/deps/include -L/tools/deps/lib -lgdbm
16+
_hashlib _hashopenssl.c -I/tools/deps/include -L/tools/deps/lib -lssl -lcrypto
17+
_json _json.c
18+
_lsprof _lsprof.c rotatingtree.c
19+
_lzma _lzmamodule.c -I/tools/deps/include -L/tools/deps/lib -llzma
20+
# TODO check setup.py logic for semaphore.c and possibly fix missing
21+
# dependency.
22+
_multiprocessing _multiprocessing/multiprocessing.c _multiprocessing/semaphore.c
23+
_opcode _opcode.c
24+
_posixshmem _multiprocessing/posixshmem.c -IModules/_multiprocessing -lrt
25+
_queue _queuemodule.c
26+
_sqlite3 _sqlite/cache.c _sqlite/connection.c _sqlite/cursor.c _sqlite/microprotocols.c _sqlite/module.c _sqlite/prepare_protocol.c _sqlite/row.c _sqlite/statement.c _sqlite/util.c -I/tools/deps/include -IModules/_sqlite -DMODULE_NAME=\"sqlite3\" -DSQLITE_OMIT_LOAD_EXTENSION=1 -L/tools/deps/lib -lsqlite3
27+
_ssl _ssl.c -I/tools/deps/include -lssl -lcrypto
28+
_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT -I/tools/deps/include/X11 -L/tools/deps/lib -ltcl8.6 -ltk8.6 -lX11 -lxcb -lXau
29+
_uuid _uuidmodule.c -I/tools/deps/include/uuid -luuid
30+
ossaudiodev ossaudiodev.c
31+
pyexpat pyexpat.c expat/xmlparse.c expat/xmlrole.c expat/xmltok.c -DHAVE_EXPAT_CONFIG_H=1 -DXML_POOR_ENTROPY=1 -DUSE_PYEXPAT_CAPI -IModules/expat
32+
# readline variant needs to come first because libreadline is in /tools/deps and is
33+
# picked up by build. We /could/ make libedit first. But since we employ a hack to
34+
# coerce use of libedit on Linux, it seems prudent for the build system to pick
35+
# up readline.
36+
readline VARIANT=readline readline.c -I/tools/deps/include -I/tools/deps/include/ncursesw -L/tools/deps/lib -lreadline -lncursesw
37+
readline VARIANT=libedit readline-libedit.c -DUSE_LIBEDIT=1 -I/tools/deps/libedit/include -I/tools/deps/libedit/include/ncursesw -L/tools/deps/libedit/lib -ledit -lncursesw

pythonbuild/downloads.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@
7070
"license_file": "LICENSE.cpython.txt",
7171
"python_tag": "cp39",
7272
},
73+
"cpython-3.10": {
74+
"url": "https://www.python.org/ftp/python/3.10.0/Python-3.10.0a5.tar.xz",
75+
"size": 18286124,
76+
"sha256": "0418e57e7036e219f1e6b6303b21e711f64cfd0fddb0894d8f19f37afffc5d4d",
77+
"version": "3.10.0a5",
78+
"licenses": ["Python-2.0", "CNRI-Python"],
79+
"license_file": "LICENSE.cpython.txt",
80+
"python_tag": "cp310",
81+
},
7382
"gcc": {
7483
"url": "https://ftp.gnu.org/gnu/gcc/gcc-10.2.0/gcc-10.2.0.tar.xz",
7584
"size": 75004144,

0 commit comments

Comments
 (0)