%global pypi_name templateflow Name: python-%{pypi_name} Version: 25.1.2 Release: 2%{?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, ...). Content under a non-commercial licence is not shipped: %%prep turns its non-metadata # files into zero-byte placeholders, which the client then fetches on demand like any image. # That is Fischer344 and WHS (CC-BY-NC-SA-4.0), MouseIn (its description says CC-BY-NC-SA-4.0, # its LICENSE file says CC-BY-SA-4.0; treated as NC), SUIT (CC-BY-NC-3.0) and the Harvard-Oxford # atlases in MNI152NLin6Asym (atlas-HOCPA/HOCPAL/HOSPA, FSL licence). The remaining non-empty files # are template descriptions, JSON sidecars, licence texts and atlas label tables. The per-template 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/', 'tpl-SUIT/') NC_ATLAS = ('atlas-HOCPA_', 'atlas-HOCPAL_', 'atlas-HOSPA_') # JSON sidecars are descriptive metadata like template_description.json (authors, name, licence) # and must stay valid JSON: an empty one breaks PyBIDS indexing of the whole archive. KEEP = ('.json', 'LICENSE', 'CHANGES', 'README.md') 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) nc = info.filename.startswith(NC) or any(a in info.filename for a in NC_ATLAS) if 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 == 9 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 all(v == 0 for k, v in names.items() if k.startswith('tpl-SUIT/') and not k.endswith(('.json', 'LICENSE', 'CHANGES', 'README.md'))) assert all(v == 0 for k, v in names.items() if '_atlas-HO' in k and k.endswith('.tsv')) 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-2 - Also blank SUIT (CC-BY-NC-3.0) and the Harvard-Oxford atlas label tables (FSL licence) in the bundled skeleton; found in the template licence review. JSON sidecars are kept (metadata; an empty one breaks PyBIDS indexing). 9 files blanked, all fetched on demand. * 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.