Blob Blame History Raw
%bcond_without tests

Name:       python-pybids
Version:    0.15.5
Release:    %autorelease
Summary:    Interface with datasets conforming to BIDS

# The entire source is MIT, except:
#   - The bundled single-file (from python-versioneer), version
#     0.20, is CC0-1.0. While this license is approved for content only, this
#     file falls under an exception
#     (
#       Existing uses of CC0-1.0 on code files in Fedora packages prior to
#       2022-08-01, and subsequent upstream versions of those files in those
#       packages, continue to be allowed. We encourage Fedora package
#       maintainers to ask upstreams to relicense such files.
#     More recent versions of python-versioneer are Unlicense, so this may
#     change if upstream updates the bundled
#     The bundled is not packaged, so we do not treat it as a
#     bundled library; however, the generated falls under the same
#     license, so CC0-1.0 still appears in the license of the subpackage that
#     contains it.
#   - We presume other test datasets (bids/tests/data/*/) are under the overall
#     MIT license, unless evidence to the contrary comes to light.
# In the python3-pybids+test subpackage:

#   - The following test datasets (content) are PDDL-1.0:
#       bids/tests/data/ds005/
#       bids/tests/data/ds005_conflict/
# We refrain from including the bids-examples/ submodule
# ( because many of the
# datasets therein have unspecified licenses. A small number of tests are
# skipped as a result.
License:        MIT AND CC0-1.0

# FIX: Adapt to SQLAlchemy 1.4+
# Backported to 0.15.5.
Patch:          pybids-0.15.5-sqlalchemy-1.4.patch

BuildArch:      noarch

# tests fail on 32 bit systems, plus:
ExcludeArch:    %{ix86}

BuildRequires:  hardlink

%global _description %{expand:
PyBIDS is a Python library to centralize interactions with datasets conforming
BIDS (Brain Imaging Data Structure) format. For more information about BIDS

%description %{_description}

%pyproject_extras_subpkg -n python3-pybids plotting

%package -n python3-pybids
Summary:    Interface with datasets conforming to BIDS

BuildRequires:  python3-devel

Obsoletes:      python-pybids-doc < 0.15.5-13

# unbundled
BuildRequires:  %{py3_dist inflect}
Requires:  %{py3_dist inflect}

%description -n python3-pybids %{_description}

%package -n python3-pybids+test
%global test_summary Tests and test extras for PyBIDS
Summary:        %{test_summary}

# See comment above base package License tag for licensing breakdown.
# The CC0-1.0 file does not appear in this subpackage.
License:        MIT AND PDDL-1.0

Requires:       python3-pybids = %{version}-%{release}

%global test_description %{expand: \
These are the tests for python3-pybids. This package:

• Provides the “bids.tests” package
• Makes sure the “test” extra dependencies are installed}

%description -n python3-pybids+test %{test_description}

# Upstream duplicates all extras with singular and plural names.
# Based loosely on: rpm -E '%%pyproject_extras_subpkg -n python3-pybids tests'
%package -n python3-pybids+tests
Summary:        %{test_summary}

# This has no files of its own, so none of the non-MIT licenses apply.
License:        MIT

# This metapackage is basically an alias for python3-pybids+test. We build it
# as a separate subpackage rather than adding a virtual Provides so that we can
# benefit from generators to add Provides like python3dist(pybids[tests]).
Requires:       python3-pybids+test = %{version}-%{release}

%description -n python3-pybids+tests %{test_description}

%autosetup -n pybids-%{version} -p1

# Remove bundled inflect
rm -rf bids/external
sed -r -i.backup 's/from.*external (import)/\1/' bids/layout/

# unpin formulaic requirement
sed -i 's/formulaic.*/formulaic/' setup.cfg

# Remove bogus executable bits for non-script files
find bids doc -type f -perm /0111 -execdir chmod -v a-x '{}' '+'

%pyproject_buildrequires -x test,plotting


%pyproject_save_files bids
# Save space by hardlinking duplicate test data files (of nonzero size).
hardlink -c -v '%{buildroot}%{python3_sitelib}/bids/tests/data/'

%if %{with tests}
%pytest -v

%files -n python3-pybids -f %{pyproject_files}
%exclude %{python3_sitelib}/bids/tests/

%files -n python3-pybids+test
%ghost %{python3_sitelib}/*.dist-info

%files -n python3-pybids+tests
%ghost %{python3_sitelib}/*.dist-info