mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
remove old python versions and use f-strings
This commit is contained in:
+127
-140
@@ -56,16 +56,10 @@ import subprocess as sp
|
|||||||
import shutil
|
import shutil
|
||||||
import tarfile
|
import tarfile
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
import platform
|
||||||
|
|
||||||
PYTHON_MAJOR = sys.version_info[0]
|
|
||||||
|
|
||||||
if PYTHON_MAJOR >= 3:
|
from urllib.request import urlretrieve
|
||||||
from urllib.request import urlretrieve
|
|
||||||
else:
|
|
||||||
# Not Python 3 - today, it is most likely to be Python 2
|
|
||||||
# But note that this might need an update when Python 4
|
|
||||||
# might be around one day
|
|
||||||
from urllib import urlretrieve
|
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -75,7 +69,8 @@ ch.setLevel(logging.INFO)
|
|||||||
logger.addHandler(ch)
|
logger.addHandler(ch)
|
||||||
|
|
||||||
PROJECT_NAME="IfcOpenShell"
|
PROJECT_NAME="IfcOpenShell"
|
||||||
PYTHON_VERSIONS=["2.7.18", "3.5.5", "3.6.13", "3.7.10", "3.8.8", "3.9.2"]
|
PYTHON_VERSIONS=["3.6.13", "3.7.10", "3.8.8", "3.9.2"]
|
||||||
|
PYTHON_VERSIONS=[platform.python_version()]
|
||||||
JSON_VERSION="v3.6.1"
|
JSON_VERSION="v3.6.1"
|
||||||
OCE_VERSION="0.18"
|
OCE_VERSION="0.18"
|
||||||
OCCT_VERSION="7.5.3"
|
OCCT_VERSION="7.5.3"
|
||||||
@@ -128,17 +123,9 @@ def which(cmd):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def get_os():
|
def get_os():
|
||||||
ret_value = sp.check_output([uname, "-s"]).strip()
|
ret_value = sp.check_output([uname, "-s"], encoding="utf-8").strip()
|
||||||
return ret_value
|
return ret_value
|
||||||
|
|
||||||
def to_pystring(x):
|
|
||||||
""" Python 2 & 3 compatibility function for strings handling
|
|
||||||
(to solve TypeError "Can't mix strings and bytes in path components" for Python 3).
|
|
||||||
Reference https://github.com/hugsy/gef/issues/382 """
|
|
||||||
res = str(x, encoding="utf-8") if PYTHON_MAJOR == 3 else x
|
|
||||||
substs = [("\n","\\n"), ("\r","\\r"), ("\t","\\t"), ("\v","\\v"), ("\b","\\b"), ]
|
|
||||||
for x,y in substs: res = res.replace(x,y)
|
|
||||||
return res
|
|
||||||
|
|
||||||
# Set defaults for missing empty environment variables
|
# Set defaults for missing empty environment variables
|
||||||
|
|
||||||
@@ -157,18 +144,18 @@ except KeyError:
|
|||||||
try:
|
try:
|
||||||
TARGET_ARCH = os.environ["TARGET_ARCH"]
|
TARGET_ARCH = os.environ["TARGET_ARCH"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
TARGET_ARCH = sp.check_output([uname, "-m"]).strip()
|
TARGET_ARCH = sp.check_output([uname, "-m"], encoding="utf-8").strip()
|
||||||
|
|
||||||
CMAKE_DIR=os.path.realpath(os.path.join("..", "cmake"))
|
CMAKE_DIR=os.path.realpath(os.path.join("..", "cmake"))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
DEPS_DIR = os.environ["DEPS_DIR"]
|
DEPS_DIR = os.environ["DEPS_DIR"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
path = [b"..", b"build", sp.check_output(uname).strip(), TARGET_ARCH]
|
path = ["..", "build", sp.check_output(uname, encoding="utf-8").strip(), TARGET_ARCH]
|
||||||
if TOOLSET:
|
if TOOLSET:
|
||||||
path.append(TOOLSET)
|
path.append(TOOLSET)
|
||||||
|
|
||||||
DEPS_DIR = to_pystring(os.path.realpath(os.path.join(*path)))
|
DEPS_DIR = os.path.realpath(os.path.join(*path))
|
||||||
|
|
||||||
if not os.path.exists(DEPS_DIR):
|
if not os.path.exists(DEPS_DIR):
|
||||||
os.makedirs(DEPS_DIR)
|
os.makedirs(DEPS_DIR)
|
||||||
@@ -252,7 +239,7 @@ print("Building:", *sorted(targets, key=lambda t: len(list(v(t)))))
|
|||||||
|
|
||||||
for cmd in [git, bunzip2, tar, cc, cplusplus, autoconf, automake, yacc, make, "patch", "cmake"]:
|
for cmd in [git, bunzip2, tar, cc, cplusplus, autoconf, automake, yacc, make, "patch", "cmake"]:
|
||||||
if which(cmd) is None:
|
if which(cmd) is None:
|
||||||
raise ValueError("Required tool '%s' not installed or not added to PATH" % (cmd,))
|
raise ValueError(f"Required tool '{cmd}' not installed or not added to PATH")
|
||||||
|
|
||||||
# identifiers for the download tool (could be less memory consuming as ints, but are more verbose as strings)
|
# identifiers for the download tool (could be less memory consuming as ints, but are more verbose as strings)
|
||||||
download_tool_default = download_tool_py = "py"
|
download_tool_default = download_tool_py = "py"
|
||||||
@@ -263,10 +250,10 @@ download_tool_git = "git"
|
|||||||
log_dir = os.path.join(DEPS_DIR, "logs")
|
log_dir = os.path.join(DEPS_DIR, "logs")
|
||||||
if not os.path.exists(log_dir):
|
if not os.path.exists(log_dir):
|
||||||
os.makedirs(log_dir)
|
os.makedirs(log_dir)
|
||||||
LOG_FILE="%s.log" % (os.path.join(log_dir, to_pystring(sp.check_output([date, "+%Y%m%d"]).strip())),)
|
LOG_FILE = os.path.join(log_dir, sp.check_output([date, "+%Y%m%d"], encoding="utf-8").strip()) + ".log"
|
||||||
if not os.path.exists(LOG_FILE):
|
if not os.path.exists(LOG_FILE):
|
||||||
open(LOG_FILE, "w").close()
|
open(LOG_FILE, "w").close()
|
||||||
logger.info("using command log file '%s'" % (LOG_FILE,))
|
logger.info(f"using command log file '{LOG_FILE}'")
|
||||||
|
|
||||||
def run(cmds, cwd=None):
|
def run(cmds, cwd=None):
|
||||||
|
|
||||||
@@ -276,27 +263,27 @@ def run(cmds, cwd=None):
|
|||||||
with leading and trailing whitespace removed.
|
with leading and trailing whitespace removed.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
logger.debug("running command %r in directory %r" % (" ".join(cmds), cwd))
|
logger.debug(f"running command {' '.join(cmds)} in directory {cwd}")
|
||||||
log_file_handle = open(LOG_FILE, "ab")
|
log_file_handle = open(LOG_FILE, "a")
|
||||||
proc = sp.Popen(cmds, cwd=cwd, stdout=sp.PIPE, stderr=sp.PIPE)
|
proc = sp.Popen(cmds, cwd=cwd, stdout=sp.PIPE, stderr=sp.PIPE, encoding="utf-8")
|
||||||
stdout, stderr = proc.communicate()
|
stdout, stderr = proc.communicate()
|
||||||
log_file_handle.write(stdout)
|
log_file_handle.write(stdout)
|
||||||
log_file_handle.write(stderr)
|
log_file_handle.write(stderr)
|
||||||
log_file_handle.close()
|
log_file_handle.close()
|
||||||
logger.debug("command returned %r" % proc.returncode)
|
logger.debug(f"command returned {proc.returncode}")
|
||||||
|
|
||||||
if proc.returncode != 0:
|
if proc.returncode != 0:
|
||||||
print("-" * 70)
|
print("-" * 70)
|
||||||
print(stderr)
|
print(stderr)
|
||||||
print("-" * 70)
|
print("-" * 70)
|
||||||
raise Exception("Command `%s` returned exit code %d" % (" ".join(cmds), proc.returncode))
|
raise Exception(f"Command `{' '.join(cmds)}` returned exit code {proc.returncode}")
|
||||||
|
|
||||||
return stdout.strip()
|
return stdout.strip()
|
||||||
|
|
||||||
BOOST_VERSION_UNDERSCORE=BOOST_VERSION.replace(".", "_")
|
BOOST_VERSION_UNDERSCORE = BOOST_VERSION.replace(".", "_")
|
||||||
|
|
||||||
OCE_LOCATION="https://github.com/tpaviot/oce/archive/OCE-%s.tar.gz" % (OCE_VERSION,)
|
OCE_LOCATION = f"https://github.com/tpaviot/oce/archive/OCE-{OCE_VERSION}.tar.gz"
|
||||||
BOOST_LOCATION="https://boostorg.jfrog.io/artifactory/main/release/%s/source/" % (BOOST_VERSION,)
|
BOOST_LOCATION = f"https://boostorg.jfrog.io/artifactory/main/release/{BOOST_VERSION}/source/"
|
||||||
|
|
||||||
# Helper functions
|
# Helper functions
|
||||||
|
|
||||||
@@ -305,14 +292,14 @@ def run_autoconf(arg1, configure_args, cwd):
|
|||||||
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
|
||||||
run(["/bin/sh", "../configure"]+configure_args+["--prefix=%s" % (os.path.realpath("%s/install/%s" % (DEPS_DIR, arg1)),)], cwd=cwd)
|
run(["/bin/sh", "../configure"] + configure_args + ["--prefix=%s" % (os.path.realpath("%s/install/%s" % (DEPS_DIR, arg1)),)], cwd=cwd)
|
||||||
|
|
||||||
def run_cmake(arg1, cmake_args, cmake_dir=None, cwd=None):
|
def run_cmake(arg1, cmake_args, cmake_dir=None, cwd=None):
|
||||||
if cmake_dir is None:
|
if cmake_dir is None:
|
||||||
P=".."
|
P = ".."
|
||||||
else:
|
else:
|
||||||
P=cmake_dir
|
P = cmake_dir
|
||||||
run(["cmake", P]+cmake_args+["-DCMAKE_BUILD_TYPE=%s" % (BUILD_CFG,)], cwd=cwd)
|
run(["cmake", P] + cmake_args + [f"-DCMAKE_BUILD_TYPE={BUILD_CFG}"], 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):
|
||||||
"""Lazily clones the `git` repository denoted by `clone_url` into
|
"""Lazily clones the `git` repository denoted by `clone_url` into
|
||||||
@@ -321,10 +308,10 @@ def git_clone_or_pull_repository(clone_url, target_dir, revision=None):
|
|||||||
`revision` after cloning or in the existing clone if `revision` is not
|
`revision` after cloning or in the existing clone if `revision` is not
|
||||||
`None`."""
|
`None`."""
|
||||||
if not os.path.exists(target_dir):
|
if not os.path.exists(target_dir):
|
||||||
logger.info("cloning '%s' into '%s'" % (clone_url, target_dir))
|
logger.info(f"cloning '{clone_url}' into '{target_dir}'")
|
||||||
run([git, "clone", "--recursive", clone_url, target_dir])
|
run([git, "clone", "--recursive", clone_url, target_dir])
|
||||||
else:
|
else:
|
||||||
logger.info("directory '%s' already cloned. Pulling latest changes." % (target_dir,))
|
logger.info(f"directory '{target_dir}' already cloned. Pulling latest changes.")
|
||||||
|
|
||||||
# detect whether we are on a branch and pull
|
# detect whether we are on a branch and pull
|
||||||
if run([git, "rev-parse", "--abbrev-ref", "HEAD"], cwd=target_dir) != "HEAD":
|
if run([git, "rev-parse", "--abbrev-ref", "HEAD"], cwd=target_dir) != "HEAD":
|
||||||
@@ -341,13 +328,13 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d
|
|||||||
linker flags."""
|
linker flags."""
|
||||||
check_dir = os.path.join(DEPS_DIR, "install", name)
|
check_dir = os.path.join(DEPS_DIR, "install", name)
|
||||||
if os.path.exists(check_dir):
|
if os.path.exists(check_dir):
|
||||||
logger.info( "Found existing %s, skipping" % (name,))
|
logger.info(f"Found existing {name}, skipping")
|
||||||
return
|
return
|
||||||
build_dir = os.path.join(DEPS_DIR, "build")
|
build_dir = os.path.join(DEPS_DIR, "build")
|
||||||
if not os.path.exists(build_dir):
|
if not os.path.exists(build_dir):
|
||||||
os.makedirs(build_dir)
|
os.makedirs(build_dir)
|
||||||
|
|
||||||
logger.info("\rFetching %s... " % (name,))
|
logger.info(f"\rFetching {name}... ")
|
||||||
|
|
||||||
if download_tool == download_tool_py:
|
if download_tool == download_tool_py:
|
||||||
if no_append_name:
|
if no_append_name:
|
||||||
@@ -359,12 +346,12 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d
|
|||||||
if not os.path.exists(download_path):
|
if not os.path.exists(download_path):
|
||||||
urlretrieve(url, os.path.join(build_dir, download_path))
|
urlretrieve(url, os.path.join(build_dir, download_path))
|
||||||
else:
|
else:
|
||||||
logger.info("Download '%s' already exists, assuming it's an undamaged download and that it has been extracted if possible, skipping" % (download_path,))
|
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("\rChecking %s... " % (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)
|
||||||
else:
|
else:
|
||||||
raise ValueError("download tool '%s' is not supported" % (download_tool,))
|
raise ValueError(f"download tool '{download_tool}' is not supported")
|
||||||
download_dir = os.path.join(build_dir, download_name)
|
download_dir = os.path.join(build_dir, download_name)
|
||||||
|
|
||||||
if os.path.isdir(download_dir):
|
if os.path.isdir(download_dir):
|
||||||
@@ -378,12 +365,12 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d
|
|||||||
compr = "bz2"
|
compr = "bz2"
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("fix source for new download type")
|
raise RuntimeError("fix source for new download type")
|
||||||
download_tarfile = tarfile.open(name=download_tarfile_path, mode="r:%s" % (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", "tar -tf %s 2> /dev/null | head -n 1 | cut -f1 -d /" % (download_name,)], 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)
|
||||||
@@ -413,26 +400,26 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d
|
|||||||
shutil.rmtree(extract_build_dir)
|
shutil.rmtree(extract_build_dir)
|
||||||
os.makedirs(extract_build_dir)
|
os.makedirs(extract_build_dir)
|
||||||
|
|
||||||
logger.info("\rConfiguring %s..." % (name,))
|
logger.info(f"\rConfiguring {name}...")
|
||||||
if mode == "autoconf":
|
if mode == "autoconf":
|
||||||
run_autoconf(name, build_tool_args, cwd=extract_build_dir)
|
run_autoconf(name, build_tool_args, cwd=extract_build_dir)
|
||||||
elif mode == "cmake":
|
elif mode == "cmake":
|
||||||
run_cmake(name, build_tool_args, cwd=extract_build_dir)
|
run_cmake(name, build_tool_args, cwd=extract_build_dir)
|
||||||
else:
|
else:
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
logger.info("\rBuilding %s... " % (name,))
|
logger.info(f"\rBuilding {name}... ")
|
||||||
run([make, "-j%s" % (IFCOS_NUM_BUILD_PROCS,), "VERBOSE=1"], cwd=extract_build_dir)
|
run([make, f"-j{IFCOS_NUM_BUILD_PROCS}", "VERBOSE=1"], cwd=extract_build_dir)
|
||||||
logger.info( "\rInstalling %s... " % (name,))
|
logger.info(f"\rInstalling {name}... ")
|
||||||
run([make, "install"], cwd=extract_build_dir)
|
run([make, "install"], cwd=extract_build_dir)
|
||||||
logger.info( "\rInstalled %s \n" % (name,))
|
logger.info(f"\rInstalled {name} \n")
|
||||||
else:
|
else:
|
||||||
logger.info( "\rConfiguring %s..." % (name,))
|
logger.info(f"\rConfiguring {name}...")
|
||||||
run([bash, "./bootstrap.sh"], cwd=extract_dir)
|
run([bash, "./bootstrap.sh"], cwd=extract_dir)
|
||||||
logger.info("\rBuilding %s... " % (name,))
|
logger.info(f"\rBuilding {name}... ")
|
||||||
run(["./b2", "-j%s" % (IFCOS_NUM_BUILD_PROCS,)]+build_tool_args, cwd=extract_dir)
|
run(["./b2", f"-j{IFCOS_NUM_BUILD_PROCS}"] + build_tool_args, cwd=extract_dir)
|
||||||
logger.info("\rInstalling %s... " % (name,))
|
logger.info(f"\rInstalling {name}... ")
|
||||||
shutil.copytree(os.path.join(extract_dir, "boost"), os.path.join(DEPS_DIR, "install", "boost-%s" % BOOST_VERSION, "boost"))
|
shutil.copytree(os.path.join(extract_dir, "boost"), os.path.join(DEPS_DIR, "install", f"boost-{BOOST_VERSION}", "boost"))
|
||||||
logger.info("\rInstalled %s \n" % (name,))
|
logger.info(f"\rInstalled {name} \n")
|
||||||
|
|
||||||
cecho("Collecting dependencies:", GREEN)
|
cecho("Collecting dependencies:", GREEN)
|
||||||
|
|
||||||
@@ -449,7 +436,7 @@ if TARGET_ARCH == "i686" and run([uname, "-m"]).strip() == "x86_64":
|
|||||||
BOOST_ADDRESS_MODEL=["architecture=x86", "address-model=32"]
|
BOOST_ADDRESS_MODEL=["architecture=x86", "address-model=32"]
|
||||||
|
|
||||||
if get_os() == "Darwin":
|
if get_os() == "Darwin":
|
||||||
ADDITIONAL_ARGS=["-mmacosx-version-min=%s" % TOOLSET]+ADDITIONAL_ARGS
|
ADDITIONAL_ARGS=[f"-mmacosx-version-min={TOOLSET}"] + ADDITIONAL_ARGS
|
||||||
|
|
||||||
# If the linker supports GC sections, set it up to reduce binary file size
|
# If the linker supports GC sections, set it up to reduce binary file size
|
||||||
# -fPIC is required for the shared libraries to work
|
# -fPIC is required for the shared libraries to work
|
||||||
@@ -488,21 +475,21 @@ os.environ["LDFLAGS"] = LDFLAGS
|
|||||||
# 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:
|
||||||
HDF5_MAJOR=".".join(HDF5_VERSION.split(".")[:-1])
|
HDF5_MAJOR = ".".join(HDF5_VERSION.split(".")[:-1])
|
||||||
get_os_result = get_os()
|
get_os_result = get_os()
|
||||||
build_dependency(
|
build_dependency(
|
||||||
name="hdf5-{HDF5_VERSION}".format(**locals()),
|
name=f"hdf5-{HDF5_VERSION}",
|
||||||
mode="ctest",
|
mode="ctest",
|
||||||
build_tool_args=[],
|
build_tool_args=[],
|
||||||
download_url="https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-{HDF5_MAJOR}/hdf5-{HDF5_VERSION}/src/".format(**locals()),
|
download_url=f"https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-{HDF5_MAJOR}/hdf5-{HDF5_VERSION}/src/",
|
||||||
download_name="CMake-hdf5-{HDF5_VERSION}.tar.gz".format(**locals()),
|
download_name=f"CMake-hdf5-{HDF5_VERSION}.tar.gz",
|
||||||
ctest_result="HDF5-{HDF5_VERSION}-{get_os_result}".format(**locals()),
|
ctest_result=f"HDF5-{HDF5_VERSION}-{get_os_result}",
|
||||||
ctest_result_path="HDF_Group/HDF5/{HDF5_VERSION}".format(**locals())
|
ctest_result_path=f"HDF_Group/HDF5/{HDF5_VERSION}"
|
||||||
)
|
)
|
||||||
|
|
||||||
if "json" in targets:
|
if "json" in targets:
|
||||||
json_url = "https://github.com/nlohmann/json/releases/download/{JSON_VERSION}/json.hpp".format(**locals())
|
json_url = f"https://github.com/nlohmann/json/releases/download/{JSON_VERSION}/json.hpp"
|
||||||
json_install_path = "{DEPS_DIR}/install/json/nlohmann/json.hpp".format(**locals())
|
json_install_path = f"{DEPS_DIR}/install/json/nlohmann/json.hpp"
|
||||||
if not os.path.exists(os.path.dirname(json_install_path)):
|
if not os.path.exists(os.path.dirname(json_install_path)):
|
||||||
os.makedirs(os.path.dirname(json_install_path))
|
os.makedirs(os.path.dirname(json_install_path))
|
||||||
if not os.path.exists(json_install_path):
|
if not os.path.exists(json_install_path):
|
||||||
@@ -510,11 +497,11 @@ if "json" in targets:
|
|||||||
|
|
||||||
if "pcre" in targets:
|
if "pcre" in targets:
|
||||||
build_dependency(
|
build_dependency(
|
||||||
name="pcre-{PCRE_VERSION}".format(**locals()),
|
name=f"pcre-{PCRE_VERSION}",
|
||||||
mode="autoconf",
|
mode="autoconf",
|
||||||
build_tool_args=[DISABLE_FLAG],
|
build_tool_args=[DISABLE_FLAG],
|
||||||
download_url="https://downloads.sourceforge.net/project/pcre/pcre/{PCRE_VERSION}/".format(**locals()),
|
download_url=f"https://downloads.sourceforge.net/project/pcre/pcre/{PCRE_VERSION}/",
|
||||||
download_name="pcre-{PCRE_VERSION}.tar.bz2".format(**locals())
|
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
|
||||||
@@ -523,20 +510,20 @@ if "swig" in targets:
|
|||||||
build_dependency(
|
build_dependency(
|
||||||
name="swig",
|
name="swig",
|
||||||
mode="autoconf",
|
mode="autoconf",
|
||||||
build_tool_args=["--disable-ccache", "--with-pcre-prefix={DEPS_DIR}/install/pcre-{PCRE_VERSION}".format(**locals())],
|
build_tool_args=["--disable-ccache", f"--with-pcre-prefix={DEPS_DIR}/install/pcre-{PCRE_VERSION}"],
|
||||||
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="rel-{SWIG_VERSION}".format(**locals())
|
revision=f"rel-{SWIG_VERSION}"
|
||||||
)
|
)
|
||||||
|
|
||||||
if USE_OCCT and "occ" in targets:
|
if USE_OCCT and "occ" in targets:
|
||||||
build_dependency(
|
build_dependency(
|
||||||
name="occt-{OCCT_VERSION}".format(**locals()),
|
name=f"occt-{OCCT_VERSION}",
|
||||||
mode="cmake",
|
mode="cmake",
|
||||||
build_tool_args=[
|
build_tool_args=[
|
||||||
"-DINSTALL_DIR={DEPS_DIR}/install/occt-{OCCT_VERSION}".format(**locals()),
|
f"-DINSTALL_DIR={DEPS_DIR}/install/occt-{OCCT_VERSION}",
|
||||||
"-DBUILD_LIBRARY_TYPE={LINK_TYPE_UCFIRST}".format(**locals()),
|
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"
|
||||||
],
|
],
|
||||||
@@ -548,7 +535,7 @@ if USE_OCCT and "occ" in targets:
|
|||||||
)
|
)
|
||||||
elif "occ" in targets:
|
elif "occ" in targets:
|
||||||
build_dependency(
|
build_dependency(
|
||||||
name="oce-{OCE_VERSION}".format(**locals()),
|
name=f"oce-{OCE_VERSION}",
|
||||||
mode="cmake",
|
mode="cmake",
|
||||||
build_tool_args=[
|
build_tool_args=[
|
||||||
"-DOCE_DISABLE_TKSERVICE_FONT=ON",
|
"-DOCE_DISABLE_TKSERVICE_FONT=ON",
|
||||||
@@ -557,15 +544,15 @@ elif "occ" in targets:
|
|||||||
"-DOCE_DISABLE_X11=ON",
|
"-DOCE_DISABLE_X11=ON",
|
||||||
"-DOCE_VISUALISATION=OFF",
|
"-DOCE_VISUALISATION=OFF",
|
||||||
"-DOCE_OCAF=OFF",
|
"-DOCE_OCAF=OFF",
|
||||||
"-DOCE_INSTALL_PREFIX={DEPS_DIR}/install/oce-{OCE_VERSION}".format(**locals())
|
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="OCE-{OCE_VERSION}.tar.gz".format(**locals())
|
download_name=f"OCE-{OCE_VERSION}.tar.gz"
|
||||||
)
|
)
|
||||||
|
|
||||||
if "libxml2" in targets:
|
if "libxml2" in targets:
|
||||||
build_dependency(
|
build_dependency(
|
||||||
"libxml2-{LIBXML2_VERSION}".format(**locals()),
|
f"libxml2-{LIBXML2_VERSION}",
|
||||||
"autoconf",
|
"autoconf",
|
||||||
build_tool_args=[
|
build_tool_args=[
|
||||||
"--without-python",
|
"--without-python",
|
||||||
@@ -576,7 +563,7 @@ if "libxml2" in targets:
|
|||||||
"--without-lzma"
|
"--without-lzma"
|
||||||
],
|
],
|
||||||
download_url="ftp://xmlsoft.org/libxml2/",
|
download_url="ftp://xmlsoft.org/libxml2/",
|
||||||
download_name="libxml2-{LIBXML2_VERSION}.tar.gz".format(**locals())
|
download_name=f"libxml2-{LIBXML2_VERSION}.tar.gz"
|
||||||
)
|
)
|
||||||
|
|
||||||
if "OpenCOLLADA" in targets:
|
if "OpenCOLLADA" in targets:
|
||||||
@@ -584,12 +571,12 @@ if "OpenCOLLADA" in targets:
|
|||||||
"OpenCOLLADA",
|
"OpenCOLLADA",
|
||||||
"cmake",
|
"cmake",
|
||||||
build_tool_args=[
|
build_tool_args=[
|
||||||
"-DLIBXML2_INCLUDE_DIR={DEPS_DIR}/install/libxml2-{LIBXML2_VERSION}/include/libxml2".format(**locals()),
|
f"-DLIBXML2_INCLUDE_DIR={DEPS_DIR}/install/libxml2-{LIBXML2_VERSION}/include/libxml2",
|
||||||
"-DLIBXML2_LIBRARIES={DEPS_DIR}/install/libxml2-{LIBXML2_VERSION}/lib/libxml2.{LIBRARY_EXT}".format(**locals()),
|
f"-DLIBXML2_LIBRARIES={DEPS_DIR}/install/libxml2-{LIBXML2_VERSION}/lib/libxml2.{LIBRARY_EXT}",
|
||||||
"-DPCRE_INCLUDE_DIR={DEPS_DIR}/install/pcre-{PCRE_VERSION}/include".format(**locals()),
|
f"-DPCRE_INCLUDE_DIR={DEPS_DIR}/install/pcre-{PCRE_VERSION}/include",
|
||||||
"-DPCRE_PCREPOSIX_LIBRARY={DEPS_DIR}/install/pcre-{PCRE_VERSION}/lib/libpcreposix.{LIBRARY_EXT}".format(**locals()),
|
f"-DPCRE_PCREPOSIX_LIBRARY={DEPS_DIR}/install/pcre-{PCRE_VERSION}/lib/libpcreposix.{LIBRARY_EXT}",
|
||||||
"-DPCRE_PCRE_LIBRARY={DEPS_DIR}/install/pcre-{PCRE_VERSION}/lib/libpcre.{LIBRARY_EXT}".format(**locals()),
|
f"-DPCRE_PCRE_LIBRARY={DEPS_DIR}/install/pcre-{PCRE_VERSION}/lib/libpcre.{LIBRARY_EXT}",
|
||||||
"-DCMAKE_INSTALL_PREFIX={DEPS_DIR}/install/OpenCOLLADA/".format(**locals())
|
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",
|
||||||
@@ -624,15 +611,15 @@ if "python" in targets:
|
|||||||
for PYTHON_VERSION, unicode_conf, abi_tag in PYTHON_VERSION_CONFS():
|
for PYTHON_VERSION, unicode_conf, abi_tag in PYTHON_VERSION_CONFS():
|
||||||
try:
|
try:
|
||||||
build_dependency(
|
build_dependency(
|
||||||
"python-{PYTHON_VERSION}{abi_tag}".format(**locals()),
|
f"python-{PYTHON_VERSION}{abi_tag}",
|
||||||
"autoconf",
|
"autoconf",
|
||||||
PYTHON_CONFIGURE_ARGS + [unicode_conf],
|
PYTHON_CONFIGURE_ARGS + [unicode_conf],
|
||||||
"http://www.python.org/ftp/python/{PYTHON_VERSION}/".format(**locals()),
|
f"http://www.python.org/ftp/python/{PYTHON_VERSION}/",
|
||||||
"Python-{PYTHON_VERSION}.tgz".format(**locals())
|
f"Python-{PYTHON_VERSION}.tgz"
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pyver2 = PYTHON_VERSION[:PYTHON_VERSION.rfind('.')]
|
pyver2 = PYTHON_VERSION[:PYTHON_VERSION.rfind('.')]
|
||||||
if os.path.exists("{DEPS_DIR}/install/python-{PYTHON_VERSION}{abi_tag}/bin/python{pyver2}".format(**locals())):
|
if os.path.exists(f"{DEPS_DIR}/install/python-{PYTHON_VERSION}{abi_tag}/bin/python{pyver2}"):
|
||||||
print("Installation partially failed")
|
print("Installation partially failed")
|
||||||
else: raise e
|
else: raise e
|
||||||
|
|
||||||
@@ -642,60 +629,60 @@ if "python" in targets:
|
|||||||
if "boost" in targets:
|
if "boost" in targets:
|
||||||
str_concat = lambda prefix: lambda postfix: "" if postfix.strip() == "" else "=".join((prefix, postfix.strip()))
|
str_concat = lambda prefix: lambda postfix: "" if postfix.strip() == "" else "=".join((prefix, postfix.strip()))
|
||||||
build_dependency(
|
build_dependency(
|
||||||
"boost-{BOOST_VERSION}".format(**locals()),
|
f"boost-{BOOST_VERSION}",
|
||||||
mode="bjam",
|
mode="bjam",
|
||||||
build_tool_args=[
|
build_tool_args=[
|
||||||
"--stagedir={DEPS_DIR}/install/boost-{BOOST_VERSION}".format(**locals()),
|
f"--stagedir={DEPS_DIR}/install/boost-{BOOST_VERSION}",
|
||||||
"--with-system",
|
"--with-system",
|
||||||
"--with-program_options",
|
"--with-program_options",
|
||||||
"--with-regex",
|
"--with-regex",
|
||||||
"--with-thread",
|
"--with-thread",
|
||||||
"--with-date_time",
|
"--with-date_time",
|
||||||
"--with-iostreams",
|
"--with-iostreams",
|
||||||
"link={LINK_TYPE}".format(**locals())
|
f"link={LINK_TYPE}"
|
||||||
] + \
|
] + \
|
||||||
BOOST_ADDRESS_MODEL + \
|
BOOST_ADDRESS_MODEL + \
|
||||||
list(map(str_concat("cxxflags"), CXXFLAGS.strip().split(' '))) + \
|
list(map(str_concat("cxxflags"), CXXFLAGS.strip().split(' '))) + \
|
||||||
list(map(str_concat("linkflags"), LDFLAGS.strip().split(' '))) + \
|
list(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,
|
||||||
download_name="boost_{BOOST_VERSION_UNDERSCORE}.tar.bz2".format(**locals())
|
download_name=f"boost_{BOOST_VERSION_UNDERSCORE}.tar.bz2"
|
||||||
)
|
)
|
||||||
|
|
||||||
if "cgal" in targets:
|
if "cgal" in targets:
|
||||||
build_dependency(
|
build_dependency(
|
||||||
name="gmp-%s" % (GMP_VERSION,),
|
name=f"gmp-{GMP_VERSION}",
|
||||||
mode="autoconf",
|
mode="autoconf",
|
||||||
build_tool_args=["--disable-shared", "--with-pic"],
|
build_tool_args=["--disable-shared", "--with-pic"],
|
||||||
download_url="https://ftp.gnu.org/gnu/gmp/",
|
download_url="https://ftp.gnu.org/gnu/gmp/",
|
||||||
download_name="gmp-{GMP_VERSION}.tar.bz2".format(**locals())
|
download_name=f"gmp-{GMP_VERSION}.tar.bz2"
|
||||||
)
|
)
|
||||||
|
|
||||||
build_dependency(
|
build_dependency(
|
||||||
name="mpfr-%s" % (MPFR_VERSION,),
|
name="mpfr-%s" % (MPFR_VERSION,),
|
||||||
mode="autoconf",
|
mode="autoconf",
|
||||||
build_tool_args=["--disable-shared", "--with-gmp={DEPS_DIR}/install/gmp-{GMP_VERSION}".format(**locals())],
|
build_tool_args=["--disable-shared", f"--with-gmp={DEPS_DIR}/install/gmp-{GMP_VERSION}"],
|
||||||
download_url="http://www.mpfr.org/mpfr-{MPFR_VERSION}/".format(**locals()),
|
download_url=f"http://www.mpfr.org/mpfr-{MPFR_VERSION}/",
|
||||||
download_name="mpfr-{MPFR_VERSION}.tar.bz2".format(**locals())
|
download_name=f"mpfr-{MPFR_VERSION}.tar.bz2"
|
||||||
)
|
)
|
||||||
|
|
||||||
build_dependency(
|
build_dependency(
|
||||||
name="cgal-{CGAL_VERSION}".format(**locals()),
|
name="cgal-{CGAL_VERSION}",
|
||||||
mode="cmake",
|
mode="cmake",
|
||||||
build_tool_args=[
|
build_tool_args=[
|
||||||
"-DGMP_LIBRARIES=%s/install/gmp-%s/lib/libgmp.a" % (DEPS_DIR, GMP_VERSION),
|
f"-DGMP_LIBRARIES={DEPS_DIR}/install/gmp-{GMP_VERSION}/lib/libgmp.a",
|
||||||
"-DGMP_INCLUDE_DIR=%s/install/gmp-%s/include" % (DEPS_DIR, GMP_VERSION),
|
f"-DGMP_INCLUDE_DIR={DEPS_DIR}/install/gmp-{GMP_VERSION}/include",
|
||||||
"-DMPFR_LIBRARIES=%s/install/mpfr-%s/lib/libmpfr.a" % (DEPS_DIR, MPFR_VERSION),
|
f"-DMPFR_LIBRARIES={DEPS_DIR}/install/mpfr-{MPFR_VERSION}/lib/libmpfr.a" ,
|
||||||
"-DMPFR_INCLUDE_DIR=%s/install/mpfr-%s/include" % (DEPS_DIR, MPFR_VERSION),
|
f"-DMPFR_INCLUDE_DIR={DEPS_DIR}/install/mpfr-{MPFR_VERSION}/include",
|
||||||
"-DBoost_INCLUDE_DIR=%s/install/boost-%s" % (DEPS_DIR, BOOST_VERSION),
|
f"-DBoost_INCLUDE_DIR={DEPS_DIR}/install/boost-{BOOST_VERSION}",
|
||||||
"-DCMAKE_INSTALL_PREFIX=%s/install/cgal-%s/" % (DEPS_DIR, 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="v{CGAL_VERSION}".format(**locals())
|
revision=f"v{CGAL_VERSION}"
|
||||||
)
|
)
|
||||||
|
|
||||||
cecho("Building IfcOpenShell:", GREEN)
|
cecho("Building IfcOpenShell:", GREEN)
|
||||||
@@ -718,38 +705,38 @@ exec_args=[
|
|||||||
"-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=" "{DEPS_DIR}/install/ifcopenshell".format(**locals()),
|
"-DCMAKE_INSTALL_PREFIX=" f"{DEPS_DIR}/install/ifcopenshell",
|
||||||
]
|
]
|
||||||
|
|
||||||
cmake_args=[
|
cmake_args=[
|
||||||
"-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=" "{DEPS_DIR}/install/boost-{BOOST_VERSION}".format(**locals()),
|
"-DBOOST_ROOT=" f"{DEPS_DIR}/install/boost-{BOOST_VERSION}",
|
||||||
"-DGLTF_SUPPORT=" "ON",
|
"-DGLTF_SUPPORT=" "ON",
|
||||||
"-DJSON_INCLUDE_DIR=" "{DEPS_DIR}/install/json".format(**locals()),
|
"-DJSON_INCLUDE_DIR=" f"{DEPS_DIR}/install/json",
|
||||||
"-DBoost_NO_BOOST_CMAKE=" "On",
|
"-DBoost_NO_BOOST_CMAKE=" "On",
|
||||||
]
|
]
|
||||||
|
|
||||||
if "cgal" in targets:
|
if "cgal" in targets:
|
||||||
cmake_args.extend([
|
cmake_args.extend([
|
||||||
"-DCGAL_INCLUDE_DIR=" "{DEPS_DIR}/install/cgal-{CGAL_VERSION}/include".format(**locals()),
|
"-DCGAL_INCLUDE_DIR=" f"{DEPS_DIR}/install/cgal-{CGAL_VERSION}/include",
|
||||||
"-DGMP_INCLUDE_DIR=" "{DEPS_DIR}/install/gmp-{GMP_VERSION}/include".format(**locals()),
|
"-DGMP_INCLUDE_DIR=" f"{DEPS_DIR}/install/gmp-{GMP_VERSION}/include",
|
||||||
"-DGMP_LIBRARY_DIR=" "{DEPS_DIR}/install/gmp-{GMP_VERSION}/lib".format(**locals()),
|
"-DGMP_LIBRARY_DIR=" f"{DEPS_DIR}/install/gmp-{GMP_VERSION}/lib",
|
||||||
"-DMPFR_INCLUDE_DIR=" "{DEPS_DIR}/install/mpfr-{MPFR_VERSION}/include".format(**locals()),
|
"-DMPFR_INCLUDE_DIR=" f"{DEPS_DIR}/install/mpfr-{MPFR_VERSION}/include",
|
||||||
"-DMPFR_LIBRARY_DIR=" "{DEPS_DIR}/install/mpfr-{MPFR_VERSION}/lib".format(**locals()),
|
"-DMPFR_LIBRARY_DIR=" f"{DEPS_DIR}/install/mpfr-{MPFR_VERSION}/lib",
|
||||||
])
|
])
|
||||||
|
|
||||||
if "occ" in targets and USE_OCCT:
|
if "occ" in targets and USE_OCCT:
|
||||||
occ_include_dir = "{DEPS_DIR}/install/occt-{OCCT_VERSION}/include/opencascade".format(**locals())
|
occ_include_dir = f"{DEPS_DIR}/install/occt-{OCCT_VERSION}/include/opencascade"
|
||||||
occ_library_dir = "{DEPS_DIR}/install/occt-{OCCT_VERSION}/lib".format(**locals())
|
occ_library_dir = f"{DEPS_DIR}/install/occt-{OCCT_VERSION}/lib"
|
||||||
cmake_args.extend([
|
cmake_args.extend([
|
||||||
"-DOCC_INCLUDE_DIR=" +occ_include_dir,
|
"-DOCC_INCLUDE_DIR=" +occ_include_dir,
|
||||||
"-DOCC_LIBRARY_DIR=" +occ_library_dir
|
"-DOCC_LIBRARY_DIR=" +occ_library_dir
|
||||||
])
|
])
|
||||||
elif "occ" in targets:
|
elif "occ" in targets:
|
||||||
occ_include_dir = "{DEPS_DIR}/install/oce-{OCE_VERSION}/include/oce".format(**locals())
|
occ_include_dir = f"{DEPS_DIR}/install/oce-{OCE_VERSION}/include/oce"
|
||||||
occ_library_dir = "{DEPS_DIR}/install/oce-{OCE_VERSION}/lib"
|
occ_library_dir = f"{DEPS_DIR}/install/oce-{OCE_VERSION}/lib"
|
||||||
cmake_args.extend([
|
cmake_args.extend([
|
||||||
"-DOCC_INCLUDE_DIR=" +occ_include_dir,
|
"-DOCC_INCLUDE_DIR=" +occ_include_dir,
|
||||||
"-DOCC_LIBRARY_DIR=" +occ_library_dir
|
"-DOCC_LIBRARY_DIR=" +occ_library_dir
|
||||||
@@ -757,49 +744,49 @@ elif "occ" in targets:
|
|||||||
|
|
||||||
if "OpenCOLLADA" in targets:
|
if "OpenCOLLADA" in targets:
|
||||||
cmake_args.extend([
|
cmake_args.extend([
|
||||||
"-DOPENCOLLADA_INCLUDE_DIR=" "{DEPS_DIR}/install/OpenCOLLADA/include/opencollada".format(**locals()),
|
"-DOPENCOLLADA_INCLUDE_DIR=" f"{DEPS_DIR}/install/OpenCOLLADA/include/opencollada",
|
||||||
"-DOPENCOLLADA_LIBRARY_DIR=" "{DEPS_DIR}/install/OpenCOLLADA/lib/opencollada".format(**locals())
|
"-DOPENCOLLADA_LIBRARY_DIR=" f"{DEPS_DIR}/install/OpenCOLLADA/lib/opencollada"
|
||||||
])
|
])
|
||||||
|
|
||||||
if "pcre" in targets:
|
if "pcre" in targets:
|
||||||
cmake_args.append(
|
cmake_args.append(
|
||||||
"-DPCRE_LIBRARY_DIR=" "{DEPS_DIR}/install/pcre-{PCRE_VERSION}/lib".format(**locals())
|
"-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=" "{DEPS_DIR}/install/libxml2-{LIBXML2_VERSION}/include/libxml2".format(**locals()),
|
"-DLIBXML2_INCLUDE_DIR=" f"{DEPS_DIR}/install/libxml2-{LIBXML2_VERSION}/include/libxml2",
|
||||||
"-DLIBXML2_LIBRARIES=" "{DEPS_DIR}/install/libxml2-{LIBXML2_VERSION}/lib/libxml2.{LIBRARY_EXT}".format(**locals())
|
"-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=" "{DEPS_DIR}/install/hdf5-{HDF5_VERSION}/include".format(**locals()),
|
"-DHDF5_INCLUDE_DIR=" f"{DEPS_DIR}/install/hdf5-{HDF5_VERSION}/include",
|
||||||
"-DHDF5_LIBRARY_DIR=" "{DEPS_DIR}/install/hdf5-{HDF5_VERSION}/lib".format(**locals())
|
"-DHDF5_LIBRARY_DIR=" f"{DEPS_DIR}/install/hdf5-{HDF5_VERSION}/lib"
|
||||||
])
|
])
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
logger.info("\rBuilding executables... ")
|
logger.info("\rBuilding executables... ")
|
||||||
|
|
||||||
run([make, "-j{IFCOS_NUM_BUILD_PROCS}".format(**locals())], cwd=executables_dir)
|
run([make, f"-j{IFCOS_NUM_BUILD_PROCS}"], cwd=executables_dir)
|
||||||
run([make, "install/strip" if BUILD_CFG == "Release" else "install"], cwd=executables_dir)
|
run([make, "install/strip" if BUILD_CFG == "Release" else "install"], cwd=executables_dir)
|
||||||
|
|
||||||
if "IfcOpenShell-Python" in targets:
|
if "IfcOpenShell-Python" in targets:
|
||||||
|
|
||||||
# On OSX the actual Python library is not linked against.
|
# On OSX the actual Python library is not linked against.
|
||||||
ADDITIONAL_ARGS=""
|
ADDITIONAL_ARGS = ""
|
||||||
if get_os() == "Darwin":
|
if get_os() == "Darwin":
|
||||||
ADDITIONAL_ARGS="-Wl,-flat_namespace,-undefined,suppress"
|
ADDITIONAL_ARGS="-Wl,-flat_namespace,-undefined,suppress"
|
||||||
|
|
||||||
os.environ["CXXFLAGS"]="%s %s" % (CXXFLAGS_MINIMAL, ADDITIONAL_ARGS)
|
os.environ["CXXFLAGS"] = f"{CXXFLAGS_MINIMAL} {ADDITIONAL_ARGS}"
|
||||||
os.environ["CFLAGS"]="%s %s" % (CFLAGS_MINIMAL, ADDITIONAL_ARGS)
|
os.environ["CFLAGS"] = f"{CFLAGS_MINIMAL} {ADDITIONAL_ARGS}"
|
||||||
os.environ["LDFLAGS"]="%s %s" % (LDFLAGS, ADDITIONAL_ARGS)
|
os.environ["LDFLAGS"] = f"{LDFLAGS} {ADDITIONAL_ARGS}"
|
||||||
|
|
||||||
for PYTHON_VERSION, _, TAG in PYTHON_VERSION_CONFS():
|
for PYTHON_VERSION, _, TAG in PYTHON_VERSION_CONFS():
|
||||||
logger.info("\rConfiguring python {PYTHON_VERSION}{TAG} wrapper...".format(**locals()))
|
logger.info(f"\rConfiguring python {PYTHON_VERSION}{TAG} wrapper...")
|
||||||
|
|
||||||
# python_dir = os.path.join(IFCOS_DIR, "python-{PYTHON_VERSION}{TAG}".format(**locals()))
|
# python_dir = os.path.join(IFCOS_DIR, f"python-{PYTHON_VERSION}{TAG}")
|
||||||
python_dir = os.path.join(IFCOS_DIR, "pythonwrapper")
|
python_dir = os.path.join(IFCOS_DIR, "pythonwrapper")
|
||||||
if not os.path.exists(python_dir):
|
if not os.path.exists(python_dir):
|
||||||
os.makedirs(python_dir)
|
os.makedirs(python_dir)
|
||||||
@@ -808,23 +795,23 @@ if "IfcOpenShell-Python" in targets:
|
|||||||
if os.path.exists(cache_path):
|
if os.path.exists(cache_path):
|
||||||
os.unlink(cache_path)
|
os.unlink(cache_path)
|
||||||
|
|
||||||
PYTHON_LIBRARY=run([bash, "-c", "ls {DEPS_DIR}/install/python-{PYTHON_VERSION}{TAG}/lib/libpython*.*".format(**locals())])
|
PYTHON_LIBRARY=run([bash, "-c", f"ls {DEPS_DIR}/install/python-{PYTHON_VERSION}{TAG}/lib/libpython*.*"])
|
||||||
PYTHON_INCLUDE=run([bash, "-c", "ls -d {DEPS_DIR}/install/python-{PYTHON_VERSION}{TAG}/include/python*".format(**locals())])
|
PYTHON_INCLUDE=run([bash, "-c", f"ls -d {DEPS_DIR}/install/python-{PYTHON_VERSION}{TAG}/include/python*"])
|
||||||
PYTHON_EXECUTABLE=os.path.join(DEPS_DIR, "install", "python-{PYTHON_VERSION}{TAG}".format(**locals()), "bin", "python{PYTHON_VERSION[0]}".format(**locals()))
|
PYTHON_EXECUTABLE=os.path.join(DEPS_DIR, "install", f"python-{PYTHON_VERSION}{TAG}", "bin", f"python{PYTHON_VERSION[0]}")
|
||||||
os.environ["PYTHON_LIBRARY_BASENAME"]=os.path.basename(PYTHON_LIBRARY)
|
os.environ["PYTHON_LIBRARY_BASENAME"] = os.path.basename(PYTHON_LIBRARY)
|
||||||
|
|
||||||
run_cmake("",
|
run_cmake("",
|
||||||
cmake_args + [
|
cmake_args + [
|
||||||
"-DPYTHON_LIBRARY=" +PYTHON_LIBRARY,
|
"-DPYTHON_LIBRARY=" +PYTHON_LIBRARY,
|
||||||
"-DPYTHON_EXECUTABLE=" +PYTHON_EXECUTABLE,
|
"-DPYTHON_EXECUTABLE=" +PYTHON_EXECUTABLE,
|
||||||
"-DPYTHON_INCLUDE_DIR=" +PYTHON_INCLUDE,
|
"-DPYTHON_INCLUDE_DIR=" +PYTHON_INCLUDE,
|
||||||
"-DSWIG_EXECUTABLE=" "{DEPS_DIR}/install/swig/bin/swig".format(**locals()),
|
"-DSWIG_EXECUTABLE=" f"{DEPS_DIR}/install/swig/bin/swig",
|
||||||
"-DCMAKE_INSTALL_PREFIX=" "{DEPS_DIR}/install/ifcopenshell/tmp".format(**locals()),
|
"-DCMAKE_INSTALL_PREFIX=" f"{DEPS_DIR}/install/ifcopenshell/tmp",
|
||||||
], cmake_dir=CMAKE_DIR, cwd=python_dir)
|
], cmake_dir=CMAKE_DIR, cwd=python_dir)
|
||||||
|
|
||||||
logger.info("\rBuilding python %s%s wrapper... " % (PYTHON_VERSION, TAG))
|
logger.info(f"\rBuilding python {PYTHON_VERSION}{TAG} wrapper... ")
|
||||||
|
|
||||||
run([make, "-j%s" % (IFCOS_NUM_BUILD_PROCS,), "_ifcopenshell_wrapper"], cwd=python_dir)
|
run([make, f"-j{IFCOS_NUM_BUILD_PROCS}", "_ifcopenshell_wrapper"], cwd=python_dir)
|
||||||
run([make, "install/local"], cwd=os.path.join(python_dir, "ifcwrap"))
|
run([make, "install/local"], cwd=os.path.join(python_dir, "ifcwrap"))
|
||||||
|
|
||||||
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))"]))
|
||||||
@@ -833,6 +820,6 @@ if "IfcOpenShell-Python" in targets:
|
|||||||
# TODO: This symbol name depends on the Python version?
|
# TODO: This symbol name depends on the Python version?
|
||||||
run([strip, "-s", "-K", "PyInit__ifcopenshell_wrapper", "_ifcopenshell_wrapper.so"], cwd=module_dir)
|
run([strip, "-s", "-K", "PyInit__ifcopenshell_wrapper", "_ifcopenshell_wrapper.so"], cwd=module_dir)
|
||||||
|
|
||||||
run([cp, "-R", module_dir, os.path.join(DEPS_DIR, "install", "ifcopenshell", "python-%s%s" % (PYTHON_VERSION, TAG))])
|
run([cp, "-R", module_dir, os.path.join(DEPS_DIR, "install", "ifcopenshell", f"python-{PYTHON_VERSION}{TAG}")])
|
||||||
|
|
||||||
logger.info("\rBuilt IfcOpenShell...\n\n")
|
logger.info("\rBuilt IfcOpenShell...\n\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user