@@ -59,6 +59,32 @@ def add_platform_config(*args, **kwargs):
5959 executable = 'python.exe' ,
6060)
6161
62+ add_platform_config (
63+ platform = 'macos' ,
64+ arch = 'x86_64' ,
65+ source_url = 'https://github.com/indygreg/python-build-standalone/releases/download/'
66+ '20231002/cpython-3.12.0+20231002-x86_64-apple-darwin-install_only.tar.gz' ,
67+ so_suffixes = ['.so' , '.dylib' ],
68+ ext_suffixes = ['.so' ],
69+ so_path = 'lib/libpython3.12.dylib' ,
70+ python_lib_dir = 'lib/python3.12' ,
71+ python_ext_dir = 'lib/python3.12/lib-dynload' ,
72+ executable = 'bin/python3.12' ,
73+ )
74+
75+ add_platform_config (
76+ platform = 'macos' ,
77+ arch = 'arm64' ,
78+ source_url = 'https://github.com/indygreg/python-build-standalone/releases/download/'
79+ '20231002/cpython-3.12.0+20231002-aarch64-apple-darwin-install_only.tar.gz' ,
80+ so_suffixes = ['.so' , '.dylib' ],
81+ ext_suffixes = ['.so' ],
82+ so_path = 'lib/libpython3.12.dylib' ,
83+ python_lib_dir = 'lib/python3.12' ,
84+ python_ext_dir = 'lib/python3.12/lib-dynload' ,
85+ executable = 'bin/python3.12' ,
86+ )
87+
6288
6389def fetch_python_for_platform (platform : str , arch : str , dest_dir : pathlib .Path ):
6490 config = platform_configs [(platform , arch )]
@@ -80,11 +106,21 @@ def prepare_for_platform(platform: str, arch: str,
80106 shutil .unpack_archive (src_dir / pathlib .Path (config .source_url ).name , extract_dir = src_dir )
81107
82108 src = src_dir / 'python'
109+ src_lib_path = src / config .so_path
110+ lib_filename = pathlib .Path (config .so_path ).name
111+
112+ if platform == 'macos' :
113+ # Rename the library id (which we depend on) to be in @rpath.
114+ # (it defaults to /install/lib/)
115+ subprocess .run (['install_name_tool' , '-id' , f'@rpath/{ lib_filename } ' , src_lib_path ], check = True )
83116
84117 dest_dir .mkdir (parents = True , exist_ok = True )
118+ shutil .copy2 (src_lib_path , dest_dir )
85119
86- shutil .copy2 (src / config .so_path , dest_dir )
87- subprocess .run (['strip' , '-s' , str (dest_dir / pathlib .Path (config .so_path ).name )], check = True )
120+ if platform == 'macos' :
121+ subprocess .run (['strip' , '-x' , dest_dir / lib_filename ], check = True )
122+ else :
123+ subprocess .run (['strip' , '-s' , dest_dir / lib_filename ], check = True )
88124
89125 if (src / config .python_ext_dir ).exists ():
90126 dest_ext_dir = dest_dir / 'python3.12' / 'lib-dynload'
0 commit comments