%global pypi_name numpydantic Name: python-%{pypi_name} # Epoch 1: 2.0.0-1 was published first; pyRadPlan 0.8.0 (released 2026-11-05) was built # against numpydantic 1.10, and 2.0.0 (2026-11-06) breaks its matRad serializer. Epoch: 1 Version: 1.10.0 Release: 1%{?dist} Summary: Type and shape validation and serialisation for arrays in pydantic models License: MIT URL: https://github.com/p2p-ld/numpydantic Source0: %{pypi_source %{pypi_name}} BuildArch: noarch BuildRequires: python3-devel BuildRequires: pyproject-rpm-macros BuildRequires: python3-h5py BuildRequires: python3-dask # numpydantic.mypy is a mypy plugin; with mypy present it is import-checked too. BuildRequires: python3-mypy %global _description %{expand: numpydantic adds NDArray annotations to pydantic models: arrays are validated for dtype and shape, and serialised to JSON. NumPy, HDF5 (h5py), Dask, Zarr and video arrays share one interface. pyRadPlan uses it for its CT, dose and machine data models.} %description %_description %package -n python3-%{pypi_name} Summary: %{summary} Suggests: python3-h5py Suggests: python3-dask %description -n python3-%{pypi_name} %_description %prep %autosetup -n %{pypi_name}-%{version} %generate_buildrequires %pyproject_buildrequires %build %pyproject_wheel %install %pyproject_install %pyproject_save_files %{pypi_name} %check # Optional array backends Fedora lacks or ships too old are left out: video needs # opencv-python and zarr needs >= 3.1 (Fedora has 2.18). %pyproject_check_import -e 'numpydantic.interface.video*' -e 'numpydantic.interface.zarr*' -e 'numpydantic.testing*' # Upstream's whole suite loads numpydantic.testing.interfaces through its conftest, and that # imports cv2 and zarr 3 at module level, so it cannot run here. Check instead the part # pyRadPlan relies on: NDArray shape and dtype validation inside pydantic models. %{py3_test_envvars} %{python3} - <<'PYEOF' import numpy as np import pydantic from numpydantic import NDArray, Shape class M(pydantic.BaseModel): a: NDArray[Shape["3"], np.float64] b: NDArray[Shape["* x, 2 y"], int] m = M(a=np.zeros(3), b=np.ones((5, 2), dtype=int)) assert m.a.shape == (3,) and m.b.shape == (5, 2) for bad in (dict(a=np.zeros(4), b=np.ones((5, 2), dtype=int)), dict(a=np.zeros(3), b=np.ones((5, 3), dtype=int)), dict(a=np.zeros(3, dtype=np.int8), b=np.ones((5, 2), dtype=int))): try: M(**bad) except pydantic.ValidationError: pass else: raise SystemExit(f"accepted an invalid array: {bad}") print("numpydantic shape/dtype validation OK") PYEOF %files -n python3-%{pypi_name} -f %{pyproject_files} %license LICENSE %doc README.md %changelog * Sat Nov 07 2026 Morgan Hough - 1:1.10.0-1 - Back to 1.10.0 with Epoch 1: pyRadPlan 0.8.0 predates numpydantic 2.0, whose NDArray type no longer works as a NumPy dtype in pyRadPlan's matRad serializer. * Fri Nov 06 2026 Morgan Hough - 2.0.0-1 - Initial package; dependency of pyRadPlan.