Skip to content

Commit 6bfd9b2

Browse files
fix: handle split keys in lists for recipe parsing (#4851)
* fix: handle split keys in lists for recipe parsing * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * test: add test for recipe parsing of libcudss Add test for parsing libcudss recipe with various configurations. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update tests/test_recipe_parser.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent a1e2242 commit 6bfd9b2

File tree

2 files changed

+230
-1
lines changed

2 files changed

+230
-1
lines changed

conda_forge_tick/recipe_parser/_parser.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,10 @@ def _unmunge_split_key_value_pairs_with_selectors(lines):
230230
for line in lines:
231231
if (
232232
len(line.lstrip()) > 0
233-
and line.lstrip()[0] == "?"
233+
and (
234+
(len(line.split()) > 1 and line.split()[0:2] == ["-", "?"])
235+
or (len(line.split()) > 0 and line.split()[0] == "?")
236+
)
234237
and ":" not in line
235238
and CONDA_SELECTOR in line
236239
):

tests/test_recipe_parser.py

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,6 +1586,232 @@ def test_recipe_parses_cupy():
15861586
assert s.read() == recipe_parsed
15871587

15881588

1589+
def test_recipe_parses_libcudss():
1590+
recipe = r"""{% set version = "0.7.0.20" %}
1591+
{% set soversion = ".".join(version.split(".")[:3]) %}
1592+
{% set somajor = version.split(".")[0] %}
1593+
1594+
package:
1595+
name: libcudss-split
1596+
version: {{ version }}
1597+
1598+
{% set arm_variant_type = arm_variant_type | default("sbsa") %}
1599+
{% set cuda_compiler_version = cuda_compiler_version | default("None") %}
1600+
1601+
source:
1602+
- url: "https://developer.download.nvidia.com/compute/cudss/redist/libcudss/linux-x86_64/libcudss-linux-x86_64-{{ version }}_cuda12-archive.tar.xz" # [linux and x86_64 and (cuda_compiler_version or "").startswith("12")]
1603+
sha256: "c98d5ef87e8b6a356b21a678715033b19620ce58b5fa64c97e25e6d3e76e42dc" # [linux and x86_64 and (cuda_compiler_version or "").startswith("12")]
1604+
- url: "https://developer.download.nvidia.com/compute/cudss/redist/libcudss/linux-x86_64/libcudss-linux-x86_64-{{ version }}_cuda13-archive.tar.xz" # [linux and x86_64 and (cuda_compiler_version or "").startswith("13")]
1605+
sha256: "939606e8d062ee0fc28094e7be19e22191662e8593bc7f5eec16220ad836feb9" # [linux and x86_64 and (cuda_compiler_version or "").startswith("13")]
1606+
- url: "https://developer.download.nvidia.com/compute/cudss/redist/libcudss/linux-sbsa/libcudss-linux-sbsa-{{ version }}_cuda12-archive.tar.xz" # [linux and aarch64 and (cuda_compiler_version or "").startswith("12") and arm_variant_type == "sbsa"]
1607+
sha256: "92f3425e7badcd2d6324efbe8c7ca314a36295ab550238f7772137c3652d7884" # [linux and aarch64 and (cuda_compiler_version or "").startswith("12") and arm_variant_type == "sbsa"]
1608+
- url: "https://developer.download.nvidia.com/compute/cudss/redist/libcudss/linux-sbsa/libcudss-linux-sbsa-{{ version }}_cuda13-archive.tar.xz" # [linux and aarch64 and (cuda_compiler_version or "").startswith("13") and arm_variant_type == "sbsa"]
1609+
sha256: "f915eb581ab965d0baa74cd1e529086fce00e9d14d9366da4480b5ef7fabb8a6" # [linux and aarch64 and (cuda_compiler_version or "").startswith("13") and arm_variant_type == "sbsa"]
1610+
- url: "https://developer.download.nvidia.com/compute/cudss/redist/libcudss/windows-x86_64/libcudss-windows-x86_64-{{ version }}_cuda12-archive.zip" # [win and x86_64 and (cuda_compiler_version or "").startswith("12")]
1611+
sha256: "69b7e5dc98f2d6242eb8e072d7a73e1f573d8a1bb65d97463ba72e9334d67f58" # [win and x86_64 and (cuda_compiler_version or "").startswith("12")]
1612+
- url: "https://developer.download.nvidia.com/compute/cudss/redist/libcudss/windows-x86_64/libcudss-windows-x86_64-{{ version }}_cuda13-archive.zip" # [win and x86_64 and (cuda_compiler_version or "").startswith("13")]
1613+
sha256: "a35f34a1995b5951cfe5b625e17d33ebe0e7e487476b5315a229cf348dcc2c0b" # [win and x86_64 and (cuda_compiler_version or "").startswith("13")]
1614+
- url: "https://developer.download.nvidia.com/compute/cudss/redist/libcudss/linux-aarch64/libcudss-linux-aarch64-{{ version }}_cuda12-archive.tar.xz" # [linux and aarch64 and (cuda_compiler_version or "").startswith("12") and arm_variant_type == "tegra"]
1615+
sha256: "ce3de5e6a0cee00fd1fc355881308ef0c692c6e14b6a5625aa35a7f9df98b846" # [linux and aarch64 and (cuda_compiler_version or "").startswith("12") and arm_variant_type == "tegra"]
1616+
- url: "https://developer.download.nvidia.com/compute/cudss/redist/libcudss/linux-aarch64/libcudss-linux-aarch64-{{ version }}_cuda13-archive.tar.xz" # [linux and aarch64 and (cuda_compiler_version or "").startswith("13") and arm_variant_type == "tegra"]
1617+
sha256: "c33768ac50caa36103facfec21a32b2c65ed1f1f085eaf153091dcaf734fdfc6" # [linux and aarch64 and (cuda_compiler_version or "").startswith("13") and arm_variant_type == "tegra"]
1618+
1619+
build:
1620+
number: 0
1621+
skip: true # [(cuda_compiler_version in (None, "None", "11.8")) or (not (linux64 or aarch64 or win64))]
1622+
script: # [win]
1623+
- xcopy include %LIBRARY_INC% /E /I /Y /V # [win]
1624+
- xcopy lib %LIBRARY_LIB% /E /I /Y /V # [win]
1625+
- xcopy bin %LIBRARY_BIN% /E /I /Y /V # [win]
1626+
1627+
requirements:
1628+
build:
1629+
- {{ compiler('c') }}
1630+
- {{ compiler('cuda') }}
1631+
- {{ compiler('cxx') }}
1632+
- {{ stdlib("c") }}
1633+
- cf-nvidia-tools 1 # [linux]
1634+
1635+
outputs:
1636+
1637+
- name: libcudss
1638+
build:
1639+
ignore_run_exports_from:
1640+
- libcublas-dev
1641+
ignore_run_exports:
1642+
- cuda-version
1643+
files:
1644+
- lib/libcudss.so.* # [linux]
1645+
- lib/libcudss_mtlayer_*.so.* # [linux]
1646+
- Library/bin/cudss64_{{ somajor }}.dll # [win]
1647+
- Library/bin/cudss_mtlayer_*.dll # [win]
1648+
requirements:
1649+
build:
1650+
- {{ compiler('c') }}
1651+
- {{ compiler('cuda') }}
1652+
- {{ compiler('cxx') }}
1653+
- {{ stdlib("c") }}
1654+
- libgomp
1655+
host:
1656+
- cuda-version {{ cuda_compiler_version }} # [cuda_compiler_version != "None"]
1657+
- libcublas-dev
1658+
- {{ pin_subpackage("libcudss-commlayer-nccl", exact=True) }} # [linux]
1659+
- {{ pin_subpackage("libcudss-commlayer-mpi", exact=True) }} # [linux]
1660+
run:
1661+
- {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} # [cuda_compiler_version != "None"]
1662+
- libcublas
1663+
run_constrained:
1664+
- libcudss0 <0.0.0a0
1665+
- {{ pin_subpackage("libcudss-commlayer-nccl", exact=True) }}
1666+
- {{ pin_subpackage("libcudss-commlayer-mpi", exact=True) }}
1667+
test:
1668+
requires:
1669+
- libcudss-commlayer-nccl # [linux]
1670+
- libcudss-commlayer-mpi # [linux]
1671+
commands:
1672+
- test -f $PREFIX/lib/libcudss.so.{{ soversion }} # [linux]
1673+
- test -L $PREFIX/lib/libcudss.so.{{ somajor }} # [linux]
1674+
- test -f $PREFIX/lib/libcudss_mtlayer_gomp.so.{{ soversion }} # [linux]
1675+
- test -L $PREFIX/lib/libcudss_mtlayer_gomp.so.{{ somajor }} # [linux]
1676+
- test ! -f $PREFIX/lib/libcudss_static.a # [linux]
1677+
- if not exist %LIBRARY_BIN%\\cudss64_{{ somajor }}.dll exit 1 # [win]
1678+
- if not exist %LIBRARY_BIN%\\cudss_mtlayer_vcomp140.dll exit 1 # [win]
1679+
about:
1680+
summary: The NVIDIA cuDSS runtime library (with a pre-built threading layer for OpenMP).
1681+
license: LicenseRef-NVIDIA-End-User-License-Agreement
1682+
license_file: LICENSE
1683+
description: >-
1684+
This is a runtime package only. Developers should install libcudss-dev to build with cuDSS.
1685+
1686+
- name: libcudss-dev
1687+
build:
1688+
run_exports:
1689+
# Breaking changes every version until 1.0
1690+
- {{ pin_subpackage("libcudss", max_pin="x.x.x") }}
1691+
files:
1692+
- lib/libcudss.so # [linux]
1693+
- include/cudss* # [linux]
1694+
- lib/cmake/cudss/cudss-config* # [linux]
1695+
- lib/cmake/cudss/cudss-targets* # [linux]
1696+
- Library/lib/cudss.lib # [win]
1697+
- Library/include/cudss* # [win]
1698+
- Library/lib/cmake/cudss/* # [win]
1699+
requirements:
1700+
host:
1701+
- {{ pin_subpackage("libcudss", exact=True) }}
1702+
run:
1703+
- {{ pin_subpackage("libcudss", exact=True) }}
1704+
run_constrained:
1705+
test:
1706+
files:
1707+
- test
1708+
requires: # [build_platform == target_platform]
1709+
- {{ compiler("c") }} # [build_platform == target_platform]
1710+
- {{ compiler("cxx") }} # [build_platform == target_platform]
1711+
- {{ compiler('cuda') }} # [build_platform == target_platform]
1712+
- {{ stdlib("c") }} # [build_platform == target_platform]
1713+
- cmake # [build_platform == target_platform]
1714+
- ninja # [build_platform == target_platform]
1715+
commands:
1716+
- test -f $PREFIX/include/cudss.h # [linux]
1717+
- test -f $PREFIX/include/cudss_distributed_interface.h # [linux]
1718+
- test -f $PREFIX/include/cudss_threading_interface.h # [linux]
1719+
- test -L $PREFIX/lib/libcudss.so # [linux]
1720+
- test ! -f $PREFIX/lib/libcudss_static.a # [linux]
1721+
- test ! -f $PREFIX/lib/cmake/cudss/cudss-static.targets.cmake # [linux]
1722+
- if not exist %LIBRARY_LIB%\\cudss.lib exit 1 # [win]
1723+
- if not exist %LIBRARY_INC%\\cudss.h exit 1 # [win]
1724+
- if not exist %LIBRARY_INC%\\cudss_distributed_interface.h exit 1 # [win]
1725+
- if not exist %LIBRARY_INC%\\cudss_threading_interface.h exit 1 # [win]
1726+
- if not exist %LIBRARY_LIB%\\cmake\\cudss\\cudss-config.cmake exit 1 # [win]
1727+
- cmake ${CMAKE_ARGS} -GNinja test # [build_platform == target_platform]
1728+
- cmake --build . # [build_platform == target_platform]
1729+
# Metadata will be inherited from top-level
1730+
1731+
# loadable modules; optional and only needed at runtime
1732+
1733+
- name: libcudss-commlayer-nccl
1734+
build:
1735+
skip: true # [not linux]
1736+
files:
1737+
- lib/libcudss_commlayer_nccl.so.* # [linux]
1738+
requirements:
1739+
build:
1740+
- {{ compiler('c') }}
1741+
- {{ compiler('cxx') }}
1742+
- {{ compiler('cuda') }}
1743+
- {{ stdlib("c") }}
1744+
host:
1745+
- cuda-version {{ cuda_compiler_version }} # [cuda_compiler_version != "None"]
1746+
- nccl
1747+
test:
1748+
commands:
1749+
- test -f $PREFIX/lib/libcudss_commlayer_nccl.so.{{ soversion }} # [linux]
1750+
- test -L $PREFIX/lib/libcudss_commlayer_nccl.so.{{ somajor }} # [linux]
1751+
about:
1752+
summary: Install this package to enable NCCL for cuDSS
1753+
license: LicenseRef-NVIDIA-End-User-License-Agreement
1754+
license_file: LICENSE
1755+
description: >-
1756+
This is a runtime package only. Developers should install libcudss-dev to build with cuDSS.
1757+
1758+
- name: libcudss-commlayer-mpi
1759+
build:
1760+
skip: true # [not linux]
1761+
files:
1762+
- lib/libcudss_commlayer_openmpi.so.* # [linux]
1763+
requirements:
1764+
build:
1765+
- {{ compiler('c') }}
1766+
- {{ compiler('cxx') }}
1767+
- {{ compiler('cuda') }}
1768+
- {{ stdlib("c") }}
1769+
host:
1770+
- cuda-version {{ cuda_compiler_version }} # [cuda_compiler_version != "None"]
1771+
# collect channel pinning
1772+
- openmpi
1773+
# constrain to version that we actually built with
1774+
- openmpi >=4.1.0,<6
1775+
test:
1776+
commands:
1777+
- test -f $PREFIX/lib/libcudss_commlayer_openmpi.so.{{ soversion }} # [linux]
1778+
- test -L $PREFIX/lib/libcudss_commlayer_openmpi.so.{{ somajor }} # [linux]
1779+
about:
1780+
summary: Install this package to enable MPI for cuDSS
1781+
license: LicenseRef-NVIDIA-End-User-License-Agreement
1782+
license_file: LICENSE
1783+
description: >-
1784+
This is a runtime package only. Developers should install libcudss-dev to build with cuDSS.
1785+
1786+
# NOTE: Metadata inheritance from this section to the outputs is all or nothing. Only the
1787+
# -dev package and the feedstock readme are inheriting this metadata.
1788+
about:
1789+
home: https://developer.nvidia.com/cudss
1790+
license: LicenseRef-NVIDIA-End-User-License-Agreement
1791+
license_file: LICENSE
1792+
license_url: https://docs.nvidia.com/cuda/cudss/license.html
1793+
summary: The NVIDIA cuDSS development package.
1794+
description: >-
1795+
NVIDIA cuDSS is an optimized, first-generation GPU-accelerated Direct Sparse Solver library for solving linear systems with sparse matrices. Direct Sparse Solvers are an important part of numerical computing as they provide a general robust way of solving large linear systems without and are capable of taking advantage
1796+
of both high compute throughput and memory bandwidth of the GPUs.
1797+
doc_url: https://docs.nvidia.com/cuda/cudss/
1798+
1799+
extra:
1800+
compute-subdir: cudss
1801+
redist-json-name: libcudss
1802+
recipe-maintainers:
1803+
- conda-forge/cuda
1804+
- kvoronin
1805+
feedstock-name: libcudss
1806+
""" # noqa
1807+
1808+
cm = CondaMetaYAML(recipe)
1809+
s = io.StringIO()
1810+
cm.dump(s)
1811+
s.seek(0)
1812+
assert s.read() == recipe
1813+
1814+
15891815
def test_recipe_parses_strings_colons_quotes():
15901816
recipe = """\
15911817
test:

0 commit comments

Comments
 (0)