Skip to content

Commit

Permalink
Merge branch 'main' into joeycarter/update-changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
joeycarter authored Jan 15, 2025
2 parents 45f5833 + 64f3aad commit 2d1c4bd
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .dep-versions
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ enzyme=v0.0.149

# For a custom PL version, update the package version here and at
# 'doc/requirements.txt
pennylane=0.40.0
# pennylane=0.41.0-dev1

# For a custom LQ/LK version, update the package version here and at
# 'doc/requirements.txt'
lightning=0.40.0
# lightning=0.41.0-dev1
4 changes: 0 additions & 4 deletions .github/workflows/check-catalyst.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,6 @@ jobs:
- name: Checkout Catalyst repo
uses: actions/checkout@v4

- name: Install lightning.kokkos used in Python tests
run: |
pip install PennyLane-Lightning-Kokkos==0.39.0 --extra-index-url https://test.pypi.org/simple
- name: Install Deps
run: |
sudo apt-get update
Expand Down
63 changes: 57 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import glob
import os
import platform
import re
import subprocess
import sys
from typing import Optional
Expand Down Expand Up @@ -50,13 +51,63 @@
f.write("# AUTOGENERATED by setup.py!\n")
f.write(f"__revision__ = '{REVISION}'\n")

with open(".dep-versions", encoding="utf-8") as f:
lines = f.readlines()
jax_version = next(line[4:].strip() for line in lines if "jax=" in line)
pl_version = next((line[10:].strip() for line in lines if "pennylane=" in line), None)
lq_version = next((line[10:].strip() for line in lines if "lightning=" in line), None)

pl_min_release = 0.40
def parse_dep_versions():
"""Parse the version strings of the Catalyst package dependencies based on the values found in
the .dep-versions file.
Search patterns must be added manually; this function will not automatically parse patterns like
<package>=x.y.z
Example
-------
If the .dep-versions file is
jax=0.4.28
pennylane=0.40.0
# lightning=0.40.0
The version strings for jax and pennylane will be returned, but the version string for lightning
is omitted because it has been commented out:
>>> parse_dep_version()
{"jax": "0.4.28", "pennylane": "0.40.0"}
Returns:
dict: Dictionary of dependency versions
"""
results = {}
pattern_jax = re.compile(r"^jax=(\S+)", re.MULTILINE)
pattern_pl = re.compile(r"^pennylane=(\S+)", re.MULTILINE)
pattern_lq = re.compile(r"^lightning=(\S+)", re.MULTILINE)

with open(".dep-versions", encoding="utf-8") as fin:
lines = fin.read()

match_jax = pattern_jax.search(lines)
match_pl = pattern_pl.search(lines)
match_lq = pattern_lq.search(lines)

if match_jax is not None:
results["jax"] = match_jax.group(1)

if match_pl is not None:
results["pennylane"] = match_pl.group(1)

if match_lq is not None:
results["lightning"] = match_lq.group(1)

return results


dep_versions = parse_dep_versions()
jax_version = dep_versions.get("jax")
pl_version = dep_versions.get("pennylane")
lq_version = dep_versions.get("lightning")

pl_min_release = "0.40"
lq_min_release = pl_min_release

if pl_version is not None:
Expand Down

0 comments on commit 2d1c4bd

Please sign in to comment.