Skip to content

Commit

Permalink
Point to the right Lightning root folder independently from the invoc…
Browse files Browse the repository at this point in the history
…ation folder (#874)

**Context:** `configure_pyproject_toml.py` assumes it is being invoked
from the root directory of Lightning. But the reality is that it can be
invoked from anywhere else.

**Description of the Change:** Calculate safely the root folder by
traversing back the folder structure starting from the current file
location.

**Benefits:** The file can be invoked from any place.

---------

Co-authored-by: ringo-but-quantum <[email protected]>
  • Loading branch information
rauletorresc and ringo-but-quantum authored Aug 29, 2024
1 parent 2189af1 commit 756eb7b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@
* Fix checkout command in test workflows for rc branches.
[(#777)](https://github.com/PennyLaneAI/pennylane-lightning/pull/777)

* Point to the right Lightning root folder independently from the invocation location, when configuring the project.
[(#874)](https://github.com/PennyLaneAI/pennylane-lightning/pull/874)

### Contributors

This release contains contributions from (in alphabetical order):
Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.38.0-dev51"
__version__ = "0.38.0-dev52"
8 changes: 7 additions & 1 deletion scripts/configure_pyproject_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import toml
from backend_support import backend, device_name

path_to_version = Path("pennylane_lightning").absolute() / "core" / "_version.py"
path_to_project = Path(__file__).parent.parent.absolute()

path_to_version = path_to_project / Path("pennylane_lightning") / "core" / "_version.py"
with open(path_to_version, encoding="utf-8") as f:
version = f.readlines()[-1].split()[-1].strip("\"'")

Expand Down Expand Up @@ -49,6 +51,10 @@ def parse_args():

if __name__ == "__main__":
parsed_args = parse_args()

if parsed_args.path.strip() == "":
parsed_args.path = path_to_project.as_posix()

pyproject_path = os.path.join(parsed_args.path, "pyproject.toml")

pyproject = toml.load(pyproject_path)
Expand Down

0 comments on commit 756eb7b

Please sign in to comment.