From 2ed6bb797b8f564b0378983c60f1a28258b84801 Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Tue, 6 Aug 2024 11:17:03 +0200 Subject: [PATCH] finish mpich test --- .../modify_recipe.py | 12 +++++---- tests/data/version/mpich/expected.yaml | 27 +++++++++++++++++++ tests/test_recipe_modification.py | 9 +++++++ 3 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 tests/data/version/mpich/expected.yaml diff --git a/src/rattler_build_conda_compat/modify_recipe.py b/src/rattler_build_conda_compat/modify_recipe.py index ffbeecb..e8aed5a 100644 --- a/src/rattler_build_conda_compat/modify_recipe.py +++ b/src/rattler_build_conda_compat/modify_recipe.py @@ -105,17 +105,19 @@ def update_hash(source: Source, url: str, hash_: Hash | None) -> None: * `url` - The URL to download and hash (if no hash is provided). * `hash_` - The hash to use. If not provided, the file will be downloaded and `sha256` hashed. """ - if "md5" in source: - del source["md5"] - if "sha256" in source: - del source["sha256"] + hash_type = hash_.hash_type if hash_ is not None else "sha256" + # delete all old hashes that we are not updating + all_hash_types = {"md5", "sha256"} + for key in all_hash_types - {hash_type}: + if key in source: + del source[key] if hash_ is not None: source[hash_.hash_type] = hash_.hash_value else: # download and hash the file hasher = hashlib.sha256() - logger.info("Retrieving and hashing %s", url) + print(f"Retrieving and hashing {url}") with requests.get(url, stream=True, timeout=100) as r: for chunk in r.iter_content(chunk_size=4096): hasher.update(chunk) diff --git a/tests/data/version/mpich/expected.yaml b/tests/data/version/mpich/expected.yaml new file mode 100644 index 0000000..e759e4c --- /dev/null +++ b/tests/data/version/mpich/expected.yaml @@ -0,0 +1,27 @@ +context: + version: 4.1.1 + build: 0 + version_url: ${{ version if version[-2:] != ".0" else version[:-2] }} + computed_build: ${{ build + 100 if mpi_type == 'conda' else build }} + +package: + # must not match any outputs for requirements to be handled correctly + name: mpich-mpi + version: ${{ version }} + +source: + file_name: mpich-${{ version }}.tar.gz + url: https://www.mpich.org/static/downloads/${{ version_url }}/mpich-${{ version_url }}.tar.gz + sha256: ee30471b35ef87f4c88f871a5e2ad3811cd9c4df32fd4f138443072ff4284ca2 + patches: + - libfrabric-osx-lock.patch + - libfrabric-osx-memsize.patch + +build: + number: ${{ build }} + skip: + - win + +extra: + recipe-maintainers: + - mpich diff --git a/tests/test_recipe_modification.py b/tests/test_recipe_modification.py index a36662b..51fc476 100644 --- a/tests/test_recipe_modification.py +++ b/tests/test_recipe_modification.py @@ -39,3 +39,12 @@ def test_multi_source(data_dir: Path) -> None: result = update_version(test_recipe, "3.7.0", None) expected = test_recipe.parent / "expected.yaml" assert result == expected.read_text() + + +def test_mpich(data_dir: Path) -> None: + tests = data_dir / "version" + test_recipe = tests / "mpich/recipe.yaml" + result = update_version(test_recipe, "4.1.1", None) + print(result) + expected = test_recipe.parent / "expected.yaml" + assert result == expected.read_text()