Make a couple of things configurable in setup.py scripts. (#14443)
This enables some better downstream usage:
* Can build with some level of debug symbols as needed.
* Can customize the package prefix, not just the suffix (and makes
uniform between compiler/runtime).
* Removes some premature optimizations on build targets and install
paths that have no material benefit and are hard to make match in
downstreams.
diff --git a/compiler/setup.py b/compiler/setup.py
index 4451bde..5a7f41e 100644
--- a/compiler/setup.py
+++ b/compiler/setup.py
@@ -236,6 +236,9 @@
version_py_content = generate_version_py()
print(f"Generating version.py:\n{version_py_content}", file=sys.stderr)
+ cfg = os.getenv("IREE_CMAKE_BUILD_TYPE", "Release")
+ strip_install = cfg == "Release"
+
if not IS_CONFIGURED:
# Build from source tree.
subprocess.check_call(["cmake", "--version"])
@@ -243,7 +246,6 @@
maybe_nuke_cmake_cache()
print(f"CMake build dir: {IREE_BINARY_DIR}", file=sys.stderr)
print(f"CMake install dir: {CMAKE_INSTALL_DIR_ABS}", file=sys.stderr)
- cfg = "Release"
cmake_args = [
"-GNinja",
"--log-level=VERBOSE",
@@ -278,20 +280,19 @@
print(f"Not re-configuring (already configured)", file=sys.stderr)
# Build.
- subprocess.check_call(
- ["cmake", "--build", ".", "--target", "compiler/all"], cwd=IREE_BINARY_DIR
- )
+ subprocess.check_call(["cmake", "--build", "."], cwd=IREE_BINARY_DIR)
print("Build complete.", file=sys.stderr)
# Perform installation on the entire compiler/ tree as this is guaranteed
# to have all of our installation targets.
- install_subdirectory = os.path.join(IREE_BINARY_DIR, "compiler")
+ install_subdirectory = os.path.join(IREE_BINARY_DIR)
install_args = [
- "-DCMAKE_INSTALL_DO_STRIP=ON",
f"-DCMAKE_INSTALL_PREFIX={CMAKE_INSTALL_DIR_ABS}",
"-P",
os.path.join(install_subdirectory, "cmake_install.cmake"),
]
+ if strip_install:
+ install_args.append("-DCMAKE_INSTALL_DO_STRIP=ON")
print(f"Installing with: {install_args}", file=sys.stderr)
subprocess.check_call(["cmake"] + install_args, cwd=install_subdirectory)
@@ -405,8 +406,11 @@
)
print(f"Found compiler packages: {packages}")
+custom_package_suffix = os.getenv("IREE_COMPILER_CUSTOM_PACKAGE_SUFFIX", "")
+custom_package_prefix = os.getenv("IREE_COMPILER_CUSTOM_PACKAGE_PREFIX", "")
+
setup(
- name=f"iree-compiler{PACKAGE_SUFFIX}",
+ name=f"{custom_package_prefix}iree-compiler{custom_package_suffix}{PACKAGE_SUFFIX}",
version=f"{PACKAGE_VERSION}",
author="IREE Authors",
author_email="iree-discuss@googlegroups.com",
diff --git a/runtime/setup.py b/runtime/setup.py
index 005d258..f5077f9 100644
--- a/runtime/setup.py
+++ b/runtime/setup.py
@@ -229,13 +229,15 @@
version_py_content = generate_version_py()
print(f"Generating version.py:\n{version_py_content}", file=sys.stderr)
+ cfg = os.getenv("IREE_CMAKE_BUILD_TYPE", "Release")
+ strip_install = cfg == "Release"
+
if not IS_CONFIGURED:
# Build from source tree.
os.makedirs(IREE_BINARY_DIR, exist_ok=True)
maybe_nuke_cmake_cache()
print(f"CMake build dir: {IREE_BINARY_DIR}", file=sys.stderr)
print(f"CMake install dir: {CMAKE_INSTALL_DIR_ABS}", file=sys.stderr)
- cfg = "Release"
cmake_args = [
"-GNinja",
"--log-level=VERBOSE",
@@ -282,12 +284,13 @@
# Install the component we care about.
install_args = [
- "-DCMAKE_INSTALL_DO_STRIP=ON",
f"-DCMAKE_INSTALL_PREFIX={CMAKE_INSTALL_DIR_ABS}/",
f"-DCMAKE_INSTALL_COMPONENT=IreePythonPackage-runtime",
"-P",
os.path.join(IREE_BINARY_DIR, "cmake_install.cmake"),
]
+ if strip_install:
+ install_args.append("-DCMAKE_INSTALL_DO_STRIP=ON")
print(f"Installing with: {install_args}", file=sys.stderr)
subprocess.check_call(["cmake"] + install_args, cwd=IREE_BINARY_DIR)
@@ -376,12 +379,11 @@
) as f:
README = f.read()
-custom_package_suffix = os.getenv("IREE_RUNTIME_CUSTOM_PACKAGE_SUFFIX")
-if not custom_package_suffix:
- custom_package_suffix = ""
+custom_package_suffix = os.getenv("IREE_RUNTIME_CUSTOM_PACKAGE_SUFFIX", "")
+custom_package_prefix = os.getenv("IREE_RUNTIME_CUSTOM_PACKAGE_PREFIX", "")
setup(
- name=f"iree-runtime{custom_package_suffix}{PACKAGE_SUFFIX}",
+ name=f"{custom_package_prefix}iree-runtime{custom_package_suffix}{PACKAGE_SUFFIX}",
version=f"{PACKAGE_VERSION}",
author="IREE Authors",
author_email="iree-discuss@googlegroups.com",