Include build-all.py to black formatter

This commit is contained in:
Andrej730
2025-07-25 17:19:16 +05:00
parent 99cdc4da35
commit 9004c5d153
2 changed files with 307 additions and 214 deletions
+275 -185
View File
@@ -67,6 +67,7 @@ import sysconfig
# @todo temporary for expired mpfr.org certificate on 2023-04-08 # @todo temporary for expired mpfr.org certificate on 2023-04-08
import ssl import ssl
ssl._create_default_https_context = ssl._create_unverified_context ssl._create_default_https_context = ssl._create_unverified_context
import time import time
@@ -95,7 +96,7 @@ OPENCOLLADA_VERSION = "v1.6.68"
HDF5_VERSION = "1.12.1" HDF5_VERSION = "1.12.1"
GMP_VERSION = "6.2.1" GMP_VERSION = "6.2.1"
MPFR_VERSION = "3.1.6" # latest is 4.1.0 MPFR_VERSION = "3.1.6" # latest is 4.1.0
CGAL_VERSION = "5.6.x-branch" CGAL_VERSION = "5.6.x-branch"
USD_VERSION = "23.05" USD_VERSION = "23.05"
TBB_VERSION = "2021.9.0" TBB_VERSION = "2021.9.0"
@@ -117,21 +118,25 @@ wget = "wget"
strip = "strip" strip = "strip"
explicit_targets = [s for s in sys.argv[1:] if not s.startswith("-")] explicit_targets = [s for s in sys.argv[1:] if not s.startswith("-")]
flags = set(s.lstrip('-') for s in sys.argv[1:] if s.startswith("-")) flags = set(s.lstrip("-") for s in sys.argv[1:] if s.startswith("-"))
# Helper function for coloured printing # Helper function for coloured printing
NO_COLOR = "\033[0m" # <ref>http://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux</ref> NO_COLOR = (
"\033[0m" # <ref>http://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux</ref>
)
BLACK_ON_WHITE = "\033[0;30;107m" BLACK_ON_WHITE = "\033[0;30;107m"
RED = "\033[31m" RED = "\033[31m"
GREEN = "\033[32m" GREEN = "\033[32m"
YELLOW = "\033[33m" YELLOW = "\033[33m"
MAGENTA = "\033[35m" MAGENTA = "\033[35m"
def cecho(message, color=NO_COLOR): def cecho(message, color=NO_COLOR):
"""Logs message `message` in color `color`.""" """Logs message `message` in color `color`."""
logger.info(f"{color}{message}\033[0m") logger.info(f"{color}{message}\033[0m")
def which(cmd): def which(cmd):
for path in os.getenv("PATH").split(":"): for path in os.getenv("PATH").split(":"):
if os.path.exists(path) and cmd in os.listdir(path): if os.path.exists(path) and cmd in os.listdir(path):
@@ -170,11 +175,17 @@ BUILD_CFG = os.getenv("BUILD_CFG", "RelWithDebInfo")
# Print build configuration information # Print build configuration information
cecho (f"""This script fetches and builds {PROJECT_NAME} and its dependencies cecho(
""", BLACK_ON_WHITE) f"""This script fetches and builds {PROJECT_NAME} and its dependencies
cecho("""Script configuration: """,
BLACK_ON_WHITE,
)
cecho(
"""Script configuration:
""", GREEN) """,
GREEN,
)
cecho(f"""* USE_OCCT = {USE_OCCT}""", MAGENTA) cecho(f"""* USE_OCCT = {USE_OCCT}""", MAGENTA)
if USE_OCCT: if USE_OCCT:
cecho(" - Compiling against official Open Cascade") cecho(" - Compiling against official Open Cascade")
@@ -183,42 +194,48 @@ else:
cecho(f"* Dependency Directory = {DEPS_DIR}", MAGENTA) cecho(f"* Dependency Directory = {DEPS_DIR}", MAGENTA)
cecho(f" - The directory where {PROJECT_NAME} dependencies are installed.") cecho(f" - The directory where {PROJECT_NAME} dependencies are installed.")
cecho(f"* Build Config Type = {BUILD_CFG}", MAGENTA) cecho(f"* Build Config Type = {BUILD_CFG}", MAGENTA)
cecho(""" - The used build configuration type for the dependencies. cecho(
Defaults to RelWithDebInfo if not specified.""") """ - The used build configuration type for the dependencies.
Defaults to RelWithDebInfo if not specified."""
)
if BUILD_CFG == "MinSizeRel": if BUILD_CFG == "MinSizeRel":
cecho(" WARNING: MinSizeRel build can suffer from a significant performance loss.", RED) cecho(" WARNING: MinSizeRel build can suffer from a significant performance loss.", RED)
cecho(f"* IFCOS_NUM_BUILD_PROCS = {IFCOS_NUM_BUILD_PROCS}", MAGENTA) cecho(f"* IFCOS_NUM_BUILD_PROCS = {IFCOS_NUM_BUILD_PROCS}", MAGENTA)
cecho(""" - How many compiler processes may be run in parallel. cecho(
""") """ - How many compiler processes may be run in parallel.
"""
)
dependency_tree = { dependency_tree = {
'IfcParse': ('boost', 'libxml2', 'hdf5'), "IfcParse": ("boost", "libxml2", "hdf5"),
'IfcGeom': ('IfcParse', 'occ', 'json', 'cgal', 'eigen'), "IfcGeom": ("IfcParse", "occ", "json", "cgal", "eigen"),
'IfcConvert': ('IfcGeom',), "IfcConvert": ("IfcGeom",),
'OpenCOLLADA': ('libxml2', 'pcre'), "OpenCOLLADA": ("libxml2", "pcre"),
'IfcGeomServer': ('IfcGeom',), "IfcGeomServer": ("IfcGeom",),
'IfcOpenShell-Python': ('python', 'swig', 'IfcGeom'), "IfcOpenShell-Python": ("python", "swig", "IfcGeom"),
'swig': ('pcre',), "swig": ("pcre",),
'boost': (), "boost": (),
'libxml2': (), "libxml2": (),
'python': (), "python": (),
'occ': ('freetype',), "occ": ("freetype",),
'pcre': (), "pcre": (),
'json': (), "json": (),
'hdf5': (), "hdf5": (),
'cgal': (), "cgal": (),
'eigen': (), "eigen": (),
'freetype': (), "freetype": (),
# 'usd': ('boost', 'oneTBB') # 'usd': ('boost', 'oneTBB')
} }
def v(dep): def v(dep):
yield dep yield dep
for d in dependency_tree[dep]: for d in dependency_tree[dep]:
for x in v(d): for x in v(d):
yield x yield x
if "v" in flags: if "v" in flags:
logger.setLevel(logging.DEBUG) logger.setLevel(logging.DEBUG)
@@ -235,14 +252,14 @@ LIBRARY_EXT = "a" if BUILD_STATIC else "so"
PIC = "-fPIC" if BUILD_STATIC else "" PIC = "-fPIC" if BUILD_STATIC else ""
if any(f.startswith("py-") for f in flags): if any(f.startswith("py-") for f in flags):
PYTHON_VERSIONS = [pyv for pyv in PYTHON_VERSIONS if "py-%s" % "".join(pyv.split('.')[0:2]) in flags] PYTHON_VERSIONS = [pyv for pyv in PYTHON_VERSIONS if "py-%s" % "".join(pyv.split(".")[0:2]) in flags]
if len(explicit_targets): if len(explicit_targets):
targets = set(sum((list(v(target)) for target in explicit_targets), [])) targets = set(sum((list(v(target)) for target in explicit_targets), []))
else: else:
targets = set(dependency_tree.keys()) targets = set(dependency_tree.keys())
targets = set(t for t in targets if 'without-%s' % t.lower() not in flags) targets = set(t for t in targets if "without-%s" % t.lower() not in flags)
print("Building:", *sorted(targets, key=lambda t: len(list(v(t))))) print("Building:", *sorted(targets, key=lambda t: len(list(v(t)))))
@@ -268,11 +285,12 @@ logger.info(f"using command log file '{LOG_FILE}'")
# Causing havoc in python 3.11 build # Causing havoc in python 3.11 build
try: try:
del os.environ['__PYVENV_LAUNCHER__'] del os.environ["__PYVENV_LAUNCHER__"]
except: pass except:
pass
def run(cmds, cwd=None, can_fail=False): def run(cmds, cwd=None, can_fail=False):
""" """
Wraps `subprocess.Popen.communicate()` and logs the command being executed, Wraps `subprocess.Popen.communicate()` and logs the command being executed,
sets up logging `stderr` to `LOG_FILE` (in append mode) and returns stdout sets up logging `stderr` to `LOG_FILE` (in append mode) and returns stdout
@@ -296,6 +314,7 @@ def run(cmds, cwd=None, can_fail=False):
return stdout.strip() return stdout.strip()
if platform.system() == "Darwin": if platform.system() == "Darwin":
if run(["sw_vers", "-productVersion"]) >= "11.": if run(["sw_vers", "-productVersion"]) >= "11.":
# Apparently not supported # Apparently not supported
@@ -316,7 +335,9 @@ BOOST_LOCATION = f"https://github.com/boostorg/boost/releases/download/boost-{BO
def run_autoconf(arg1, configure_args, cwd): def run_autoconf(arg1, configure_args, cwd):
configure_path = os.path.realpath(os.path.join(cwd, "..", "configure")) configure_path = os.path.realpath(os.path.join(cwd, "..", "configure"))
if not os.path.exists(configure_path): if not os.path.exists(configure_path):
run([bash, "./autogen.sh"], cwd=os.path.realpath(os.path.join(cwd, ".."))) # only run autogen.sh in the directory it is located and use cwd to achieve that in order to not mess up things run(
[bash, "./autogen.sh"], cwd=os.path.realpath(os.path.join(cwd, ".."))
) # only run autogen.sh in the directory it is located and use cwd to achieve that in order to not mess up things
# Using `sh` over `bash` fixes issues with building swig # Using `sh` over `bash` fixes issues with building swig
prefix = os.path.realpath(f"{DEPS_DIR}/install/{arg1}") prefix = os.path.realpath(f"{DEPS_DIR}/install/{arg1}")
@@ -324,7 +345,17 @@ def run_autoconf(arg1, configure_args, cwd):
if "wasm" in flags: if "wasm" in flags:
wasm.append("emconfigure") wasm.append("emconfigure")
run([*wasm, "/bin/sh", "../configure", *(["--host=wasm32"] if "wasm" in flags and not any(s.startswith('--host') for s in configure_args) else []), *configure_args, f"--prefix={prefix}"], cwd=cwd) run(
[
*wasm,
"/bin/sh",
"../configure",
*(["--host=wasm32"] if "wasm" in flags and not any(s.startswith("--host") for s in configure_args) else []),
*configure_args,
f"--prefix={prefix}",
],
cwd=cwd,
)
def run_cmake(arg1, cmake_args, cmake_dir=None, cwd=None): def run_cmake(arg1, cmake_args, cmake_dir=None, cwd=None):
@@ -337,7 +368,20 @@ def run_cmake(arg1, cmake_args, cmake_dir=None, cwd=None):
if "wasm" in flags: if "wasm" in flags:
wasm.append("emcmake") wasm.append("emcmake")
run([*wasm, "cmake", P, *cmake_args, f"-DCMAKE_BUILD_TYPE={BUILD_CFG}", f"-DBUILD_SHARED_LIBS={OFF_ON[not BUILD_STATIC]}", f"-DCMAKE_CXX_FLAGS='{os.environ['CXXFLAGS']}'", f"-DCMAKE_C_FLAGS='{os.environ['CFLAGS']}'", f"-DCMAKE_SHARED_LINKER_FLAGS={os.environ['LDFLAGS']}"], cwd=cwd) run(
[
*wasm,
"cmake",
P,
*cmake_args,
f"-DCMAKE_BUILD_TYPE={BUILD_CFG}",
f"-DBUILD_SHARED_LIBS={OFF_ON[not BUILD_STATIC]}",
f"-DCMAKE_CXX_FLAGS='{os.environ['CXXFLAGS']}'",
f"-DCMAKE_C_FLAGS='{os.environ['CFLAGS']}'",
f"-DCMAKE_SHARED_LINKER_FLAGS={os.environ['LDFLAGS']}",
],
cwd=cwd,
)
def git_clone_or_pull_repository(clone_url, target_dir, revision=None): def git_clone_or_pull_repository(clone_url, target_dir, revision=None):
@@ -363,7 +407,21 @@ def git_clone_or_pull_repository(clone_url, target_dir, revision=None):
run([git, "checkout", revision], cwd=target_dir) run([git, "checkout", revision], cwd=target_dir)
def build_dependency(name, mode, build_tool_args, download_url, download_name, download_tool=download_tool_default, revision=None, patch=None, shell=None, pre_compile_subs=[], additional_files={}, no_append_name=False, **kwargs): def build_dependency(
name,
mode,
build_tool_args,
download_url,
download_name,
download_tool=download_tool_default,
revision=None,
patch=None,
shell=None,
pre_compile_subs=[],
additional_files={},
no_append_name=False,
**kwargs,
):
"""Handles building of dependencies with different tools (which are """Handles building of dependencies with different tools (which are
distinguished with the `mode` argument. `build_tool_args` is expected to be distinguished with the `mode` argument. `build_tool_args` is expected to be
a list which is necessary in order to not mess up quoting of compiler and a list which is necessary in order to not mess up quoting of compiler and
@@ -392,10 +450,12 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d
break break
except ConnectionError as e: except ConnectionError as e:
print(e, "... retrying...") print(e, "... retrying...")
time.sleep(30.) time.sleep(30.0)
continue continue
else: else:
logger.info(f"Download '{download_path}' already exists, assuming it's an undamaged download and that it has been extracted if possible, skipping") logger.info(
f"Download '{download_path}' already exists, assuming it's an undamaged download and that it has been extracted if possible, skipping"
)
elif download_tool == download_tool_git: elif download_tool == download_tool_git:
logger.info(f"\rChecking {name}... ") logger.info(f"\rChecking {name}... ")
git_clone_or_pull_repository(download_url, target_dir=os.path.join(build_dir, download_name), revision=revision) git_clone_or_pull_repository(download_url, target_dir=os.path.join(build_dir, download_name), revision=revision)
@@ -419,9 +479,11 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d
download_tarfile = tarfile.open(name=download_tarfile_path, mode=f"r:{compr}") download_tarfile = tarfile.open(name=download_tarfile_path, mode=f"r:{compr}")
# tarfile seriously doesn't have a function to retrieve the root directory more easily # tarfile seriously doesn't have a function to retrieve the root directory more easily
extract_dir_name = os.path.commonprefix([x for x in download_tarfile.getnames() if x != "."]) extract_dir_name = os.path.commonprefix([x for x in download_tarfile.getnames() if x != "."])
#run([tar, "--exclude=\"*/*\"", "-tf", download_name], cwd=build_dir).strip() no longer works # run([tar, "--exclude=\"*/*\"", "-tf", download_name], cwd=build_dir).strip() no longer works
if extract_dir_name is None: if extract_dir_name is None:
extract_dir_name = run([bash, "-c", f"tar -tf {download_name} 2> /dev/null | head -n 1 | cut -f1 -d /"], cwd=build_dir) extract_dir_name = run(
[bash, "-c", f"tar -tf {download_name} 2> /dev/null | head -n 1 | cut -f1 -d /"], cwd=build_dir
)
extract_dir = os.path.join(build_dir, extract_dir_name) extract_dir = os.path.join(build_dir, extract_dir_name)
if not os.path.exists(extract_dir): if not os.path.exists(extract_dir):
run([tar, "-xf", download_name], cwd=build_dir) run([tar, "-xf", download_name], cwd=build_dir)
@@ -436,7 +498,8 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d
for p in patch: for p in patch:
patch_abs = os.path.abspath(os.path.join(os.path.dirname(__file__), p)) patch_abs = os.path.abspath(os.path.join(os.path.dirname(__file__), p))
if os.path.exists(patch_abs): if os.path.exists(patch_abs):
try: run(["patch", "-p1", "--batch", "--forward", "-i", patch_abs], cwd=extract_dir) try:
run(["patch", "-p1", "--batch", "--forward", "-i", patch_abs], cwd=extract_dir)
except Exception as e: except Exception as e:
# Assert that the patch has already been applied # Assert that the patch has already been applied
run(["patch", "-p1", "--batch", "--reverse", "--dry-run", "-i", patch_abs], cwd=extract_dir) run(["patch", "-p1", "--batch", "--reverse", "--dry-run", "-i", patch_abs], cwd=extract_dir)
@@ -445,11 +508,14 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d
sp.run(shell, shell=True, check=True, cwd=extract_dir) sp.run(shell, shell=True, check=True, cwd=extract_dir)
if mode == "ctest": if mode == "ctest":
run(["ctest", "-S", "HDF5config.cmake,BUILD_GENERATOR=Unix", "-C", BUILD_CFG, "-V", "-O", "hdf5.log"], cwd=extract_dir) run(
run([tar, "-xf", kwargs["ctest_result"] + ".tar.gz"], cwd=os.path.join(extract_dir, 'build')) ["ctest", "-S", "HDF5config.cmake,BUILD_GENERATOR=Unix", "-C", BUILD_CFG, "-V", "-O", "hdf5.log"],
cwd=extract_dir,
)
run([tar, "-xf", kwargs["ctest_result"] + ".tar.gz"], cwd=os.path.join(extract_dir, "build"))
shutil.copytree( shutil.copytree(
os.path.join(extract_dir, "build", kwargs["ctest_result"], kwargs["ctest_result_path"]), os.path.join(extract_dir, "build", kwargs["ctest_result"], kwargs["ctest_result_path"]),
os.path.join(DEPS_DIR, "install", name) os.path.join(DEPS_DIR, "install", name),
) )
elif mode != "bjam": elif mode != "bjam":
extract_build_dir = os.path.join(extract_dir, "build") extract_build_dir = os.path.join(extract_dir, "build")
@@ -465,10 +531,10 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d
else: else:
raise ValueError() raise ValueError()
for fn, before, after in pre_compile_subs: for fn, before, after in pre_compile_subs:
with open(os.path.join(extract_dir, fn), 'r') as f: with open(os.path.join(extract_dir, fn), "r") as f:
s = f.read() s = f.read()
s = s.replace(before, after) s = s.replace(before, after)
with open(os.path.join(extract_dir, fn), 'w') as f: with open(os.path.join(extract_dir, fn), "w") as f:
f.write(s) f.write(s)
logger.info(f"\rBuilding {name}... ") logger.info(f"\rBuilding {name}... ")
run([make, f"-j{IFCOS_NUM_BUILD_PROCS}", "VERBOSE=1"], cwd=extract_build_dir) run([make, f"-j{IFCOS_NUM_BUILD_PROCS}", "VERBOSE=1"], cwd=extract_build_dir)
@@ -481,12 +547,15 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d
logger.info(f"\rBuilding {name}... ") logger.info(f"\rBuilding {name}... ")
run(["./b2", f"-j{IFCOS_NUM_BUILD_PROCS}"] + build_tool_args, cwd=extract_dir, can_fail="wasm" in flags) run(["./b2", f"-j{IFCOS_NUM_BUILD_PROCS}"] + build_tool_args, cwd=extract_dir, can_fail="wasm" in flags)
logger.info(f"\rInstalling {name}... ") logger.info(f"\rInstalling {name}... ")
shutil.copytree(os.path.join(extract_dir, "boost"), os.path.join(DEPS_DIR, "install", f"boost-{BOOST_VERSION}", "boost")) shutil.copytree(
os.path.join(extract_dir, "boost"), os.path.join(DEPS_DIR, "install", f"boost-{BOOST_VERSION}", "boost")
)
logger.info(f"\rInstalled {name} \n") logger.info(f"\rInstalled {name} \n")
if "diskcleanup" in flags: if "diskcleanup" in flags:
shutil.rmtree(build_dir, ignore_errors=True) shutil.rmtree(build_dir, ignore_errors=True)
cecho("Collecting dependencies:", GREEN) cecho("Collecting dependencies:", GREEN)
# Set compiler flags for 32bit builds on 64bit system # Set compiler flags for 32bit builds on 64bit system
@@ -509,8 +578,8 @@ LDFLAGS = os.environ.get("LDFLAGS", "")
ADDITIONAL_ARGS_STR = " ".join(ADDITIONAL_ARGS) ADDITIONAL_ARGS_STR = " ".join(ADDITIONAL_ARGS)
if "wasm" in flags: if "wasm" in flags:
CFLAGS_MINIMAL = CXXFLAGS_MINIMAL = CFLAGS = CXXFLAGS = os.environ['SIDE_MODULE_CFLAGS'] CFLAGS_MINIMAL = CXXFLAGS_MINIMAL = CFLAGS = CXXFLAGS = os.environ["SIDE_MODULE_CFLAGS"]
LDFLAGS = os.environ['SIDE_MODULE_LDFLAGS'] LDFLAGS = os.environ["SIDE_MODULE_LDFLAGS"]
elif sp.call([bash, "-c", "ld --gc-sections 2>&1 | grep -- --gc-sections &> /dev/null"]) != 0: elif sp.call([bash, "-c", "ld --gc-sections 2>&1 | grep -- --gc-sections &> /dev/null"]) != 0:
CXXFLAGS_MINIMAL = f"{CXXFLAGS} {PIC} {ADDITIONAL_ARGS_STR}" CXXFLAGS_MINIMAL = f"{CXXFLAGS} {PIC} {ADDITIONAL_ARGS_STR}"
CFLAGS_MINIMAL = f"{CFLAGS} {PIC} {ADDITIONAL_ARGS_STR}" CFLAGS_MINIMAL = f"{CFLAGS} {PIC} {ADDITIONAL_ARGS_STR}"
@@ -528,8 +597,8 @@ else:
CXXFLAGS = f"{CXXFLAGS} {PIC} -fvisibility=hidden -fvisibility-inlines-hidden {ADDITIONAL_ARGS_STR}" CXXFLAGS = f"{CXXFLAGS} {PIC} -fvisibility=hidden -fvisibility-inlines-hidden {ADDITIONAL_ARGS_STR}"
CFLAGS = f"{CFLAGS} {PIC} -fvisibility=hidden -fvisibility-inlines-hidden {ADDITIONAL_ARGS_STR}" CFLAGS = f"{CFLAGS} {PIC} -fvisibility=hidden -fvisibility-inlines-hidden {ADDITIONAL_ARGS_STR}"
else: else:
CXXFLAGS=CXXFLAGS_MINIMAL CXXFLAGS = CXXFLAGS_MINIMAL
CFLAGS=CFLAGS_MINIMAL CFLAGS = CFLAGS_MINIMAL
LDFLAGS = f"{LDFLAGS} {ADDITIONAL_ARGS_STR}" LDFLAGS = f"{LDFLAGS} {ADDITIONAL_ARGS_STR}"
if "lto" in flags: if "lto" in flags:
@@ -545,7 +614,7 @@ os.environ["LDFLAGS"] = LDFLAGS
# @tfk: this is no longer needed # @tfk: this is no longer needed
# build_dependency(name="cmake-%s" % (CMAKE_VERSION,), mode="autoconf", build_tool_args=[], download_url="https://cmake.org/files/v%s" % (CMAKE_VERSION_2,), download_name="cmake-%s.tar.gz" % (CMAKE_VERSION,)) # build_dependency(name="cmake-%s" % (CMAKE_VERSION,), mode="autoconf", build_tool_args=[], download_url="https://cmake.org/files/v%s" % (CMAKE_VERSION_2,), download_name="cmake-%s.tar.gz" % (CMAKE_VERSION,))
if 'hdf5' in targets: if "hdf5" in targets:
# not supported # not supported
orig = [os.environ[f] for f in compiler_flags] orig = [os.environ[f] for f in compiler_flags]
for f in compiler_flags: for f in compiler_flags:
@@ -559,7 +628,7 @@ if 'hdf5' in targets:
download_url=f"https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-{HDF5_MAJOR}/hdf5-{HDF5_VERSION}/src/", download_url=f"https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-{HDF5_MAJOR}/hdf5-{HDF5_VERSION}/src/",
download_name=f"CMake-hdf5-{HDF5_VERSION}.tar.gz", download_name=f"CMake-hdf5-{HDF5_VERSION}.tar.gz",
ctest_result=f"HDF5-{HDF5_VERSION}-{platform.system()}", ctest_result=f"HDF5-{HDF5_VERSION}-{platform.system()}",
ctest_result_path=f"HDF_Group/HDF5/{HDF5_VERSION}" ctest_result_path=f"HDF_Group/HDF5/{HDF5_VERSION}",
) )
for f, o in zip(compiler_flags, orig): for f, o in zip(compiler_flags, orig):
@@ -575,7 +644,9 @@ if "json" in targets:
urlretrieve(json_url, json_install_path) urlretrieve(json_url, json_install_path)
if "eigen" in targets: if "eigen" in targets:
git_clone_or_pull_repository("https://gitlab.com/libeigen/eigen.git", f"{DEPS_DIR}/install/eigen-3.3.9", revision="3.3.9") git_clone_or_pull_repository(
"https://gitlab.com/libeigen/eigen.git", f"{DEPS_DIR}/install/eigen-3.3.9", revision="3.3.9"
)
if "pcre" in targets: if "pcre" in targets:
build_dependency( build_dependency(
@@ -583,7 +654,7 @@ if "pcre" in targets:
mode="autoconf", mode="autoconf",
build_tool_args=[DISABLE_FLAG], build_tool_args=[DISABLE_FLAG],
download_url=f"https://downloads.sourceforge.net/project/pcre/pcre/{PCRE_VERSION}/", download_url=f"https://downloads.sourceforge.net/project/pcre/pcre/{PCRE_VERSION}/",
download_name=f"pcre-{PCRE_VERSION}.tar.bz2" download_name=f"pcre-{PCRE_VERSION}.tar.bz2",
) )
# An issue exists with swig-1.3 and python >= 3.2 # An issue exists with swig-1.3 and python >= 3.2
@@ -596,20 +667,18 @@ if "swig" in targets:
download_url="https://github.com/swig/swig.git", download_url="https://github.com/swig/swig.git",
download_name="swig", download_name="swig",
download_tool=download_tool_git, download_tool=download_tool_git,
revision=f"rel-{SWIG_VERSION}" revision=f"rel-{SWIG_VERSION}",
) )
if "freetype" in targets: if "freetype" in targets:
build_dependency( build_dependency(
name=f"freetype", name=f"freetype",
mode="cmake", mode="cmake",
build_tool_args=[ build_tool_args=[f"-DCMAKE_INSTALL_PREFIX={DEPS_DIR}/install/freetype"],
f"-DCMAKE_INSTALL_PREFIX={DEPS_DIR}/install/freetype" download_url="https://github.com/freetype/freetype",
], download_name="freetype2",
download_url = "https://github.com/freetype/freetype",
download_name = "freetype2",
download_tool=download_tool_git, download_tool=download_tool_git,
revision="VER-2-11-1" revision="VER-2-11-1",
) )
if USE_OCCT and "occ" in targets: if USE_OCCT and "occ" in targets:
@@ -637,13 +706,13 @@ if USE_OCCT and "occ" in targets:
f"-DBUILD_LIBRARY_TYPE={LINK_TYPE_UCFIRST}", f"-DBUILD_LIBRARY_TYPE={LINK_TYPE_UCFIRST}",
"-DBUILD_MODULE_Draw=0", "-DBUILD_MODULE_Draw=0",
"-DBUILD_RELEASE_DISABLE_EXCEPTIONS=Off", "-DBUILD_RELEASE_DISABLE_EXCEPTIONS=Off",
f"-D3RDPARTY_FREETYPE_DIR={DEPS_DIR}/install/freetype" f"-D3RDPARTY_FREETYPE_DIR={DEPS_DIR}/install/freetype",
], ],
download_url = "https://github.com/Open-Cascade-SAS/OCCT", download_url="https://github.com/Open-Cascade-SAS/OCCT",
download_name = "occt", download_name="occt",
download_tool=download_tool_git, download_tool=download_tool_git,
patch=patches, patch=patches,
revision="V" + OCCT_VERSION.replace('.', '_') revision="V" + OCCT_VERSION.replace(".", "_"),
) )
elif "occ" in targets: elif "occ" in targets:
build_dependency( build_dependency(
@@ -656,10 +725,10 @@ elif "occ" in targets:
"-DOCE_DISABLE_X11=ON", "-DOCE_DISABLE_X11=ON",
"-DOCE_VISUALISATION=OFF", "-DOCE_VISUALISATION=OFF",
"-DOCE_OCAF=OFF", "-DOCE_OCAF=OFF",
f"-DOCE_INSTALL_PREFIX={DEPS_DIR}/install/oce-{OCE_VERSION}" f"-DOCE_INSTALL_PREFIX={DEPS_DIR}/install/oce-{OCE_VERSION}",
], ],
download_url="https://github.com/tpaviot/oce/archive/", download_url="https://github.com/tpaviot/oce/archive/",
download_name=f"OCE-{OCE_VERSION}.tar.gz" download_name=f"OCE-{OCE_VERSION}.tar.gz",
) )
if "libxml2" in targets: if "libxml2" in targets:
@@ -672,10 +741,10 @@ if "libxml2" in targets:
DISABLE_FLAG, DISABLE_FLAG,
"--without-zlib", "--without-zlib",
"--without-iconv", "--without-iconv",
"--without-lzma" "--without-lzma",
], ],
download_url=f"https://download.gnome.org/sources/libxml2/{'.'.join(LIBXML2_VERSION.split('.')[0:2])}/", download_url=f"https://download.gnome.org/sources/libxml2/{'.'.join(LIBXML2_VERSION.split('.')[0:2])}/",
download_name=f"libxml2-{LIBXML2_VERSION}.tar.xz" download_name=f"libxml2-{LIBXML2_VERSION}.tar.xz",
) )
if "OpenCOLLADA" in targets: if "OpenCOLLADA" in targets:
@@ -697,13 +766,13 @@ if "OpenCOLLADA" in targets:
f"-DPCRE_INCLUDE_DIR={DEPS_DIR}/install/pcre-{PCRE_VERSION}/include", f"-DPCRE_INCLUDE_DIR={DEPS_DIR}/install/pcre-{PCRE_VERSION}/include",
f"-DPCRE_PCREPOSIX_LIBRARY={DEPS_DIR}/install/pcre-{PCRE_VERSION}/lib/libpcreposix.{LIBRARY_EXT}", f"-DPCRE_PCREPOSIX_LIBRARY={DEPS_DIR}/install/pcre-{PCRE_VERSION}/lib/libpcreposix.{LIBRARY_EXT}",
f"-DPCRE_PCRE_LIBRARY={DEPS_DIR}/install/pcre-{PCRE_VERSION}/lib/libpcre.{LIBRARY_EXT}", f"-DPCRE_PCRE_LIBRARY={DEPS_DIR}/install/pcre-{PCRE_VERSION}/lib/libpcre.{LIBRARY_EXT}",
f"-DCMAKE_INSTALL_PREFIX={DEPS_DIR}/install/OpenCOLLADA/" f"-DCMAKE_INSTALL_PREFIX={DEPS_DIR}/install/OpenCOLLADA/",
], ],
download_url="https://github.com/KhronosGroup/OpenCOLLADA.git", download_url="https://github.com/KhronosGroup/OpenCOLLADA.git",
download_name="OpenCOLLADA", download_name="OpenCOLLADA",
download_tool=download_tool_git, download_tool=download_tool_git,
patch=patches, patch=patches,
revision=OPENCOLLADA_VERSION revision=OPENCOLLADA_VERSION,
) )
if "python" in targets and not USE_CURRENT_PYTHON_VERSION and "wasm" not in flags: if "python" in targets and not USE_CURRENT_PYTHON_VERSION and "wasm" not in flags:
@@ -728,7 +797,7 @@ if "python" in targets and not USE_CURRENT_PYTHON_VERSION and "wasm" not in flag
"autoconf", "autoconf",
PYTHON_CONFIGURE_ARGS, PYTHON_CONFIGURE_ARGS,
f"http://www.python.org/ftp/python/{PYTHON_VERSION}/", f"http://www.python.org/ftp/python/{PYTHON_VERSION}/",
f"Python-{PYTHON_VERSION}.tgz" f"Python-{PYTHON_VERSION}.tgz",
) )
except RuntimeError as e: except RuntimeError as e:
# Sometimes setting up modules such as pip/lzma can cause # Sometimes setting up modules such as pip/lzma can cause
@@ -737,9 +806,7 @@ if "python" in targets and not USE_CURRENT_PYTHON_VERSION and "wasm" not in flag
# are installed correctly. This is all we need so we catch # are installed correctly. This is all we need so we catch
# the exception and only reraise if a partially successful # the exception and only reraise if a partially successful
# install is not detected. # install is not detected.
if not os.path.exists( if not os.path.exists(os.path.join(DEPS_DIR, "install", f"python-{PYTHON_VERSION}")):
os.path.join(DEPS_DIR, "install", f"python-{PYTHON_VERSION}")
):
raise e raise e
os.environ["CPPFLAGS"] = OLD_CPP_FLAGS os.environ["CPPFLAGS"] = OLD_CPP_FLAGS
@@ -765,17 +832,23 @@ if "boost" in targets:
"--with-filesystem", "--with-filesystem",
f"link={LINK_TYPE}", f"link={LINK_TYPE}",
*toolset, *toolset,
*map(str_concat("cxxflags"), CXXFLAGS.strip().split(' ')), *map(str_concat("cxxflags"), CXXFLAGS.strip().split(" ")),
*map(str_concat("linkflags"), LDFLAGS.strip().split(' ')), *map(str_concat("linkflags"), LDFLAGS.strip().split(" ")),
"stage", "-s", "NO_BZIP2=1"], "stage",
"-s",
"NO_BZIP2=1",
],
download_url=BOOST_LOCATION, download_url=BOOST_LOCATION,
# don't remember what this is, but fail on 1.86 # don't remember what this is, but fail on 1.86
# patch="./patches/boost/boostorg_regex_62.patch", # patch="./patches/boost/boostorg_regex_62.patch",
download_name=f"boost-{BOOST_VERSION}-b2-nodocs.tar.gz" download_name=f"boost-{BOOST_VERSION}-b2-nodocs.tar.gz",
) )
if "wasm" in flags: if "wasm" in flags:
# only supported on nix for now # only supported on nix for now
run(("find", ".", "-name", "*.bc", "-exec", "bash", "-c", "emar q ${1%.bc}.a $1", "bash", "{}", ";"), cwd=f"{DEPS_DIR}/install/boost-{BOOST_VERSION}/lib") run(
("find", ".", "-name", "*.bc", "-exec", "bash", "-c", "emar q ${1%.bc}.a $1", "bash", "{}", ";"),
cwd=f"{DEPS_DIR}/install/boost-{BOOST_VERSION}/lib",
)
if "cgal" in targets: if "cgal" in targets:
gmp_args = [] gmp_args = []
@@ -788,9 +861,11 @@ if "cgal" in targets:
name=f"gmp-{GMP_VERSION}", name=f"gmp-{GMP_VERSION}",
mode="autoconf", mode="autoconf",
build_tool_args=[ENABLE_FLAG, DISABLE_FLAG, "--with-pic", *gmp_args], build_tool_args=[ENABLE_FLAG, DISABLE_FLAG, "--with-pic", *gmp_args],
pre_compile_subs=([("build/config.h", "HAVE_OBSTACK_VPRINTF 1", "HAVE_OBSTACK_VPRINTF 0")] if "wasm" in flags else []), pre_compile_subs=(
[("build/config.h", "HAVE_OBSTACK_VPRINTF 1", "HAVE_OBSTACK_VPRINTF 0")] if "wasm" in flags else []
),
download_url="https://ftp.gnu.org/gnu/gmp/", download_url="https://ftp.gnu.org/gnu/gmp/",
download_name=f"gmp-{GMP_VERSION}.tar.bz2" download_name=f"gmp-{GMP_VERSION}.tar.bz2",
) )
build_dependency( build_dependency(
@@ -798,7 +873,7 @@ if "cgal" in targets:
mode="autoconf", mode="autoconf",
build_tool_args=[ENABLE_FLAG, DISABLE_FLAG, *mpfr_args, f"--with-gmp={DEPS_DIR}/install/gmp-{GMP_VERSION}"], build_tool_args=[ENABLE_FLAG, DISABLE_FLAG, *mpfr_args, f"--with-gmp={DEPS_DIR}/install/gmp-{GMP_VERSION}"],
download_url=f"http://www.mpfr.org/mpfr-{MPFR_VERSION}/", download_url=f"http://www.mpfr.org/mpfr-{MPFR_VERSION}/",
download_name=f"mpfr-{MPFR_VERSION}.tar.bz2" download_name=f"mpfr-{MPFR_VERSION}.tar.bz2",
) )
build_dependency( build_dependency(
@@ -807,31 +882,28 @@ if "cgal" in targets:
build_tool_args=[ build_tool_args=[
f"-DGMP_LIBRARIES={DEPS_DIR}/install/gmp-{GMP_VERSION}/lib/libgmp.{LIBRARY_EXT}", f"-DGMP_LIBRARIES={DEPS_DIR}/install/gmp-{GMP_VERSION}/lib/libgmp.{LIBRARY_EXT}",
f"-DGMP_INCLUDE_DIR={DEPS_DIR}/install/gmp-{GMP_VERSION}/include", f"-DGMP_INCLUDE_DIR={DEPS_DIR}/install/gmp-{GMP_VERSION}/include",
f"-DMPFR_LIBRARIES={DEPS_DIR}/install/mpfr-{MPFR_VERSION}/lib/libmpfr.{LIBRARY_EXT}" , f"-DMPFR_LIBRARIES={DEPS_DIR}/install/mpfr-{MPFR_VERSION}/lib/libmpfr.{LIBRARY_EXT}",
f"-DMPFR_INCLUDE_DIR={DEPS_DIR}/install/mpfr-{MPFR_VERSION}/include", f"-DMPFR_INCLUDE_DIR={DEPS_DIR}/install/mpfr-{MPFR_VERSION}/include",
f"-DBoost_INCLUDE_DIR={DEPS_DIR}/install/boost-{BOOST_VERSION}", f"-DBoost_INCLUDE_DIR={DEPS_DIR}/install/boost-{BOOST_VERSION}",
f"-DCMAKE_INSTALL_PREFIX={DEPS_DIR}/install/cgal-{CGAL_VERSION}/", f"-DCMAKE_INSTALL_PREFIX={DEPS_DIR}/install/cgal-{CGAL_VERSION}/",
"-DCGAL_HEADER_ONLY=On", "-DCGAL_HEADER_ONLY=On",
"-DBUILD_SHARED_LIBS=Off" "-DBUILD_SHARED_LIBS=Off",
], ],
download_url="https://github.com/CGAL/cgal.git", download_url="https://github.com/CGAL/cgal.git",
download_name="cgal", download_name="cgal",
download_tool=download_tool_git, download_tool=download_tool_git,
revision=CGAL_VERSION revision=CGAL_VERSION,
) )
if "usd" in targets: if "usd" in targets:
build_dependency( build_dependency(
name=f"oneTBB-{TBB_VERSION}", name=f"oneTBB-{TBB_VERSION}",
mode="cmake", mode="cmake",
build_tool_args=[ build_tool_args=[f"-DCMAKE_INSTALL_PREFIX={DEPS_DIR}/install/tbb-{TBB_VERSION}", f"-DTBB_TEST=OFF"],
f"-DCMAKE_INSTALL_PREFIX={DEPS_DIR}/install/tbb-{TBB_VERSION}",
f"-DTBB_TEST=OFF"
],
download_url="https://github.com/oneapi-src/oneTBB", download_url="https://github.com/oneapi-src/oneTBB",
download_name="oneTBB", download_name="oneTBB",
download_tool=download_tool_git, download_tool=download_tool_git,
revision=f"v{TBB_VERSION}" revision=f"v{TBB_VERSION}",
) )
build_dependency( build_dependency(
@@ -847,12 +919,12 @@ if "usd" in targets:
f"-DPXR_BUILD_TUTORIALS=FALSE", f"-DPXR_BUILD_TUTORIALS=FALSE",
f"-DPXR_BUILD_EXAMPLES=FALSE", f"-DPXR_BUILD_EXAMPLES=FALSE",
f"-DPXR_BUILD_USD_TOOLS=FALSE", f"-DPXR_BUILD_USD_TOOLS=FALSE",
f"-DPXR_BUILD_TESTS=FALSE" f"-DPXR_BUILD_TESTS=FALSE",
], ],
download_url="https://github.com/PixarAnimationStudios/USD", download_url="https://github.com/PixarAnimationStudios/USD",
download_name="USD", download_name="USD",
download_tool=download_tool_git, download_tool=download_tool_git,
revision=f"v{USD_VERSION}" revision=f"v{USD_VERSION}",
) )
cecho("Building IfcOpenShell:", GREEN) cecho("Building IfcOpenShell:", GREEN)
@@ -867,17 +939,17 @@ os.makedirs(executables_dir, exist_ok=True)
cmake_args = [ cmake_args = [
"-DCMAKE_CXX_STANDARD=" "17", "-DCMAKE_CXX_STANDARD=" "17",
"-DUSE_MMAP=" "OFF", "-DUSE_MMAP=" "OFF",
"-DBUILD_EXAMPLES=" "OFF", "-DBUILD_EXAMPLES=" "OFF",
"-DBUILD_SHARED_LIBS=" +OFF_ON[not BUILD_STATIC], "-DBUILD_SHARED_LIBS=" + OFF_ON[not BUILD_STATIC],
"-DBOOST_ROOT=" f"{DEPS_DIR}/install/boost-{BOOST_VERSION}", "-DBOOST_ROOT=" f"{DEPS_DIR}/install/boost-{BOOST_VERSION}",
"-DGLTF_SUPPORT=" "ON", "-DGLTF_SUPPORT=" "ON",
"-DJSON_INCLUDE_DIR=" f"{DEPS_DIR}/install/json", "-DJSON_INCLUDE_DIR=" f"{DEPS_DIR}/install/json",
"-DEIGEN_DIR=" f"{DEPS_DIR}/install/eigen-3.3.9", "-DEIGEN_DIR=" f"{DEPS_DIR}/install/eigen-3.3.9",
"-DBoost_NO_BOOST_CMAKE=" "On", "-DBoost_NO_BOOST_CMAKE=" "On",
"-DADD_COMMIT_SHA=" +("On" if ADD_COMMIT_SHA else "Off"), "-DADD_COMMIT_SHA=" + ("On" if ADD_COMMIT_SHA else "Off"),
"-DVERSION_OVERRIDE=" +("On" if ADD_COMMIT_SHA else "Off") "-DVERSION_OVERRIDE=" + ("On" if ADD_COMMIT_SHA else "Off"),
] ]
if "wasm" in flags: if "wasm" in flags:
@@ -886,75 +958,79 @@ if "wasm" in flags:
cmake_args.append("-DWASM_BUILD=On") cmake_args.append("-DWASM_BUILD=On")
if "cgal" in targets: if "cgal" in targets:
cmake_args.extend([ cmake_args.extend(
"-DCGAL_INCLUDE_DIR=" f"{DEPS_DIR}/install/cgal-{CGAL_VERSION}/include", [
"-DGMP_INCLUDE_DIR=" f"{DEPS_DIR}/install/gmp-{GMP_VERSION}/include", "-DCGAL_INCLUDE_DIR=" f"{DEPS_DIR}/install/cgal-{CGAL_VERSION}/include",
"-DGMP_LIBRARY_DIR=" f"{DEPS_DIR}/install/gmp-{GMP_VERSION}/lib", "-DGMP_INCLUDE_DIR=" f"{DEPS_DIR}/install/gmp-{GMP_VERSION}/include",
"-DMPFR_INCLUDE_DIR=" f"{DEPS_DIR}/install/mpfr-{MPFR_VERSION}/include", "-DGMP_LIBRARY_DIR=" f"{DEPS_DIR}/install/gmp-{GMP_VERSION}/lib",
"-DMPFR_LIBRARY_DIR=" f"{DEPS_DIR}/install/mpfr-{MPFR_VERSION}/lib", "-DMPFR_INCLUDE_DIR=" f"{DEPS_DIR}/install/mpfr-{MPFR_VERSION}/include",
]) "-DMPFR_LIBRARY_DIR=" f"{DEPS_DIR}/install/mpfr-{MPFR_VERSION}/lib",
]
if "occ" in targets and USE_OCCT:
occ_include_dir = f"{DEPS_DIR}/install/occt-{OCCT_VERSION}/include/opencascade"
occ_library_dir = f"{DEPS_DIR}/install/occt-{OCCT_VERSION}/lib"
cmake_args.extend([
"-DOCC_INCLUDE_DIR=" +occ_include_dir,
"-DOCC_LIBRARY_DIR=" +occ_library_dir
])
elif "occ" in targets:
occ_include_dir = f"{DEPS_DIR}/install/oce-{OCE_VERSION}/include/oce"
occ_library_dir = f"{DEPS_DIR}/install/oce-{OCE_VERSION}/lib"
cmake_args.extend([
"-DOCC_INCLUDE_DIR=" +occ_include_dir,
"-DOCC_LIBRARY_DIR=" +occ_library_dir
])
if "OpenCOLLADA" in targets:
cmake_args.extend([
"-DOPENCOLLADA_INCLUDE_DIR=" f"{DEPS_DIR}/install/OpenCOLLADA/include/opencollada",
"-DOPENCOLLADA_LIBRARY_DIR=" f"{DEPS_DIR}/install/OpenCOLLADA/lib/opencollada"
])
else:
cmake_args.extend([
"-DCOLLADA_SUPPORT=" "Off",
])
if "pcre" in targets:
cmake_args.append(
"-DPCRE_LIBRARY_DIR=" f"{DEPS_DIR}/install/pcre-{PCRE_VERSION}/lib"
) )
if "occ" in targets and USE_OCCT:
occ_include_dir = f"{DEPS_DIR}/install/occt-{OCCT_VERSION}/include/opencascade"
occ_library_dir = f"{DEPS_DIR}/install/occt-{OCCT_VERSION}/lib"
cmake_args.extend(["-DOCC_INCLUDE_DIR=" + occ_include_dir, "-DOCC_LIBRARY_DIR=" + occ_library_dir])
elif "occ" in targets:
occ_include_dir = f"{DEPS_DIR}/install/oce-{OCE_VERSION}/include/oce"
occ_library_dir = f"{DEPS_DIR}/install/oce-{OCE_VERSION}/lib"
cmake_args.extend(["-DOCC_INCLUDE_DIR=" + occ_include_dir, "-DOCC_LIBRARY_DIR=" + occ_library_dir])
if "OpenCOLLADA" in targets:
cmake_args.extend(
[
"-DOPENCOLLADA_INCLUDE_DIR=" f"{DEPS_DIR}/install/OpenCOLLADA/include/opencollada",
"-DOPENCOLLADA_LIBRARY_DIR=" f"{DEPS_DIR}/install/OpenCOLLADA/lib/opencollada",
]
)
else:
cmake_args.extend(
[
"-DCOLLADA_SUPPORT=" "Off",
]
)
if "pcre" in targets:
cmake_args.append("-DPCRE_LIBRARY_DIR=" f"{DEPS_DIR}/install/pcre-{PCRE_VERSION}/lib")
if "libxml2" in targets: if "libxml2" in targets:
cmake_args.extend([ cmake_args.extend(
"-DLIBXML2_INCLUDE_DIR=" f"{DEPS_DIR}/install/libxml2-{LIBXML2_VERSION}/include/libxml2", [
"-DLIBXML2_LIBRARIES=" f"{DEPS_DIR}/install/libxml2-{LIBXML2_VERSION}/lib/libxml2.{LIBRARY_EXT}" "-DLIBXML2_INCLUDE_DIR=" f"{DEPS_DIR}/install/libxml2-{LIBXML2_VERSION}/include/libxml2",
]) "-DLIBXML2_LIBRARIES=" f"{DEPS_DIR}/install/libxml2-{LIBXML2_VERSION}/lib/libxml2.{LIBRARY_EXT}",
]
)
if "hdf5" in targets: if "hdf5" in targets:
cmake_args.extend([ cmake_args.extend(
"-DHDF5_INCLUDE_DIR=" f"{DEPS_DIR}/install/hdf5-{HDF5_VERSION}/include", [
"-DHDF5_LIBRARY_DIR=" f"{DEPS_DIR}/install/hdf5-{HDF5_VERSION}/lib" "-DHDF5_INCLUDE_DIR=" f"{DEPS_DIR}/install/hdf5-{HDF5_VERSION}/include",
]) "-DHDF5_LIBRARY_DIR=" f"{DEPS_DIR}/install/hdf5-{HDF5_VERSION}/lib",
]
)
else: else:
cmake_args.append("-DHDF5_SUPPORT=Off") cmake_args.append("-DHDF5_SUPPORT=Off")
if "usd" in targets: if "usd" in targets:
cmake_args.extend([ cmake_args.extend(
"-DUSD_SUPPORT=" "On", [
"-DUSD_INCLUDE_DIR=" f"{DEPS_DIR}/install/usd-{USD_VERSION}/include", "-DUSD_SUPPORT=" "On",
"-DUSD_LIBRARY_DIR=" f"{DEPS_DIR}/install/usd-{USD_VERSION}/lib" "-DUSD_INCLUDE_DIR=" f"{DEPS_DIR}/install/usd-{USD_VERSION}/include",
]) "-DUSD_LIBRARY_DIR=" f"{DEPS_DIR}/install/usd-{USD_VERSION}/lib",
]
)
if not explicit_targets or {"IfcGeom", "IfcConvert", "IfcGeomServer"} & set(explicit_targets): if not explicit_targets or {"IfcGeom", "IfcConvert", "IfcGeomServer"} & set(explicit_targets):
logger.info("\rConfiguring executables...") logger.info("\rConfiguring executables...")
exec_args = [ exec_args = [
"-DBUILD_IFCGEOM=" +OFF_ON["IfcGeom" in targets], "-DBUILD_IFCGEOM=" + OFF_ON["IfcGeom" in targets],
"-DBUILD_GEOMSERVER=" +OFF_ON["IfcGeomServer" in targets], "-DBUILD_GEOMSERVER=" + OFF_ON["IfcGeomServer" in targets],
"-DBUILD_CONVERT=" +OFF_ON["IfcConvert" in targets], "-DBUILD_CONVERT=" + OFF_ON["IfcConvert" in targets],
"-DBUILD_IFCPYTHON=" "OFF", "-DBUILD_IFCPYTHON=" "OFF",
"-DCMAKE_INSTALL_PREFIX=" f"{DEPS_DIR}/install/ifcopenshell", "-DCMAKE_INSTALL_PREFIX=" f"{DEPS_DIR}/install/ifcopenshell",
] ]
run_cmake("", exec_args + cmake_args, cmake_dir=CMAKE_DIR, cwd=executables_dir) run_cmake("", exec_args + cmake_args, cmake_dir=CMAKE_DIR, cwd=executables_dir)
@@ -994,17 +1070,30 @@ if "IfcOpenShell-Python" in targets:
if "swig" in targets: if "swig" in targets:
swig_when_built.append(f"-DSWIG_EXECUTABLE={DEPS_DIR}/install/swig/bin/swig") swig_when_built.append(f"-DSWIG_EXECUTABLE={DEPS_DIR}/install/swig/bin/swig")
run_cmake("", run_cmake(
cmake_args + [ "",
"-DPYTHON_LIBRARY=" +python_library, cmake_args
+ [
"-DPYTHON_LIBRARY=" + python_library,
*([f"-DPYTHON_EXECUTABLE={python_executable}"] if python_executable else []), *([f"-DPYTHON_EXECUTABLE={python_executable}"] if python_executable else []),
# *([f"-DPYTHON_MODULE_INSTALL_DIR={os.environ['PYTHONPATH']}/ifcopenshell"] if "wasm" in flags else []), # *([f"-DPYTHON_MODULE_INSTALL_DIR={os.environ['PYTHONPATH']}/ifcopenshell"] if "wasm" in flags else []),
*(["-DPYTHON_MODULE_INSTALL_DIR="+os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "package"))] if "wasm" in flags else []), *(
"-DPYTHON_INCLUDE_DIR=" +python_include, [
"-DCMAKE_INSTALL_PREFIX=" f"{DEPS_DIR}/install/ifcopenshell/tmp", "-DPYTHON_MODULE_INSTALL_DIR="
"-DUSERSPACE_PYTHON_PREFIX=" +["Off", "On"][os.environ.get("PYTHON_USER_SITE", "").lower() in {"1", "on", "true"}], + os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "package"))
*swig_when_built], ]
cmake_dir=CMAKE_DIR, cwd=python_dir) if "wasm" in flags
else []
),
"-DPYTHON_INCLUDE_DIR=" + python_include,
"-DCMAKE_INSTALL_PREFIX=" f"{DEPS_DIR}/install/ifcopenshell/tmp",
"-DUSERSPACE_PYTHON_PREFIX="
+ ["Off", "On"][os.environ.get("PYTHON_USER_SITE", "").lower() in {"1", "on", "true"}],
*swig_when_built,
],
cmake_dir=CMAKE_DIR,
cwd=python_dir,
)
logger.info(f"\rBuilding python {python_version} wrapper... ") logger.info(f"\rBuilding python {python_version} wrapper... ")
@@ -1012,14 +1101,16 @@ if "IfcOpenShell-Python" in targets:
run([make, "install/local"], cwd=os.path.join(python_dir, "ifcwrap")) run([make, "install/local"], cwd=os.path.join(python_dir, "ifcwrap"))
if python_executable: if python_executable:
module_dir = os.path.dirname(run([python_executable, "-c", "import inspect, ifcopenshell; print(inspect.getfile(ifcopenshell))"])) module_dir = os.path.dirname(
run([python_executable, "-c", "import inspect, ifcopenshell; print(inspect.getfile(ifcopenshell))"])
)
if platform.system() != "Darwin": if platform.system() != "Darwin":
if BUILD_CFG == "Release": if BUILD_CFG == "Release":
# TODO: This symbol name depends on the Python version? # TODO: This symbol name depends on the Python version?
so = glob.glob(os.path.join(module_dir, "_ifcopenshell_wrapper*.so"))[0] so = glob.glob(os.path.join(module_dir, "_ifcopenshell_wrapper*.so"))[0]
if "wasm" in flags: if "wasm" in flags:
run(['wasm-strip', so, '-k', "dylink.0"]) run(["wasm-strip", so, "-k", "dylink.0"])
else: else:
run([strip, "-s", "-K", "PyInit__ifcopenshell_wrapper", so], cwd=module_dir) run([strip, "-s", "-K", "PyInit__ifcopenshell_wrapper", so], cwd=module_dir)
@@ -1029,20 +1120,17 @@ if "IfcOpenShell-Python" in targets:
compile_python_wrapper( compile_python_wrapper(
f"{os.environ['PYMAJOR']}.{os.environ['PYMINOR']}.{os.environ['PYMICRO']}", f"{os.environ['PYMAJOR']}.{os.environ['PYMINOR']}.{os.environ['PYMICRO']}",
f"{os.environ['TARGETINSTALLDIR']}/lib/libpython{os.environ['PYMAJOR']}.{os.environ['PYMINOR']}.a", f"{os.environ['TARGETINSTALLDIR']}/lib/libpython{os.environ['PYMAJOR']}.{os.environ['PYMINOR']}.a",
os.environ['PYTHONINCLUDE'], os.environ["PYTHONINCLUDE"],
None None,
) )
elif USE_CURRENT_PYTHON_VERSION: elif USE_CURRENT_PYTHON_VERSION:
python_info = sysconfig.get_paths() python_info = sysconfig.get_paths()
py_path_components = [ py_path_components = [sysconfig.get_config_var("LIBDIR"), sysconfig.get_config_var("INSTSONAME")]
sysconfig.get_config_var('LIBDIR'),
sysconfig.get_config_var("INSTSONAME")
]
if sysconfig.get_config_var('multiarchsubdir'): if sysconfig.get_config_var("multiarchsubdir"):
py_path_components.insert(1, sysconfig.get_config_var('multiarchsubdir').replace("/", "")) py_path_components.insert(1, sysconfig.get_config_var("multiarchsubdir").replace("/", ""))
python_lib = os.path.join(*py_path_components) python_lib = os.path.join(*py_path_components)
@@ -1051,7 +1139,9 @@ if "IfcOpenShell-Python" in targets:
for python_version in PYTHON_VERSIONS: for python_version in PYTHON_VERSIONS:
python_library = run([bash, "-c", f"ls {DEPS_DIR}/install/python-{python_version}/lib/libpython*.*"]) python_library = run([bash, "-c", f"ls {DEPS_DIR}/install/python-{python_version}/lib/libpython*.*"])
python_include = run([bash, "-c", f"ls -d {DEPS_DIR}/install/python-{python_version}/include/python*"]) python_include = run([bash, "-c", f"ls -d {DEPS_DIR}/install/python-{python_version}/include/python*"])
python_executable = os.path.join(DEPS_DIR, "install", f"python-{python_version}", "bin", f"python{python_version[0]}") python_executable = os.path.join(
DEPS_DIR, "install", f"python-{python_version}", "bin", f"python{python_version[0]}"
)
module_dir = compile_python_wrapper(python_version, python_library, python_include, python_executable) module_dir = compile_python_wrapper(python_version, python_library, python_include, python_executable)
run([cp, "-R", module_dir, os.path.join(DEPS_DIR, "install", "ifcopenshell", f"python-{python_version}")]) run([cp, "-R", module_dir, os.path.join(DEPS_DIR, "install", "ifcopenshell", f"python-{python_version}")])
+4 -1
View File
@@ -1,6 +1,9 @@
[tool.black] [tool.black]
line-length = 120 line-length = 120
include = "src/.*.pyi?$" include = '''
src/.*.pyi?$
|nix/.*.pyi?$
'''
extend-exclude = ''' extend-exclude = '''
src/ifcopenshell-python/ifcopenshell/express/* src/ifcopenshell-python/ifcopenshell/express/*
|src/ifcopenshell-python/ifcopenshell/mvd/* |src/ifcopenshell-python/ifcopenshell/mvd/*