Skip to content

Commit

Permalink
Add back extra-path
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcarcell committed Mar 18, 2024
1 parent c24cb69 commit a78accb
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions scripts/fetch_nightly_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ def get_latest_commit(
description="Add latest commits to a spack environment"
)
parser.add_argument(
"path",
help="path to the current environment",
default="/key4hep-spack",
"--path",
help="path to a yaml file with spack packages",
)
parser.add_argument(
"--extra-path",
help="path to a yaml file with spack packages",
)
parser.add_argument(
"date",
Expand All @@ -66,12 +69,19 @@ def get_latest_commit(
date = args.date

try:
with open(os.path.join(args.path, "packages.yaml"), "r") as recipe:
with open(args.path, "r") as recipe:
text = yaml.safe_load(recipe)
except FileNotFoundError:
print("Please run this script from the key4hep-spack repository.")
raise

try:
with open(args.extra_path, "r") as recipe:
text_extra = yaml.safe_load(recipe)
except FileNotFoundError:
print("Please run this script from the key4hep-spack repository.")
raise

for package, location in [
("aidatt", "aidasoft/aidatt"),
("ced", "ilcsoft/ced"),
Expand Down Expand Up @@ -135,11 +145,24 @@ def get_latest_commit(
line = f"@{commit}"
if package not in ["cepcsw"]:
line += "=develop"
original = " "
if package in text["packages"] and "require" in text["packages"][package]:
original = text["packages"][package]["require"]
text["packages"][package]["require"] = line + original
elif (
package in text_extra["packages"]
and "require" in text_extra["packages"][package]
):
original = text_extra["packages"][package]["require"]
text_extra["packages"][package]["require"] = line + original

if not text["packages"][package]:
print(f"Adding {package}@{commit} to the key4hep-stack package.py")
else:
print(f"Updating {package}@{commit} in the key4hep-stack package.py")
text["packages"][package]["require"] = line

with open(os.path.join(args.path, "packages.yaml"), "w") as recipe:
with open(args.path, "w") as recipe:
yaml.dump(text, recipe)
with open(args.extra_path, "w") as recipe:
yaml.dump(text_extra, recipe)

0 comments on commit a78accb

Please sign in to comment.