8000 unix: support CPython 3.10 macOS builds · adiantek/python-build-standalone@774fb47 · GitHub
Skip to content

Commit 774fb47

Browse files
committed
unix: support CPython 3.10 macOS builds
This seems pretty straightfoward.
1 parent acd4092 commit 774fb47

File tree

8 files changed

+148
-3
lines changed

8 files changed

+148
-3
lines changed

.github/workflows/apple.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ jobs:
130130
py: 'cpython-3.9'
131131
optimizations: 'lto'
132132

133+
- target_triple: 'aarch64-apple-darwin'
134+
py: 'cpython-3.10'
135+
optimizations: 'debug'
136+
- target_triple: 'aarch64-apple-darwin'
137+
py: 'cpython-3.10'
138+
optimizations: 'noopt'
139+
- target_triple: 'aarch64-apple-darwin'
140+
py: 'cpython-3.10'
141+
optimizations: 'lto'
142+
133143
# macOS on Intel hardware. This is pretty straightforward. We exclude
134144
# noopt because it doesn't provide any compelling advantages over PGO
135145
# or LTO builds.
@@ -159,6 +169,19 @@ jobs:
159169
py: 'cpython-3.9'
160170
optimizations: 'pgo+lto'
161171

172+
- target_triple: 'x86_64-apple-darwin'
173+
py: 'cpython-3.10'
174+
optimizations: 'debug'
175+
- target_triple: 'x86_64-apple-darwin'
176+
py: 'cpython-3.10'
177+
optimizations: 'lto'
178+
- target_triple: 'x86_64-apple-darwin'
179+
py: 'cpython-3.10'
180+
optimizations: 'pgo'
181+
- target_triple: 'x86_64-apple-darwin'
182+
py: 'cpython-3.10'
183+
optimizations: 'pgo+lto'
184+
162185
# iOS targeting mobile hardware. Can't do PGO during cross-compiles.
163186
# Can't cross-compile until Python 3.9.
164187
- target_triple: 'aarch64-apple-ios'
@@ -244,6 +267,12 @@ jobs:
244267
path: dist/*
245268

246269
install-only:
270+
strategy:
271+
fail-fast: false
272+
matrix:
273+
version:
274+
- '3.9'
275+
- '3.10'
247276
needs:
248277
- build
249278
runs-on: 'ubuntu-20.04'
@@ -260,7 +289,7 @@ jobs:
260289
- name: Download Python
261290
uses: actions/download-artifact@v2
262291
with:
263-
name: cpython-3.9-x86_64-apple-darwin
292+
name: 'cpython-${{ matrix.version }}-x86_64-apple-darwin'
264293

265294
- name: Repack Distribution
266295
run: |
@@ -269,5 +298,5 @@ jobs:
269298
- name: Upload Distribution
270299
uses: actions/upload-artifact@v2
271300
with:
272-
name: cpython-install-only
301+
name: 'cpython-${{ matrix.version }}-install-only'
273302
path: cpython-*.tar.gz

cpython-unix/build-cpython.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ diff --git a/Makefile.pre.in b/Makefile.pre.in
398398
platform: $(BUILDPYTHON) pybuilddir.txt
399399
$(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform
400400
EOF
401-
else
401+
elif [ "${PYTHON_MAJMIN_VERSION}" = "3.9" ]; then
402402
patch -p1 <<"EOF"
403403
diff --git a/Makefile.pre.in b/Makefile.pre.in
404404
--- a/Makefile.pre.in
@@ -408,6 +408,21 @@ diff --git a/Makefile.pre.in b/Makefile.pre.in
408408
# Build the interpreter
409409
$(BUILDPYTHON): Programs/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) $(EXPORTSYMS)
410410
- $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS)
411+
+ $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(SYSLIBS)
412+
413+
platform: $(BUILDPYTHON) pybuilddir.txt
414+
$(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform
415+
EOF
416+
else
417+
patch -p1 <<"EOF"
418+
diff --git a/Makefile.pre.in b/Makefile.pre.in
419+
--- a/Makefile.pre.in
420+
+++ b/Makefile.pre.in
421+
@@ -563,7 +563,7 @@ clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c
422+
423+
# Build the interpreter
424+
$(BUILDPYTHON): Programs/python.o $(LIBRARY_DEPS)
425+
- $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS)
411426
+ $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(SYSLIBS)
412427
413428
platform: $(BUILDPYTHON) pybuilddir.txt
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# We don't support GDBM because it is GPL v3.
2+
_gdbm
3+
# Not available on macOS.
4+
nis
5+
# Not available on macOS.
6+
ossaudiodev
7+
# Not available on macOS.
8+
spwd
9+
10+
# Ideally this would only be disabled while cross-compiling. We can't build it
11+
# as a built-in extension via static-modules. And when letting setup.py build
12+
# it, it builds for the host architecture during cross-builds, which upsets
13+
# our validation script when it screens for the target machine type of
14+
# binaries. So just disable it.
15+
_testcapi
16+
17+
# Similar story as _testcapi. The extension exists to test the limited API,
18+
# which we don't really care about. Statically building it runs into problems
19+
# and cross-compiling emits wrong machine type when built via setup.py.
20+
xxlimited
21+
xxlimited_35
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# We don't support GDBM because it is GPL v3.
2+
_gdbm
3+
# Not available on macOS.
4+
nis
5+
# Not available on macOS.
6+
ossaudiodev
7+
# Not available on macOS.
8+
spwd
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: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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
8+
# We link against the system ncurses on macOS for simplicity. There is no ncursesw
9+
# but it is Unicode aware.
10+
_curses _cursesmodule.c -DHAVE_NCURSESW=1 -D_XOPEN_SOURCE_EXTENDED=1 -lncurses
11+
_curses_panel _curses_panel.c -DHAVE_NCURSESW=1 -D_XOPEN_SOURCE_EXTENDED=1 -lpanel -lncurses
12+
_ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c _ctypes/darwin/dlfcn_simple.c _ctypes/malloc_closure.c _ctypes/stgdict.c _ctypes/cfield.c -DMACOSX -DUSING_MALLOC_CLOSURE_DOT_C=1 -DHAVE_FFI_PREP_CIF_VAR=1 -DHAVE_FFI_PREP_CLOSURE_LOC=1 -DHAVE_FFI_CLOSURE_ALLOC=1 -I_ctypes/darwin -lffi -ldl
13+
_ctypes_test _ctypes/_ctypes_test.c -lm
14+
_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 -DUNIVERSAL=1 -IModules/_decimal/libmpdec
15+
# macOS ships with an ndbm implementation in libSystem. CPython's setup.py will
16+
# use it unless an ndbl or gdbm_compat library is present.
17+
_dbm _dbmmodule.c -DHAVE_NDBM_H
18+
_elementtree _elementtree.c -DHAVE_EXPAT_CONFIG_H=1 -DXML_POOR_ENTROPY=1 -DUSE_PYEXPAT_CAPI -IModules/expat
19+
_hashlib _hashopenssl.c -lcrypto
20+
_json _json.c
21+
_lsprof _lsprof.c rotatingtree.c
22+
_lzma _lzmamodule.c -llzma
23+
# TODO check setup.py logic for semaphore.c and possibly fix missing
24+
# dependency.
25+
_multiprocessing _multiprocessing/multiprocessing.c _multiprocessing/semaphore.c
26+
_opcode _opcode.c
27+
_posixshmem _multiprocessing/posixshmem.c -IModules/_multiprocessing
28+
_queue _queuemodule.c
29+
_scproxy _scproxy.c -framework SystemConfiguration -framework CoreFoundation
30+
_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 -IModules/_sqlite -DMODULE_NAME=\"sqlite3\" -DSQLITE_OMIT_LOAD_EXTENSION=1 -lsqlite3
31+
_ssl _ssl.c -lssl -lcrypto
32+
_testbuffer _testbuffer.c
33+
_testimportmultiple _testimportmultiple.c
34+
_testinternalcapi _testinternalcapi.c -DPy_BUILD_CORE_MODULE
35+
_testmultiphase _testmultiphase.c
36+
# CoreFoundation isn't a directory dependency but is a dependency of libtcl and libtk.
37+
_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT -framework AppKit -framework ApplicationServices -framework Carbon -framework CoreFoundation -framework CoreServices -framework CoreGraphics -framework IOKit -ltcl8.6 -ltk8.6
38+
_uuid _uuidmodule.c -luuid
39+
_xxsubinterpreters _xxsubinterpretersmodule.c
40+
_xxtestfuzz _xxtestfuzz/_xxtestfuzz.c _xxtestfuzz/fuzzer.c
41+
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
42+
readline readline.c -ledit -lncurses

cpython-unix/targets.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ aarch64-apple-darwin:
5757
- macos
5858
pythons_supported:
5959
- '3.9'
60+
- '3.10'
6061
needs_toolchain: true
6162
host_cc: clang
6263
host_cxx: clang++
@@ -451,6 +452,7 @@ x86_64-apple-darwin:
451452
pythons_supported:
452453
- '3.8'
453454
- '3.9'
455+
- '3.10'
454456
needs_toolchain: true
455457
apple_sdk_platform: macosx
456458
host_cc: clang

src/main.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,16 @@ static DARWIN_ALLOWED_DYLIBS: Lazy<Vec<MachOAllowedDylib>> = Lazy::new(|| {
200200
max_compatibility_version: "3.9.0".try_into().unwrap(),
201201
required: false,
202202
},
203+
MachOAllowedDylib {
204+
name: "@executable_path/../lib/libpython3.10.dylib".to_string(),
205+
max_compatibility_version: "3.10.0".try_into().unwrap(),
206+
required: false,
207+
},
208+
MachOAllowedDylib {
209+
name: "@executable_path/../lib/libpython3.10d.dylib".to_string(),
210+
max_compatibility_version: "3.10.0".try_into().unwrap(),
211+
required: false,
212+
},
203213
MachOAllowedDylib {
204214
name: "/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit".to_string(),
205215
max_compatibility_version: "45.0.0".try_into().unwrap(),
@@ -298,6 +308,16 @@ static IOS_ALLOWED_DYLIBS: Lazy<Vec<MachOAllowedDylib>> = Lazy::new(|| {
298308
max_compatibility_version: "3.9.0".try_into().unwrap(),
299309
required: false,
300310
},
311+
MachOAllowedDylib {
312+
name: "@executable_path/../lib/libpython3.10.dylib".to_string(),
313+
max_compatibility_version: "3.10.0".try_into().unwrap(),
314+
required: false,
315+
},
316+
MachOAllowedDylib {
317+
name: "@executable_path/../lib/libpython3.10d.dylib".to_string(),
318+
max_compatibility_version: "3.10.0".try_into().unwrap(),
319+
required: false,
320+
},
301321
// For some reason, CoreFoundation is present in debug/noopt builds but not
302322
// LTO builds.
303323
MachOAllowedDylib {

0 commit comments

Comments
 (0)
0