aboutsummaryrefslogtreecommitdiff
path: root/Tools/Release/updatePICSAR.py
diff options
context:
space:
mode:
authorGravatar Axel Huebl <axel.huebl@plasma.ninja> 2021-02-18 20:15:52 -0800
committerGravatar GitHub <noreply@github.com> 2021-02-18 20:15:52 -0800
commit03650f39bbef3da49f2a4623da93d0b6b6ce11b7 (patch)
tree0a12f15924fbc203e41bfa1dcbfd2f1cb660eb5b /Tools/Release/updatePICSAR.py
parent04c5a487106127d5f4a24a5c6f6c1c5bc8153c3c (diff)
downloadWarpX-03650f39bbef3da49f2a4623da93d0b6b6ce11b7.tar.gz
WarpX-03650f39bbef3da49f2a4623da93d0b6b6ce11b7.tar.zst
WarpX-03650f39bbef3da49f2a4623da93d0b6b6ce11b7.zip
Tool: update AMReX dependency (#1710)
* Tool: update AMReX dependency We currently pull the `development` branch of AMReX in CMake builds. This is problematic in central workflows: - checking out a release might not compile - manual intervention is needed by users - builds are not as reproducibile as they could be - CI fails in a surprising wary in WarpX if a temporary bug is lands in AMReX' `development` Instead, we can bump the AMReX requirement periodically in a PR. This migh be the case when we: - need new features or bug fixes - do a release Manual updates guarantee that we see problems with updates from AMReX in the moment they are introduced - during a PR that changes the dependency to AMReX. * Tool: update PICSAR dependency See AMReX' updater description. * Docs: Dependencies & Releases Update and add workflows. * PICSAR & AMReX: Bump Version to HEAD Bump the PICSAR and AMReX versions to the latest head. Executed with: ``` ./Tools/Release/updateAMReX.py ./Tools/Release/updatePICSAR.py ``` * Python Tools: Cleanup * Fix typos Co-authored-by: Luca Fedeli <luca.fedeli@for.unipi.it> Co-authored-by: Luca Fedeli <luca.fedeli@for.unipi.it>
Diffstat (limited to 'Tools/Release/updatePICSAR.py')
-rwxr-xr-xTools/Release/updatePICSAR.py138
1 files changed, 138 insertions, 0 deletions
diff --git a/Tools/Release/updatePICSAR.py b/Tools/Release/updatePICSAR.py
new file mode 100755
index 000000000..a3c3f79fc
--- /dev/null
+++ b/Tools/Release/updatePICSAR.py
@@ -0,0 +1,138 @@
+#!/usr/bin/env python3
+#
+# Copyright 2021 Axel Huebl
+#
+# This file is part of WarpX.
+#
+
+# This file is a maintainer tool to bump the PICSAR version that we pull in
+# when building WarpX.
+#
+import datetime
+from pathlib import Path
+import re
+import requests
+import sys
+
+
+# Maintainer Inputs ###########################################################
+
+print("""Hi there, this is a WarpX maintainer tool to update the source
+code of WarpX to a new commit/release of PICSAR.
+For it to work, you need write access on the source directory and
+you should be working in a clean git branch without ongoing
+rebase/merge/conflict resolves and without unstaged changes.""")
+
+# check source dir
+REPO_DIR = Path(__file__).parent.parent.parent.absolute()
+print(f"\nYour current source directory is: {REPO_DIR}")
+
+REPLY = input("Are you sure you want to continue? [y/N] ")
+print()
+if not REPLY in ["Y", "y"]:
+ print("You did not confirm with 'y', aborting.")
+ sys.exit(1)
+
+
+# Current Versions ############################################################
+
+# PICSAR development HEAD
+PICSAR_gh = requests.get('https://api.github.com/repos/ECP-WarpX/picsar/commits/development')
+PICSAR_HEAD = PICSAR_gh.json()["sha"]
+
+# WarpX references to PICSAR: cmake/dependencies/PICSAR.cmake
+PICSAR_cmake_path = str(REPO_DIR.joinpath("cmake/dependencies/PICSAR.cmake"))
+# branch/commit/tag (git fetcher) version
+# set(WarpX_picsar_branch "development" ...
+PICSAR_branch = f"unknown (format issue in {PICSAR_cmake_path})"
+with open(PICSAR_cmake_path, encoding='utf-8') as f:
+ r_minimal = re.findall(r'.*set\(WarpX_picsar_branch\s+"(.+)"\s+.*',
+ f.read(), re.MULTILINE)
+ if len(r_minimal) >= 1:
+ PICSAR_branch = r_minimal[0]
+
+# minimal (external) version
+# find_package(PICSAR YY.MM CONFIG ...
+PICSAR_minimal = f"unknown (format issue in {PICSAR_cmake_path})"
+with open(PICSAR_cmake_path, encoding='utf-8') as f:
+ r_minimal = re.findall(r'.*find_package\(PICSAR\s+(.+)\s+CONFIG\s+.*',
+ f.read(), re.MULTILINE)
+ if len(r_minimal) >= 1:
+ PICSAR_minimal = r_minimal[0]
+
+
+# Ask for new #################################################################
+
+print("""We will now run a few sed commands on your source directory.
+Please answer the following questions about the version number
+you want to require from PICSAR:\n""")
+
+print(f"Currently, WarpX builds against this PICSAR commit/branch/sha: {PICSAR_branch}")
+print(f"PICSAR HEAD commit (development branch): {PICSAR_HEAD}")
+PICSAR_new_branch = input(f"Update PICSAR commit/branch/sha: ").strip()
+if not PICSAR_new_branch:
+ PICSAR_new_branch = PICSAR_branch
+ print(f"--> Nothing entered, will keep: {PICSAR_branch}")
+print()
+
+print(f"Currently, a pre-installed PICSAR is required at least at version: {PICSAR_minimal}")
+today = datetime.date.today().strftime("%y.%m")
+PICSAR_new_minimal = input(f"New minimal PICSAR version (e.g. {today})? ").strip()
+if not PICSAR_new_minimal:
+ PICSAR_new_minimal = PICSAR_minimal
+ print(f"--> Nothing entered, will keep: {PICSAR_minimal}")
+
+print()
+print(f"New PICSAR commit/branch/sha: {PICSAR_new_branch}")
+print(f"New minimal PICSAR version: {PICSAR_new_minimal}\n")
+
+REPLY = input("Is this information correct? Will now start updating! [y/N] ")
+print()
+if not REPLY in ["Y", "y"]:
+ print("You did not confirm with 'y', aborting.")
+ sys.exit(1)
+
+
+# Updates #####################################################################
+
+# run_test.sh (used also for Azure Pipelines)
+run_test_path = str(REPO_DIR.joinpath("run_test.sh"))
+with open(run_test_path, encoding='utf-8') as f:
+ run_test_content = f.read()
+ # branch/commit/tag (git fetcher) version
+ # git clone --branch development https://github.com/PICSAR-Codes/PICSAR.git
+ run_test_content = re.sub(
+ r'(.*git\s+clone\s+\-\-branch\s+)(.+)(\s+https://github\.com/ECP\-WarpX/picsar\.git)',
+ r'\g<1>{}\g<3>'.format(PICSAR_new_branch),
+ run_test_content, flags = re.MULTILINE)
+
+with open(run_test_path, "w", encoding='utf-8') as f:
+ f.write(run_test_content)
+
+# WarpX references to PICSAR: cmake/dependencies/PICSAR.cmake
+with open(PICSAR_cmake_path, encoding='utf-8') as f:
+ PICSAR_cmake_content = f.read()
+
+ # branch/commit/tag (git fetcher) version
+ # set(WarpX_picsar_branch "development" ...
+ PICSAR_cmake_content = re.sub(
+ r'(.*set\(WarpX_picsar_branch\s+")(.+)("\s+.*)',
+ r'\g<1>{}\g<3>'.format(PICSAR_new_branch),
+ PICSAR_cmake_content, flags = re.MULTILINE)
+
+ # minimal (external) version
+ # find_package(PICSAR YY.MM CONFIG ...
+ PICSAR_cmake_content = re.sub(
+ r'(.*find_package\(PICSAR\s+)(.+)(\s+CONFIG\s+.*)',
+ r'\g<1>{}\g<3>'.format(PICSAR_new_minimal),
+ PICSAR_cmake_content, flags = re.MULTILINE)
+
+with open(PICSAR_cmake_path, "w", encoding='utf-8') as f:
+ f.write(PICSAR_cmake_content)
+
+
+# Epilogue ####################################################################
+
+print("""Done. Please check your source, e.g. via
+ git diff
+now and commit the changes if no errors occurred.""")