From a20e931ca9f6e36bf273982bf441d814c098870f Mon Sep 17 00:00:00 2001 From: David Ittah Date: Thu, 11 Dec 2025 13:06:49 -0500 Subject: [PATCH 1/4] Fix cleanup of wheel artifacts - now includes an "include" directory - bin directory was moved a while ago one level up --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1fbcd30fa1..434575d9cb 100644 --- a/Makefile +++ b/Makefile @@ -268,7 +268,7 @@ clean: find frontend/catalyst -name "*.so" -not -path "*/third_party/*" -exec rm -v {} + git restore frontend/catalyst/_configuration.py rm -rf $(MK_DIR)/frontend/catalyst/_revision.py - rm -rf $(MK_DIR)/frontend/mlir_quantum $(MK_DIR)/frontend/catalyst/lib $(MK_DIR)/frontend/catalyst/bin + rm -rf $(MK_DIR)/frontend/mlir_quantum $(MK_DIR)/frontend/catalyst/include $(MK_DIR)/frontend/catalyst/lib $(MK_DIR)/frontend/bin rm -rf dist __pycache__ rm -rf .coverage coverage_html_report rm -rf .benchmarks From e05ae0f1bc69bfa924e3315256e3111abb22ae11 Mon Sep 17 00:00:00 2001 From: David Ittah Date: Thu, 11 Dec 2025 13:11:10 -0500 Subject: [PATCH 2/4] Fix misleading package_root variable - now it points to the actual package root, not the utils directory - since we're using os.join, we should use it for all path separators --- .../catalyst/utils/runtime_environment.py | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/frontend/catalyst/utils/runtime_environment.py b/frontend/catalyst/utils/runtime_environment.py index 86ec00fd4f..699c88a956 100644 --- a/frontend/catalyst/utils/runtime_environment.py +++ b/frontend/catalyst/utils/runtime_environment.py @@ -22,37 +22,37 @@ from catalyst._configuration import INSTALLED -package_root = os.path.dirname(__file__) +package_root = os.path.join(os.path.dirname(__file__), "..") # Default paths to dep libraries DEFAULT_LIB_PATHS = { - "llvm": os.path.join(package_root, "../../../mlir/llvm-project/build/lib"), - "runtime": os.path.join(package_root, "../../../runtime/build/lib"), - "enzyme": os.path.join(package_root, "../../../mlir/Enzyme/build/Enzyme"), - "oqc_runtime": os.path.join(package_root, "../../catalyst/third_party/oqc/src/build"), - "oqd_runtime": os.path.join(package_root, "../../../runtime/build/lib"), + "llvm": os.path.join(package_root, "..", "..", "mlir", "llvm-project", "build", "lib"), + "runtime": os.path.join(package_root, "..", "..", "runtime", "build", "lib"), + "enzyme": os.path.join(package_root, "..", "..", "mlir", "Enzyme", "build", "Enzyme"), + "oqc_runtime": os.path.join(package_root, "third_party", "oqc", "src", "build"), + "oqd_runtime": os.path.join(package_root, "..", "..", "runtime", "build", "lib"), } DEFAULT_INCLUDE_PATHS = { - "mlir": os.path.join(package_root, "../../../mlir/include"), + "mlir": os.path.join(package_root, "..", "..", "mlir", "include"), } DEFAULT_BIN_PATHS = { - "cli": os.path.join(package_root, "../../../mlir/build/bin"), + "cli": os.path.join(package_root, "..", "..", "mlir", "build", "bin"), } def get_lib_path(project, env_var): - """Get the library path.""" + """Get the path to Catalyst's shared libraries.""" if INSTALLED: - return os.path.join(package_root, "..", "lib") # pragma: no cover + return os.path.join(package_root, "lib") # pragma: no cover return os.getenv(env_var, DEFAULT_LIB_PATHS.get(project, "")) def get_include_path(): """Return the path to Catalyst's include directory.""" if INSTALLED: - return os.path.join(package_root, "..", "include") # pragma: no cover + return os.path.join(package_root, "include") # pragma: no cover return os.getenv("CATALYST_INCLUDE_DIRS", DEFAULT_INCLUDE_PATHS.get("mlir", "")) From 949efa97214228c73f92d89cdd118f1a0cbee781 Mon Sep 17 00:00:00 2001 From: David Ittah Date: Thu, 11 Dec 2025 13:17:12 -0500 Subject: [PATCH 3/4] Remove obsolete get_bin_dir function - only used in a test, not even to get the bin dir but the lib dir - add catalyst dialects build dir to the default lib paths --- frontend/catalyst/utils/runtime_environment.py | 8 +------- frontend/test/lit/test_mlir_plugin.py | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/frontend/catalyst/utils/runtime_environment.py b/frontend/catalyst/utils/runtime_environment.py index 699c88a956..3f6d5aa660 100644 --- a/frontend/catalyst/utils/runtime_environment.py +++ b/frontend/catalyst/utils/runtime_environment.py @@ -27,6 +27,7 @@ # Default paths to dep libraries DEFAULT_LIB_PATHS = { "llvm": os.path.join(package_root, "..", "..", "mlir", "llvm-project", "build", "lib"), + "dialects": os.path.join(package_root, "..", "..", "mlir", "build", "lib"), "runtime": os.path.join(package_root, "..", "..", "runtime", "build", "lib"), "enzyme": os.path.join(package_root, "..", "..", "mlir", "Enzyme", "build", "Enzyme"), "oqc_runtime": os.path.join(package_root, "third_party", "oqc", "src", "build"), @@ -56,13 +57,6 @@ def get_include_path(): return os.getenv("CATALYST_INCLUDE_DIRS", DEFAULT_INCLUDE_PATHS.get("mlir", "")) -def get_bin_path(project, env_var): - """Get the library path.""" - if INSTALLED: - return os.path.join(package_root, "..", "bin") # pragma: no cover - return os.getenv(env_var, DEFAULT_BIN_PATHS.get(project, "")) - - def get_cli_path() -> str: # pragma: nocover """Method to obtain the Catalyst CLI path packaged via the data_files mechanism.""" catalyst_cli = "catalyst" diff --git a/frontend/test/lit/test_mlir_plugin.py b/frontend/test/lit/test_mlir_plugin.py index 3528c03188..a533a02248 100644 --- a/frontend/test/lit/test_mlir_plugin.py +++ b/frontend/test/lit/test_mlir_plugin.py @@ -69,7 +69,7 @@ def module(): import catalyst from catalyst import qjit from catalyst.compiler import _quantum_opt -from catalyst.utils.runtime_environment import get_bin_path +from catalyst.utils.runtime_environment import get_lib_path mlir_module = """ module @module { @@ -90,7 +90,7 @@ def module(): """ ext = "so" if platform.system() == "Linux" else "dylib" -plugin_path = get_bin_path("cli", "CATALYST_BIN_DIR") + f"/../lib/StandalonePlugin.{ext}" +plugin_path = get_lib_path("dialects", "") + f"/StandalonePlugin.{ext}" plugin = Path(plugin_path) custom_pipeline = [("run_only_plugin", ["builtin.module(apply-transform-sequence)"])] mlir_string = _quantum_opt( From fadc0714f24d7521f00483296cf449b79fb1bf1e Mon Sep 17 00:00:00 2001 From: David Ittah Date: Thu, 11 Dec 2025 13:22:53 -0500 Subject: [PATCH 4/4] Add cli path fallback for rare wheel setups The catalyst binary used to be shipped right within the package, under catalyst/bin. This is no longer the case, and now pip will install the binary into the dedicated binary folder for Python packages. However, we may still encounter a configuration where the binary is located in a bin folder next to the catalyst package folder, specifically: - after `make wheel` we'll have frontend/bin next to frontend/catalyst, although we rarely directly test this configuration since it's more of a setup to packaging the wheel. - when trying to emulate the above configuration for a quick frontend-only editable install, e.g. by extracting wheel contents over a checked out catalyst repo. --- frontend/catalyst/utils/runtime_environment.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/catalyst/utils/runtime_environment.py b/frontend/catalyst/utils/runtime_environment.py index 3f6d5aa660..901a02403b 100644 --- a/frontend/catalyst/utils/runtime_environment.py +++ b/frontend/catalyst/utils/runtime_environment.py @@ -82,6 +82,12 @@ def get_cli_path() -> str: # pragma: nocover if os.path.isfile(path): return path + # Check the old bin directory location, which in rare scenarios may still be used + # (e.g. the configuration after `make wheel` has been run). + path = os.path.join(package_root, "..", "bin", catalyst_cli) + if os.path.isfile(path): + return path + raise RuntimeError( "Could not locate the Catalyst executable, please report this issue on GitHub." )