From a1276e90cdce80965e5c4260c154c8a65a50d79b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20R=C4=85czy?= Date: Tue, 1 Aug 2023 17:22:45 -0700 Subject: [PATCH] Refactor sconscripts to support target var --- SConstruct | 14 +++++++++----- rednose/SConscript | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/SConstruct b/SConstruct index 012ae7e..e5374b8 100644 --- a/SConstruct +++ b/SConstruct @@ -1,9 +1,16 @@ import os +import platform import subprocess import sysconfig import numpy as np arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() +if platform.system() == "Darwin": + target = "Darwin" +elif platform.system() == "Linux": + target = f"linux-{arch}" +else: + raise Exception("Unsupported platform: ", platform.system()) common = '' @@ -44,11 +51,8 @@ envCython = env.Clone() envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-shadow", "-Wno-deprecated-declarations"] envCython["LIBS"] = [] -if arch == "Darwin": +if target == "Darwin": envCython["LINKFLAGS"] = ["-bundle", "-undefined", "dynamic_lookup"] -elif arch == "aarch64": - envCython["LINKFLAGS"] = ["-shared"] - envCython["LIBS"] = [os.path.basename(python_path)] else: envCython["LINKFLAGS"] = ["-pthread", "-shared"] @@ -64,5 +68,5 @@ rednose_config = { }, } -Export('env', 'envCython', 'arch', 'rednose_config', 'common') +Export('env', 'envCython', 'rednose_config', 'common') SConscript(['#rednose/SConscript']) diff --git a/rednose/SConscript b/rednose/SConscript index 398b4b4..8aed356 100644 --- a/rednose/SConscript +++ b/rednose/SConscript @@ -1,4 +1,4 @@ -Import('env', 'envCython', 'arch', 'rednose_config', 'common') +Import('env', 'envCython', 'rednose_config', 'common') generated_folder = rednose_config['generated_folder']