diff --git a/Python/setup.py b/Python/setup.py index 13f2dc370ee..87f4ebbbf5b 100644 --- a/Python/setup.py +++ b/Python/setup.py @@ -64,11 +64,12 @@ else: package_data = {} -# Parse WarpX version information +# Parse WarpX, PICMI versions information dependencies_file = "../dependencies.json" with open(dependencies_file, "r") as file: dependencies_data = json.load(file) warpx_version = dependencies_data.get("version_warpx") +picmi_version = dependencies_data.get("version_picmi") setup( name="pywarpx", @@ -77,7 +78,7 @@ package_dir={"pywarpx": "pywarpx"}, description="""Wrapper of WarpX""", package_data=package_data, - install_requires=["numpy", "picmistandard==0.34.0", "periodictable"], + install_requires=["numpy", f"picmistandard=={picmi_version}", "periodictable"], python_requires=">=3.8", # left for CI, truly ">=3.9" zip_safe=False, ) diff --git a/Tools/Release/update_dependencies.py b/Tools/Release/update_dependencies.py index 0ee4df1da63..6473b5a5cc6 100755 --- a/Tools/Release/update_dependencies.py +++ b/Tools/Release/update_dependencies.py @@ -42,6 +42,22 @@ def update(args): repo_dict["picsar"]["tags"] = ( "https://api.github.com/repos/ECP-WarpX/picsar/tags" ) + if args.all or args.pybind11: + repo_dict["pybind11"] = {} + repo_dict["pybind11"]["commit"] = ( + "https://api.github.com/repos/pybind/pybind11/commits/master" + ) + repo_dict["pybind11"]["tags"] = ( + "https://api.github.com/repos/pybind/pybind11/tags" + ) + if args.all or args.picmi: + repo_dict["picmi"] = {} + repo_dict["picmi"]["commit"] = ( + "https://api.github.com/repos/picmi-standard/picmi/commits/master" + ) + repo_dict["picmi"]["tags"] = ( + "https://api.github.com/repos/picmi-standard/picmi/tags" + ) if args.all or args.warpx: repo_dict["warpx"] = {} repo_dict["warpx"]["commit"] = ( @@ -56,6 +72,8 @@ def update(args): "amrex": "AMReX", "pyamrex": "pyAMReX", "picsar": "PICSAR", + "pybind11": "pybind11", + "picmi": "PICMI", "warpx": "WarpX", } @@ -72,17 +90,22 @@ def update(args): # loop over repositories and update dependencies data for repo_name, repo_subdict in repo_dict.items(): print(f"\nUpdating {repo_labels[repo_name]}...") + # set keys to access dependencies data commit_key = f"commit_{repo_name}" version_key = f"version_{repo_name}" + # get new commit information commit_response = requests.get(repo_subdict["commit"]) commit_dict = commit_response.json() + # set new commit repo_commit_sha = commit_dict["sha"] + # get new version tag information tags_response = requests.get(repo_subdict["tags"]) tags_list = tags_response.json() + # filter out old-format tags for specific repositories tags_list_filtered = copy.deepcopy(tags_list) if repo_name == "amrex": @@ -97,6 +120,7 @@ def update(args): for tag_dict in tags_list if (tag_dict["name"] != "PICSARlite-0.1") ] + # set new version tag if repo_name == "warpx": # current date version for the WarpX release update @@ -104,8 +128,11 @@ def update(args): else: # latest available tag (index 0) for all other dependencies repo_version_tag = tags_list_filtered[0]["name"] - # use version tag instead of commit sha for a release update - new_commit_sha = repo_version_tag if args.release else repo_commit_sha + + # use version tag instead of commit sha for a release update or for pybind11 + use_version_tag = args.release or (repo_name == "pybind11") + new_commit_sha = repo_version_tag if use_version_tag else repo_commit_sha + # update commit if repo_name != "warpx": print(f"- old commit: {dependencies_data[commit_key]}") @@ -115,6 +142,7 @@ def update(args): else: print("Updating commit...") dependencies_data[f"commit_{repo_name}"] = new_commit_sha + # update version print(f"- old version: {dependencies_data[version_key]}") print(f"- new version: {repo_version_tag}") @@ -124,6 +152,21 @@ def update(args): print("Updating version...") dependencies_data[f"version_{repo_name}"] = repo_version_tag + # update PICMI version in requirements.txt files manually + if repo_name == "picmi": + files = [ + os.path.join(repo_dir, "requirements.txt"), + os.path.join(repo_dir, "Docs", "requirements.txt"), + ] + for filename in files: + with open(filename) as f: + lines = f.readlines() + with open(filename, "w") as f: + for line in lines: + if line.startswith("picmistandard=="): + line = f"picmistandard=={repo_version_tag}\n" + f.write(line) + # write to JSON file with dependencies data with open(dependencies_file, "w") as file: json.dump(dependencies_data, file, indent=4) @@ -157,6 +200,22 @@ def update(args): dest="picsar", ) + # add arguments: pybind11 option + parser.add_argument( + "--pybind11", + help="Update pybind11 only", + action="store_true", + dest="pybind11", + ) + + # add arguments: PICMI option + parser.add_argument( + "--picmi", + help="Update PICMI only", + action="store_true", + dest="picmi", + ) + # add arguments: WarpX option parser.add_argument( "--warpx", @@ -178,7 +237,16 @@ def update(args): # set args.all automatically args.all = ( - False if (args.amrex or args.pyamrex or args.picsar or args.warpx) else True + False + if ( + args.amrex + or args.pyamrex + or args.picsar + or args.pybind11 + or args.picmi + or args.warpx + ) + else True ) # update diff --git a/cmake/dependencies/pybind11.cmake b/cmake/dependencies/pybind11.cmake index ee8560a24a2..bbdf25e7845 100644 --- a/cmake/dependencies/pybind11.cmake +++ b/cmake/dependencies/pybind11.cmake @@ -37,7 +37,7 @@ function(find_pybind11) mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FETCHEDpybind11) endif() else() - find_package(pybind11 3.0.1 CONFIG REQUIRED) + find_package(pybind11 ${pybind11_version} CONFIG REQUIRED) message(STATUS "pybind11: Found version '${pybind11_VERSION}'") endif() endfunction() @@ -52,7 +52,16 @@ option(WarpX_pybind11_internal "Download & build pybind11" ON) set(WarpX_pybind11_repo "https://github.com/pybind/pybind11.git" CACHE STRING "Repository URI to pull and build pybind11 from if(WarpX_pybind11_internal)") -set(WarpX_pybind11_branch "v3.0.1" + +# Parse pybind11 version and commit information +file(READ "${WarpX_SOURCE_DIR}/dependencies.json" dependencies_data) +string(JSON pybind11_version GET "${dependencies_data}" version_pybind11) +string(JSON pybind11_commit GET "${dependencies_data}" commit_pybind11) + +# Strip "v" prefix from version for find_package +string(REGEX REPLACE "^v" "" pybind11_version "${pybind11_version}") + +set(WarpX_pybind11_branch ${pybind11_commit} CACHE STRING "Repository branch for WarpX_pybind11_repo if(WarpX_pybind11_internal)") diff --git a/dependencies.json b/dependencies.json index 9e190ed771b..577cadbf4a2 100644 --- a/dependencies.json +++ b/dependencies.json @@ -3,7 +3,11 @@ "version_amrex": "25.11", "version_pyamrex": "25.11", "version_picsar": "25.06", + "version_pybind11": "v3.0.1", + "version_picmi": "0.34.0", "commit_amrex": "c4fcda1fb2ea238c3e6fa273dc9cfcde54b4cc51", "commit_pyamrex": "5fc00b46b2a60b2c20b9067500c4b68f709ccb94", - "commit_picsar": "0c329e66010267662a82219f7de7abbd231463f4" + "commit_picsar": "0c329e66010267662a82219f7de7abbd231463f4", + "commit_pybind11": "v3.0.1", + "commit_picmi": "e79dc49c58ad65b5e207ed40e4e6edc4b1482241" } \ No newline at end of file