diff options
author | CoprDistGit <copr-devel@lists.fedorahosted.org> | 2025-04-24 08:35:56 +0000 |
---|---|---|
committer | CoprDistGit <copr-devel@lists.fedorahosted.org> | 2025-04-24 08:35:56 +0000 |
commit | 81bc40ba2cea43d1173d8ec41ce2bf3f09cc603c (patch) | |
tree | c5f6eb4828fb4a24edebb25642834b57bc507296 | |
parent | 82f3465041b7b9e9c2c8d78eb61a6a1c1e2a8558 (diff) |
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | bids-schema.spec | 363 | ||||
-rw-r--r-- | bst-export.1 | 17 | ||||
-rw-r--r-- | bst.1 | 21 | ||||
-rwxr-xr-x | get_test_data | 91 | ||||
-rw-r--r-- | sources | 3 |
6 files changed, 498 insertions, 0 deletions
@@ -0,0 +1,3 @@ +/bids-error-examples-ac0a2f58f34ce284847dde5bd3b90d7ea048c141-filtered.tar.zst +/bids-examples-f21306744fd57bfd5c8e8e91d907fa8448f9eca5-filtered.tar.zst +/bids-specification-schema-1.0.5.tar.gz diff --git a/bids-schema.spec b/bids-schema.spec new file mode 100644 index 0000000..77cfb2c --- /dev/null +++ b/bids-schema.spec @@ -0,0 +1,363 @@ +## START: Set by rpmautospec +## (rpmautospec version 0.7.3) +## RPMAUTOSPEC: autorelease, autochangelog +%define autorelease(e:s:pb:n) %{?-p:0.}%{lua: + release_number = 1; + base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); + print(release_number + base_release_number - 1); +}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}} +## END: Set by rpmautospec + +Name: bids-schema +Version: 1.0.5 +Release: %autorelease +Summary: BIDS schema description + +%global srcversion %(echo '%{version}' | tr '^' '.') +# Installation paths imitate the structure of +# https://github.com/bids-standard/bids-schema/ in case we start packaging from +# that in the future. Schemas are installed under directories versioned by the +# BIDS specification version, not the schema version. If the following is set +# correctly, then +# https://github.com/bids-standard/bids-schema/raw/refs/heads/main/… +# versions/%%{bidsversion}/schema/SCHEMA_VERSION +# should match or nearly match the schema version packaged here. +%global bidsversion 1.10.0 + +# The specification, and the schema data derived from it, are CC-BY-4.0. +# +# The Python library in tools/schemacode/, packaged as python3-bidsschematools, +# is MIT. +License: CC-BY-4.0 +# CC0-1.0 comes from the filtered test datasets, Source2 and Source3 +SourceLicense: CC0-1.0 AND CC-BY-4.0 AND MIT +URL: https://github.com/bids-standard/bids-specification +# The PyPI sdist corresponds to the tools/schemacode directory in git. +Source0: %{url}/archive/schema-%{srcversion}/bids-specification-schema-%{srcversion}.tar.gz + +# Tests would like to use the following datasets from +# https://github.com/bids-standard/bids-examples: +# CC0-1.0: +# - asl003/ ds000248/ micr_SEMzarr/ micr_SPIM/ pet003/ qmri_tb1tfl/ +# CC-BY-4.0: +# - eeg_cbm/ +# Unclear licensing (no license specified or "Custom" with no text or details): +# - hcp_example_bids/ qmri_vfa/ +# ODC-By-1.0 (not-allowed in Fedora) +# - fnirs_automaticity/ +# +# Also, the following from https://github.com/bids-standard/bids-error-examples: +# CC0-1.0: +# - invalid_asl003/ invalid_pet001/ +# +# See BIDS_SELECTION and BIDS_ERROR_SELECTION in +# tools/schemacode/src/bidsschematools/conftest.py. +# +# We use the latest commits from each repository at the time of packaging; see +# tools/schemacode/src/bidsschematools/conftest.py, which contains code to download +# these if they are not present. +%global examples_url https://github.com/bids-standard/bids-examples +%global examples_commit f21306744fd57bfd5c8e8e91d907fa8448f9eca5 +%global error_examples_url https://github.com/bids-standard/bids-error-examples +%global error_examples_commit ac0a2f58f34ce284847dde5bd3b90d7ea048c141 +# +# We use a script to create archives containing only the test datasets that +# fall under clearly-acceptable content license terms *and* are used in the +# tests. The script requires that each of the following macros occupies a +# single (long, if necessary) line. +%global examples asl003 ds000248 eeg_cbm micr_SEMzarr micr_SPIM pet003 qmri_tb1tfl +%global error_examples invalid_asl003 invalid_pet001 +# Run this script with no arguments to parse the spec file (in the same +# directory) for commits, URLs, and whitelisted datasets, and create two +# corresponding source archives in the current working directory. +Source1: get_test_data +# License: CC0-1.0 AND CC-BY-4.0 +# (does not contribute to the licenses of the binary RPMs) +Source2: bids-examples-%{examples_commit}-filtered.tar.zst +# License: CC0-1.0 +# (does not contribute to the licenses of the binary RPMs) +Source3: bids-error-examples-%{error_examples_commit}-filtered.tar.zst + +# Man pages hand-written for Fedora in groff_man(7) format based on --help +Source10: bst.1 +Source11: bst-export.1 + +BuildArch: noarch + +BuildRequires: symlinks +BuildRequires: python3-devel +# The tests extra includes mostly linting/coverage tools; considering +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters, +# it is easier to enumerate test dependencies by hand. +BuildRequires: %{py3_dist pytest} + +%description +Portions of the BIDS specification are defined using YAML files in order to +make the specification machine-readable. + +Currently the portions of the specification that rely on this schema are: + + • the entity tables, + • entity definitions, + • filename templates, + • metadata tables. + +Any changes to the specification should be mirrored in the schema. + + +%package -n python3-bidsschematools +Summary: Python tools for working with the BIDS schema +License: MIT + +Requires: %{name} = %{version}-%{release} + +%description -n python3-bidsschematools +A Python library (available after installation in the Python interpreter as +bidsschematools) for working with the Brain Imaging Data Structure (BIDS) +schema. + +Features: + + • lightweight + • reference schema parsing implementation used for schema testing + • simple CLI bindings (e.g. bst export) + + +%pyproject_extras_subpkg -n python3-bidsschematools render expressions + + +%prep +%autosetup -n bids-specification-schema-%{srcversion} +%setup -q -T -D -a 2 -c -n bids-specification-schema-%{srcversion} +%setup -q -T -D -a 3 -c -n bids-specification-schema-%{srcversion} + +# Remove JavaScript sources used for building the specification documents +# (which we don’t do anyway); these include a bundled pre-compiled/minified +# version of JQuery, which is (license-wise) allowable in the source RPM, but +# must not be shipped in the binary RPMs. Removing it confirms that it is not +# used or shipped. We also preemptively remove the CSS sources, which currently +# don’t contain anything bundled or pre-minified, but are unused and might +# contain something objectionable in a future release. +rm -rf src/js/ src/css/ + + +%generate_buildrequires +pushd tools/schemacode >/dev/null +%pyproject_buildrequires -x render,expressions +popd >/dev/null + + +%build +pushd tools/schemacode >/dev/null +%pyproject_wheel +popd + + +%install +# Imitate the structure of https://github.com/bids-standard/bids-schema/ in +# case we start packaging from that in the future. +install -d '%{buildroot}%{_datadir}/bids-schema/versions/%{bidsversion}' +ln -s '%{bidsversion}' '%{buildroot}%{_datadir}/bids-schema/versions/latest' +cp -rvp src/schema \ + '%{buildroot}%{_datadir}/bids-schema/versions/%{bidsversion}/schema' +# While https://github.com/bids-standard/bids-schema does not install +# metaschema.json alongside the schema/ directory, it *is* included in the PyPI +# sdist for bidsschematools. +install -t '%{buildroot}%{_datadir}/bids-schema/versions/%{bidsversion}' \ + -p -m 0644 src/metaschema.json + +pushd tools/schemacode >/dev/null +%pyproject_install +%pyproject_save_files -l bidsschematools +popd + +# Unbundle the schema data from the Python library. +# Since the schema directory is replaced by a symbolic link into the base +# package, we must remove its contents from the files list, and we must remove +# the directory itself so that we can list it manually without %%dir. +sed -r -i '/\/bidsschematools\/data\/schema(\/|$)/d' %{pyproject_files} +for thing in metaschema.json schema +do + rm -rv "%{buildroot}%{python3_sitelib}/bidsschematools/data/${thing}" + # Create an absolute symlink into the buildroot and then convert it to a + # relative one; the relative symlink works both in %%check and after the + # package is actually installed. + ln -s \ + "%{buildroot}%{_datadir}/bids-schema/versions/%{bidsversion}/${thing}" \ + "%{buildroot}%{python3_sitelib}/bidsschematools/data/${thing}" + symlinks -c -o "%{buildroot}%{python3_sitelib}/bidsschematools/data/${thing}" +done + +# Generate and include a copy of the “exported” JSON version of the schema to +# imitate the structure of https://github.com/bids-standard/bids-schema. See +# readthedocs.yml. We do this in %%install rather than %%build because we need +# to use the generated “bst” entry point. +PYTHONDONTWRITEBYTECODE=1 PYTHONPATH='%{buildroot}%{python3_sitelib}' \ + %{buildroot}%{_bindir}/bst -v export --output \ + '%{buildroot}%{_datadir}/bids-schema/versions/%{bidsversion}/schema.json' + +# Do not ship the tests. +sed -r -i '/\/bidsschematools\/tests(\/|$)/d' %{pyproject_files} +sed -r -i '/bidsschematools\.tests(\.|$)/d' '%{_pyproject_modules}' +rm -rvf '%{buildroot}%{python3_sitelib}/bidsschematools/tests' + +# Install the man pages +install -t '%{buildroot}%{_mandir}/man1' -D -p -m 0644 \ + '%{SOURCE10}' '%{SOURCE11}' + +# Install documentation. (Since we use %%doc with an absolute path for the +# README.md file in the schema directory, we must use absolute paths for all +# documentation; see +# https://docs.fedoraproject.org/en-US/packaging-guidelines/#_documentation.) +install -t '%{buildroot}%{_pkgdocdir}' -D -p -m 0644 \ + CITATION.cff +# The top-level README.md in the source tree is really for the *specification*, +# and this package is for the *schema*. We therefore form a relative symlink to +# the README.md in the schema directory (in two steps). +ln -s \ + '%{buildroot}%{_datadir}/bids-schema/versions/%{bidsversion}/schema/README.md' \ + '%{buildroot}%{_pkgdocdir}/README.md' +symlinks -c -o '%{buildroot}%{_pkgdocdir}/README.md' +install -t '%{buildroot}%{_docdir}/python3-bidsschematools' -D -p -m 0644 \ + tools/schemacode/README.md + + +%check +# Sanity check +verfile='%{_datadir}/bids-schema/versions/%{bidsversion}/schema/SCHEMA_VERSION' +[ '%{srcversion}' = "$(cat "%{buildroot}${verfile}")" ] + +%pyproject_check_import + +# These tests require example files that were filtered out for license reasons. +k="${k-}${k+ and }not test_bids_datasets[hcp_example_bids]" +k="${k-}${k+ and }not test_bids_datasets[qmri_vfa]" +k="${k-}${k+ and }not test_bids_datasets[fnirs_automaticity]" + +# Since we removed the tests from the installed package, we now link the +# example data into the original source copy of the library for testing. +ln -s "${PWD}/bids-examples-%{examples_commit}" \ + tools/schemacode/tests/data/bids-examples +ln -s "${PWD}/bids-error-examples-%{error_examples_commit}" \ + tools/schemacode/tests/data/bids-error-examples +# We also link the actual schema data, as unbundled and installed in the +# buildroot. +rm -rvf 'tools/schemacode/src/bidsschematools/data' +ln -s '%{buildroot}%{python3_sitelib}/bidsschematools/data' \ + 'tools/schemacode/src/bidsschematools/data' +# All of this manipulation is OK here in %%check because we already built the +# wheel and installed the library to the buildroot. + +%pytest ${ignore-} -k "${k-}" -v + + +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Directory_Replacement/#_scriptlet_to_replace_a_directory +# Added for F42; can be removed in F45 (upgrade path for three releases) +%pretrans -p <lua> -n python3-bidsschematools +path = "%{python3_sitelib}/bidsschematools/data/schema" +st = posix.stat(path) +if st and st.type == "directory" then + status = os.rename(path, path .. ".rpmmoved") + if not status then + suffix = 0 + while not status do + suffix = suffix + 1 + status = os.rename(path .. ".rpmmoved", path .. ".rpmmoved." .. suffix) + end + os.rename(path, path .. ".rpmmoved") + end +end + + +%files +%license LICENSE +%doc %dir %{_pkgdocdir} +%doc %{_pkgdocdir}/CITATION.cff +# This is a symbolic link to the README.md in the schema directory: +%doc %{_pkgdocdir}/README.md + +%dir %{_datadir}/bids-schema/ +%dir %{_datadir}/bids-schema/versions/ +# Symbolic link to the current version +%{_datadir}/bids-schema/versions/latest +%dir %{_datadir}/bids-schema/versions/%{bidsversion}/ +%{_datadir}/bids-schema/versions/%{bidsversion}/metaschema.json +%{_datadir}/bids-schema/versions/%{bidsversion}/schema.json +%dir %{_datadir}/bids-schema/versions/%{bidsversion}/schema +%doc %{_datadir}/bids-schema/versions/%{bidsversion}/schema/README.md +# Version files +%{_datadir}/bids-schema/versions/%{bidsversion}/schema/BIDS_VERSION +%{_datadir}/bids-schema/versions/%{bidsversion}/schema/SCHEMA_VERSION +# Directories (or directory trees) filled with YAML files +%{_datadir}/bids-schema/versions/%{bidsversion}/schema/meta/ +%{_datadir}/bids-schema/versions/%{bidsversion}/schema/objects/ +%{_datadir}/bids-schema/versions/%{bidsversion}/schema/rules/ + + +%files -n python3-bidsschematools -f %{pyproject_files} +%doc %dir %{_docdir}/python3-bidsschematools +%doc %{_docdir}/python3-bidsschematools/README.md + +# Symbolic link into the appropriate directory in the base package: +%{python3_sitelib}/bidsschematools/data/schema +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Directory_Replacement/#_scriptlet_to_replace_a_directory +# Added for F42; can be removed in F45 (upgrade path for three releases) +%ghost %{python3_sitelib}/bidsschematools/data/schema.rpmmoved + +%{_bindir}/bst +%{_mandir}/man1/bst.1* +%{_mandir}/man1/bst-*.1* + + +%changelog +## START: Generated by rpmautospec +* Tue Apr 15 2025 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.5-1 +- Update to 1.0.5 (close RHBZ#2359774) + +* Sat Mar 22 2025 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.4-1 +- Update to 1.0.4 (close RHBZ#2353951) + +* Fri Feb 21 2025 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.3-1 +- Update to 1.0.3 (close RHBZ#2346980) + +* Fri Feb 21 2025 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.2-2 +- De-conditionalize the "render" extra + +* Mon Feb 10 2025 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.2-1 +- Update to 1.0.2 (close RHBZ#2344674) + +* Wed Feb 05 2025 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.1-1 +- Update to 1.0.1 (close RHBZ#2344086) + +* Thu Jan 16 2025 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + +* Wed Dec 11 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.0-2 +- Add a SourceLicense field + +* Fri Dec 06 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.0-1 +- Update to 1.0.0 (close RHBZ#2330678) + +* Thu Nov 14 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 0.11.3^post3-2 +- Fix the upgrade path for corrected schema unbundling + +* Thu Nov 14 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 0.11.3^post3-1 +- Update to 0.11.3^post3 (close RHBZ#2326272) +- Fix schema unbundling in python3-bidsschematools + +* Mon Nov 11 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 0.11.3^post2-1 +- Update to 0.11.3^post2 (close RHBZ#2325251) + +* Sat Nov 09 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 0.11.3^post1-2 +- Install schema in a dir. based on the BIDS version (not the schema + version) + +* Sat Nov 09 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 0.11.3^post1-1 +- Update to 0.11.3^post1 (close RHBZ#2324764) + +* Thu Oct 31 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 0.11.3-2 +- Add conditionals for EPEL10 + +* Sat Sep 14 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 0.11.3-1 +- Initial package (close RHBZ#2303543) +## END: Generated by rpmautospec diff --git a/bst-export.1 b/bst-export.1 new file mode 100644 index 0000000..f1bb017 --- /dev/null +++ b/bst-export.1 @@ -0,0 +1,17 @@ +.TH BST\-EXPORT "1" "August 2024" "" "User Commands" +.SH NAME +.B bst\ export +\(en Export BIDS schema to JSON document +.SH SYNOPSIS +.B bst\ export +.RI [ OPTIONS ] +.SH OPTIONS +.TP +.B \-\-schema\ \fITEXT +.TP +.B \-\-output\ \fITEXT +.TP +.B \-h\fR, \fB\-\-help +Show a help message and exit +.SH "SEE ALSO" +.BR bst (1) @@ -0,0 +1,21 @@ +.TH BST "1" "August 2024" "" "User Commands" +.SH NAME +.B bst +\(en BIDS Schema Tools +.SH SYNOPSIS +.B bst +.RI [ OPTIONS ] +.I COMMAND +.RI [ ARGS ]... +.SH OPTIONS +.TP +.B \-v\fR,\ \fB\-\-verbose +.TP +.B \-h\fR,\ \fB\-\-help +Show a help message and exit. +.SS "COMMANDS" +.TP +.B export +Export BIDS schema to JSON document +.SH "SEE ALSO" +.BR bst\-export (1) diff --git a/get_test_data b/get_test_data new file mode 100755 index 0000000..b399b9c --- /dev/null +++ b/get_test_data @@ -0,0 +1,91 @@ +#!/bin/sh +set -o errexit +set -o nounset + +if [ "$#" != '0' ] +then + cat 1>&2 <<EOF +Usage: $0 + +Parses bids-schema.spec in the same directory as this script; downloads test +data and produces two archives, filtered to include only selected datasets with +audited license terms, in the current working directory. +EOF + exit 1 +fi + +OUTDIR="${PWD}" +TMPDIR="$(mktemp -d)" +trap "rm -rf '${TMPDIR}'" INT TERM EXIT + +SPEC="$(cd "$(dirname "${0}")"; echo "${PWD}")/bids-schema.spec" +MACROS="$(grep -E '^%global' "${SPEC}")" +get_macro() +{ + rpm -E "${MACROS} +%{${1}}" +} + +EX_URL="$(get_macro examples_url)" +EX_COMMIT="$(get_macro examples_commit)" +EX_LIST="$(get_macro examples)" +ERREX_URL="$(get_macro error_examples_url)" +ERREX_COMMIT="$(get_macro error_examples_commit)" +ERREX_LIST="$(get_macro error_examples)" + +cd "${TMPDIR}" +EX_ARCHIVE="bids-examples-${EX_COMMIT}.tar.gz" +EX_DL="${EX_URL}/archive/${EX_COMMIT}/${EX_ARCHIVE}" +echo "--> Downloading: ${EX_DL}" 1>&2 +curl -L -O "${EX_DL}" +ERREX_ARCHIVE="bids-error-examples-${ERREX_COMMIT}.tar.gz" +ERREX_DL="${ERREX_URL}/archive/${ERREX_COMMIT}/${ERREX_ARCHIVE}" +echo "--> Downloading: ${ERREX_DL}" 1>&2 +curl -L -O "${ERREX_DL}" + +echo "--> Extracting: ${EX_ARCHIVE})" 1>&2 +tar -xzf "${EX_ARCHIVE}" +echo "--> Extracting: ${ERREX_ARCHIVE})" 1>&2 +tar -xzf "${ERREX_ARCHIVE}" +echo '--> Removing all but “whitelisted” datasets' 1>&2 +EX_ARCHDIR="$(basename "${EX_ARCHIVE}" '.tar.gz')" +ERREX_ARCHDIR="$(basename "${ERREX_ARCHIVE}" '.tar.gz')" +mv "${EX_ARCHDIR}" "${EX_ARCHDIR}-original" +mv "${ERREX_ARCHDIR}" "${ERREX_ARCHDIR}-original" +mkdir "${EX_ARCHDIR}" "${ERREX_ARCHDIR}" +for ds in ${EX_LIST} +do + mv "${EX_ARCHDIR}-original/${ds}" "${EX_ARCHDIR}" +done +for ds in ${ERREX_LIST} +do + mv "${ERREX_ARCHDIR}-original/${ds}" "${ERREX_ARCHDIR}" +done +# Restore the original mtimes +touch -r "${EX_ARCHDIR}-original" "${EX_ARCHDIR}" +touch -r "${ERREX_ARCHDIR}-original" "${ERREX_ARCHDIR}" + +rearchive() +{ + ARCHDIR="${1}" + FILTERED="${2}" + echo "--> Re-archiving: ${FILTERED}" 1>&2 + # https://www.gnu.org/software/tar/manual/html_section/Reproducibility.html + TZ=UTC LC_ALL=C tar \ + --create \ + --sort=name \ + --format=posix \ + --numeric-owner --owner=0 --group=0 \ + --mode=go+u,go-w \ + --pax-option='delete=atime,delete=ctime' \ + "${ARCHDIR}/" | + zstdmt --ultra -22 > "${FILTERED}" +} + +EX_FILTERED="${EX_ARCHDIR}-filtered.tar.zst" +ERREX_FILTERED="${ERREX_ARCHDIR}-filtered.tar.zst" +rearchive "${EX_ARCHDIR}" "${EX_FILTERED}" +rearchive "${ERREX_ARCHDIR}" "${ERREX_FILTERED}" + +mv "${EX_FILTERED}" "${ERREX_FILTERED}" "${OUTDIR}" +echo 'Done.' 1>&2 @@ -0,0 +1,3 @@ +49905a88b1329b4860744e1599f98c75 bids-error-examples-ac0a2f58f34ce284847dde5bd3b90d7ea048c141-filtered.tar.zst +d51766320c9f26a59d365ba0891e1d27 bids-examples-f21306744fd57bfd5c8e8e91d907fa8448f9eca5-filtered.tar.zst +4142214259722dcf07fc31e268ceaa7b bids-specification-schema-1.0.5.tar.gz |