Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 18 additions & 18 deletions frontend/catalyst/utils/runtime_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,47 +22,41 @@

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"),
"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"),
"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", ""))


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"
Expand All @@ -88,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."
)
4 changes: 2 additions & 2 deletions frontend/test/lit/test_mlir_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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(
Expand Down
Loading