Blob Blame History Raw
%bcond_without tests

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

# The entire source is MIT, except:
#   - The Versioneer-generated bids/ 0.28, is Unlicense. (It simply
#     says “This file is released into the public domain,” but the full
#     Versioneer documentation makes it clear that it is actually under the
#     same Unlicense terms as Versioneer (Fedora: python-versioneer) itself.
#   - 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 Unlicense

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}

# We cannot package the “model_reports” extra because python-altair is not
# packaged.
%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}

# loosen formulaic dep: one test fails, reported upstream
sed -i 's/formulaic .*"/formulaic"/' pyproject.toml

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

sed -r -i 's/^([[:blank:]]*)"(pytest-cov|coverage)\b/\1# "\2/' pyproject.toml

# Not currently packaged: python-altair. This patches it out of *all* extras,
# currently “test” and “model_reports”, but we neither package nor generate
# BR’s from “model_reports” since we do not have altair.
sed -r -i 's/^([[:blank:]]*)"(altair)\b/\1# "\2/' pyproject.toml

# 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 -l bids
# Save space by hardlinking duplicate test data files (of nonzero size).
hardlink -c -v '%{buildroot}%{python3_sitelib}/bids/tests/data/'

%if %{with tests}
# temporarily disable failing tests
%pytest -v -k "not test_run_variable_collection_bad_length_to_df_all_dense_vars and not test_split"

%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