Skip to content

Commit

Permalink
Fix make_python.py on Apple Silicon + Sonoma 14.5
Browse files Browse the repository at this point in the history
Signed-off-by: Bernard Laberge <[email protected]>
  • Loading branch information
bernie-laberge committed Jul 28, 2024
1 parent 8a09f26 commit 8baa705
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/build/make_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def get_python_interpreter_args(python_home: str) -> List[str]:
python_interpreters = glob.glob(
os.path.join(python_home, python_name_pattern), recursive=True
)
python_interpreters += glob.glob(os.path.join(python_home, "bin", python_name_pattern))
python_interpreters += glob.glob(
os.path.join(python_home, "bin", python_name_pattern)
)

# sort put python# before python#-config
python_interpreters = sorted(
Expand Down Expand Up @@ -164,7 +166,9 @@ def patch_python_distribution(python_home: str) -> None:
shutil.move(failed_lib, failed_lib.replace("_failed.so", ".so"))
if OPENSSL_OUTPUT_DIR:
if platform.system() == "Darwin":
openssl_libs = glob.glob(os.path.join(OPENSSL_OUTPUT_DIR, "lib", "lib*.dylib*"))
openssl_libs = glob.glob(
os.path.join(OPENSSL_OUTPUT_DIR, "lib", "lib*.dylib*")
)
openssl_libs = [l for l in openssl_libs if os.path.islink(l) is False]

python_openssl_libs = []
Expand Down Expand Up @@ -196,7 +200,9 @@ def patch_python_distribution(python_home: str) -> None:
subprocess.run(install_name_tool_change_args).check_returncode()

elif platform.system() == "Linux":
openssl_libs = glob.glob(os.path.join(OPENSSL_OUTPUT_DIR, "lib", "lib*.so*"))
openssl_libs = glob.glob(
os.path.join(OPENSSL_OUTPUT_DIR, "lib", "lib*.so*")
)

for lib_path in openssl_libs:
print(f"Copying {lib_path} to the python home")
Expand Down Expand Up @@ -297,8 +303,12 @@ def test_python_distribution(python_home: str) -> None:

# Specify the location of the debug python import lib (eg. python39_d.lib)
python_include_dirs = os.path.join(tmp_python_home, "include")
python_lib = os.path.join(tmp_python_home, "libs", f"python{PYTHON_VERSION}_d.lib")
my_env["CMAKE_ARGS"] = f"-DPython_LIBRARY={python_lib} -DCMAKE_INCLUDE_PATH={python_include_dirs}"
python_lib = os.path.join(
tmp_python_home, "libs", f"python{PYTHON_VERSION}_d.lib"
)
my_env[
"CMAKE_ARGS"
] = f"-DPython_LIBRARY={python_lib} -DCMAKE_INCLUDE_PATH={python_include_dirs}"

opentimelineio_install_arg = python_interpreter_args + [
"-m",
Expand Down Expand Up @@ -440,7 +450,7 @@ def configure() -> None:

if OPENSSL_OUTPUT_DIR:
configure_args.append(f"--with-openssl={OPENSSL_OUTPUT_DIR}")

configure_args.append(f"--with-openssl-rpath={OPENSSL_OUTPUT_DIR}/lib")

if VARIANT == "Release":
configure_args.append("--enable-optimizations")
Expand Down Expand Up @@ -565,7 +575,6 @@ def build() -> None:
if OPENSSL_OUTPUT_DIR:
subprocess_env["LC_RPATH"] = os.path.join(OPENSSL_OUTPUT_DIR, "lib")


subprocess.run(
build_args,
cwd=SOURCE_DIR,
Expand Down Expand Up @@ -683,7 +692,13 @@ def install() -> None:

if platform.system() == "Windows":
# Major and minor version of Python without dots. E.g. 3.10.3 -> 310
parser.add_argument("--python-version", dest="python_version", type=str, required=True, default="")
parser.add_argument(
"--python-version",
dest="python_version",
type=str,
required=True,
default="",
)

parser.set_defaults(clean=False, configure=False, build=False, install=False)

Expand Down

0 comments on commit 8baa705

Please sign in to comment.