Skip to content

Commit

Permalink
Fix the builds on macOS (universal). Closes #11.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivorforce committed Oct 24, 2024
1 parent cb651ca commit 09bc08b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/util/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void system_quick_exit(int status) {
#ifdef WINDOWS_ENABLED
TerminateProcess(GetCurrentProcess(), status);
#else
std::quick_exit(status);
std::_Exit(0);
#endif
}

Expand Down
18 changes: 17 additions & 1 deletion tools/build/prepare_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ def add_platform_config(*args, **kwargs):
executable = 'python.exe',
)

add_platform_config(
platform = 'macos',
arch = 'universal',
source_url = 'https://github.com/indygreg/python-build-standalone/releases/download/'
'20231002/cpython-3.12.0+20231002-x86_64-apple-darwin-install_only.tar.gz',
so_suffixes = ['.os'],
ext_suffixes = ['.os'],
so_path = 'lib/libpython3.12.dylib',
python_lib_dir = 'lib/python3.12',
python_ext_dir = 'lib/python3.12/lib-dynload',
executable = 'bin/python3.12',
)


def fetch_python_for_platform(platform: str, arch: str, dest_dir: pathlib.Path):
config = platform_configs[(platform, arch)]
Expand All @@ -84,7 +97,10 @@ def prepare_for_platform(platform: str, arch: str,
dest_dir.mkdir(parents=True, exist_ok=True)

shutil.copy2(src / config.so_path, dest_dir)
subprocess.run(['strip', '-s', str(dest_dir / pathlib.Path(config.so_path).name)], check=True)
if platform == 'macos':
subprocess.run(['strip', '-x', str(dest_dir / pathlib.Path(config.so_path).name)], check=True)
else:
subprocess.run(['strip', '-s', str(dest_dir / pathlib.Path(config.so_path).name)], check=True)

if (src / config.python_ext_dir).exists():
dest_ext_dir = dest_dir / 'python3.12' / 'lib-dynload'
Expand Down
2 changes: 1 addition & 1 deletion tools/build/python_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def normpath(path: str) -> str:

config_vars.link_libs = _stable_unique([
*itertools.chain(*(
(v.removeprefix('-l') for v in value.split())
(v.removeprefix('-l') for v in value.split() if v.startswith('-l'))
for name in ('LIBS', 'SYSLIBS')
if (value := sysconfig_vars.get(name))
)),
Expand Down

0 comments on commit 09bc08b

Please sign in to comment.