Skip to content

Commit

Permalink
finish mpich test
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Aug 6, 2024
1 parent 92876d8 commit 2ed6bb7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/rattler_build_conda_compat/modify_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 27 additions & 0 deletions tests/data/version/mpich/expected.yaml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions tests/test_recipe_modification.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 2ed6bb7

Please sign in to comment.