%global pypi_name templateflow Name: python-%{pypi_name} Version: 25.1.2 Release: 1%{?dist} Summary: TemplateFlow client: neuroimaging templates and atlases on demand # Code: Apache-2.0. templateflow/conf/templateflow-skel.zip is an index of the TemplateFlow # archive: one directory per template with template_description.json, the template's own # LICENSE/CHANGES text, small label tables (dseg.tsv/.json) and a few helper scripts, and # zero-byte placeholders for every image (fetched from S3 on first use, never shipped here). # Each template carries its own licence (CC-BY-4.0, CC0, public domain, the MNI/FreeSurfer # terms, ...). Three are CC-BY-NC-SA-4.0 (Fischer344, MouseIn, WHS): %%prep turns their # non-metadata files into zero-byte placeholders too, so the client fetches them on demand # like any image and no NC content is in this package. The per-template licence review for # shipping template DATA is separate (docs/TEMPLATEFLOW-LICENCES.md). License: Apache-2.0 URL: https://www.templateflow.org Source0: %{pypi_source %{pypi_name}} BuildArch: noarch BuildRequires: python3-devel BuildRequires: python3dist(pytest) %global _description %{expand: TemplateFlow is a curated archive of neuroimaging templates and atlases (MNI152 variants, fsaverage, fsLR, infant, pediatric and animal templates) with a BIDS-like layout. This package is the Python client and command-line tool: it keeps an index of the archive in TEMPLATEFLOW_HOME (default ~/.cache/templateflow) and downloads the files a program asks for on first use. fMRIPrep, sMRIPrep, NiWorkflows and other NiPreps tools use it to find their reference spaces.} %description %{_description} %package -n python3-%{pypi_name} Summary: %{summary} %description -n python3-%{pypi_name} %{_description} %pyproject_extras_subpkg -n python3-%{pypi_name} datalad %prep %autosetup -p1 -n %{pypi_name}-%{version} # The version comes from PKG-INFO; nipreps-versions (a hatch-vcs version-scheme plugin, not in # Fedora) is only needed to compute it from git. sed -i 's/, "nipreps-versions"//; /^raw-options = /d' pyproject.toml grep -q '^requires = \["hatchling", "hatch-vcs"\]' pyproject.toml ! grep -q nipreps-versions pyproject.toml # Blank the NC templates' non-metadata files inside the skeleton (see License comment). python3 - <<'EOF' import zipfile, shutil, sys src = 'templateflow/conf/templateflow-skel.zip' NC = ('tpl-Fischer344/', 'tpl-MouseIn/', 'tpl-WHS/') KEEP = ('template_description.json', 'LICENSE', 'CHANGES') blanked = 0 with zipfile.ZipFile(src) as zin, zipfile.ZipFile(src + '.new', 'w', zipfile.ZIP_DEFLATED) as zout: for info in zin.infolist(): data = zin.read(info) if info.filename.startswith(NC) and data and not info.filename.endswith(KEEP): data = b''; blanked += 1 zout.writestr(info, data) shutil.move(src + '.new', src) print('blanked', blanked) sys.exit(0 if blanked >= 3 else 1) EOF %generate_buildrequires export SETUPTOOLS_SCM_PRETEND_VERSION=%{version} %pyproject_buildrequires -x datalad %build export SETUPTOOLS_SCM_PRETEND_VERSION=%{version} %pyproject_wheel %install %pyproject_install %pyproject_save_files -l %{pypi_name} %check %pyproject_check_import -e 'templateflow.tests*' # Offline subset. Left out, all because they download from S3/GitHub: test_s3 (skeleton and # file fetches), test_cli get/ls (fetch files), test_multiproc (concurrent fetches), and # test_api's citation/fetch tests. export TEMPLATEFLOW_HOME=$PWD/tf-home HOME=$PWD # The use_datalad=on cases clone the archive from GitHub. %pytest -q -p no:cacheprovider templateflow/tests/test_version.py templateflow/tests/test_conf.py \ --deselect 'templateflow/tests/test_conf.py::test_conf_init[on]' --deselect 'templateflow/tests/test_conf.py::test_setup_home[on]' # The installed skeleton must contain no NC data and still index the NC templates. %{py3_test_envvars} %{python3} - <<'EOF' import zipfile from acres import Loader z = zipfile.ZipFile(Loader('templateflow.conf')('templateflow-skel.zip')) names = {i.filename: i.file_size for i in z.infolist()} assert names['tpl-Fischer344/tpl-Fischer344_atlas-v4_dseg.tsv'] == 0 assert names['tpl-Fischer344/template_description.json'] > 0 assert names['tpl-MNI152NLin2009cAsym/template_description.json'] > 0 print('skeleton: %d entries, NC data blanked' % len(names)) EOF TEMPLATEFLOW_HOME=$PWD/tf-home2 %{py3_test_envvars} %{buildroot}%{_bindir}/templateflow --help >/dev/null %files -n python3-%{pypi_name} -f %{pyproject_files} %doc README.rst CHANGES.rst %{_bindir}/templateflow %changelog * Sat Oct 10 2026 Morgan Hough - 25.1.2-1 - Initial package. Client only; templates are fetched on demand. The three CC-BY-NC-SA templates' label tables and scripts are blanked in the bundled skeleton so they too are fetched on demand rather than shipped.