From a78accba9a236588458dd98b1ceae0bff2f560ea Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Mon, 18 Mar 2024 16:48:09 +0100 Subject: [PATCH] Add back extra-path --- scripts/fetch_nightly_versions.py | 33 ++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/scripts/fetch_nightly_versions.py b/scripts/fetch_nightly_versions.py index 5efb9b81..bd21bdea 100755 --- a/scripts/fetch_nightly_versions.py +++ b/scripts/fetch_nightly_versions.py @@ -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", @@ -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"), @@ -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)