From c719ac7f65e0536b53076d2ac4c24254178ab977 Mon Sep 17 00:00:00 2001 From: Joseph Lee <40768758+josephleekl@users.noreply.github.com> Date: Fri, 18 Oct 2024 11:26:28 -0400 Subject: [PATCH] Fix LK catalyst shared object copy for linux/mac only (#947) ### Before submitting Please complete the following checklist when submitting a PR: - [ ] All new features must include a unit test. If you've fixed a bug or added code that should be tested, add a test to the [`tests`](../tests) directory! - [ ] All new functions and code must be clearly commented and documented. If you do make documentation changes, make sure that the docs build and render correctly by running `make docs`. - [ ] Ensure that the test suite passes, by running `make test`. - [x] Add a new entry to the `.github/CHANGELOG.md` file, summarizing the change, and including a link back to the PR. - [x] Ensure that code is properly formatted by running `make format`. When all the above are checked, delete everything above the dashed line and fill in the pull request template. ------------------------------------------------------------------------------------------------------------ **Context:** This is a fix for [this PR](https://github.com/PennyLaneAI/pennylane-lightning/pull/945) failing lightning kokkos build for non-linux systems. [sc-76296] **Description of the Change:** **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** --------- Co-authored-by: ringo-but-quantum Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com> Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com> --- .github/CHANGELOG.md | 3 +++ pennylane_lightning/core/_version.py | 2 +- setup.py | 8 +++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 1f4059f9e2..348164054c 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -119,6 +119,9 @@ ### Bug fixes +* Fix build failure for Lightning-Kokkos editable installation on MacOS due to `liblightning_kokkos_catalyst.so` copy. + [(#947)](https://github.com/PennyLaneAI/pennylane-lightning/pull/947) + * Fix missing `liblightning_kokkos_catalyst.so` in Lightning-Kokkos editable installation. [(#945)](https://github.com/PennyLaneAI/pennylane-lightning/pull/945) diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index 93371827c9..37f7ba1bbf 100644 --- a/pennylane_lightning/core/_version.py +++ b/pennylane_lightning/core/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.39.0-dev45" +__version__ = "0.39.0-dev46" diff --git a/setup.py b/setup.py index 7e6e080e96..0ef706955f 100644 --- a/setup.py +++ b/setup.py @@ -158,9 +158,11 @@ def build_extension(self, ext: CMakeExtension): # Ensure that catalyst shared object is copied to the build directory for pip editable install if backend in ("lightning_kokkos"): - source = os.path.join(f"{extdir}", f"lib{backend}_catalyst.so") - destination = os.path.join(os.getcwd(), "build") - shutil.copy(source, destination) + if platform.system() in ["Linux", "Darwin"]: + shared_lib_ext = {"Linux": ".so", "Darwin": ".dylib"}[platform.system()] + source = os.path.join(f"{extdir}", f"lib{backend}_catalyst{shared_lib_ext}") + destination = os.path.join(os.getcwd(), "build") + shutil.copy(source, destination) with open(os.path.join("pennylane_lightning", "core", "_version.py"), encoding="utf-8") as f: version = f.readlines()[-1].split()[-1].strip("\"'")