## 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

%bcond_without tests

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

# The entire source is MIT, except:
#   - The Versioneer-generated bids/_version.py 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.
#     https://github.com/python-versioneer/python-versioneer/tree/0.28#license)
#   - 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
# (https://github.com/bids-standard/bids-examples/) because many of the
# datasets therein have unspecified licenses. A small number of tests are
# skipped as a result.
License:        MIT AND Unlicense
URL:            https://bids.neuroimaging.io
Source0:        https://github.com/bids-standard/pybids/archive/%{version}/pybids-%{version}.tar.gz

BuildArch:      noarch

# tests fail on 32 bit systems, plus:
# https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval
ExcludeArch:    %{ix86}

BuildRequires:  git-core
BuildRequires:  hardlink
BuildRequires:  python3-devel
# Unbundled
BuildRequires:  %{py3_dist inflect}

%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
visit https://bids.neuroimaging.io.}

%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
Obsoletes:      python-pybids-doc < 0.15.5-13
# unbundled
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 _version.py 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}


%prep
%autosetup -n pybids-%{version} -S git

# loosen formulaic dep: one test fails, reported upstream
# https://github.com/bids-standard/pybids/issues/1000
sed -i 's/formulaic .*"/formulaic"/' pyproject.toml

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

# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters
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 src/bids doc -type f -perm /0111 -execdir chmod -v a-x '{}' '+'

# Drop test dependency on `s3fs`
sed -r -i '/s3fs/d' pyproject.toml

# Commit everything and tag to allow Versioneer to set the version.
# Make sure this is the last step in prep.
git add --all
git commit -m "[Fedora] Apply downstream changes"
git tag %{version}


%generate_buildrequires
%pyproject_buildrequires -x test,plotting


%build
%pyproject_wheel


%install
%pyproject_install
%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/'


%check
%if %{with tests}
# temporarily disable failing tests
# https://github.com/bids-standard/pybids/issues/1000
k="${k-}${k+ and }not test_split"
# test_remote_bids.py requires network
%pytest -v \
    ${k+-k } "${k-}" \
    --ignore src/bids/layout/tests/test_remote_bids.py
%else
%pyproject_check_import
%endif


%files -n python3-pybids -f %{pyproject_files}
%doc README.md
%{_bindir}/pybids
%exclude %{python3_sitelib}/bids/tests/


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


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


%changelog
## START: Generated by rpmautospec
* Thu Dec 05 2024 Packit <hello@packit.dev> - 0.18.1-1
- Update to 0.18.1 upstream release
- Resolves: rhbz#2330628

* Tue Nov 12 2024 Packit <hello@packit.dev> - 0.18.0-1
- Update to 0.18.0 upstream release
- Resolves: rhbz#2325705

* Fri Sep 20 2024 Packit <hello@packit.dev> - 0.17.2-1
- Update to 0.17.2 upstream release
- Resolves: rhbz#2301438

* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.16.5-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Sat Jun 29 2024 Python Maint <python-maint@redhat.com> - 0.16.5-2
- Rebuilt for Python 3.13

* Thu May 23 2024 Packit <hello@packit.dev> - 0.16.5-1
- Update to 0.16.5 upstream release
- Resolves: rhbz#2282803

* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.16.4-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.16.4-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Thu Jan 04 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 0.16.4-3
- Assert that a license file is present in the .dist-info directory

* Mon Dec 25 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 0.16.4-2
- chore: tweak reqs for formulaic 1x

* Sat Dec 02 2023 Packit <hello@packit.dev> - 0.16.4-1
- [packit] 0.16.4 upstream release
- Resolves rhbz#2252503

* Tue Sep 05 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 0.16.3-3
- fix: bump formulaic version req and temporarily disable one failing test

* Tue Sep 05 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 0.16.3-2
- fix: temporarily disable failing test (fixes rhbz#2226542, rhbz#2220422)

* Tue Sep 05 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 0.16.3-1
- feat: update to 0.16.3 (fixes rhbz#2232259)

* Tue Sep 05 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 0.16.1-4
- chore: add packit

* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.16.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Tue May 30 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.16.1-2
- Enable tests that require python-bsmschema

* Thu May 04 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.16.1-1
- Update to 0.16.1 (close RHBZ#2174248)

* Thu May 04 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.16.0-1
- Update to 0.16.0

* Thu May 04 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.15.6-3
- Revert "Run tests in parallel"

* Mon May 01 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.15.6-2
- Save space by hardlinking duplicate test data files

* Sun Apr 30 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.15.6-1
- Update to 0.15.6

* Sun Apr 30 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.15.5-17
- Backport SQLAlchemy 1.4 support from 0.16.0

* Sun Apr 30 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.15.5-16
- Split tests into a subpackage

* Sun Apr 30 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.15.5-15
- Update License to SPDX

* Sun Apr 30 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.15.5-14
- Remove bogus executable bits for non-script files

* Sun Apr 30 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.15.5-13
- Simplify inflect unbundling

* Sun Apr 30 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.15.5-12
- Stop using or packaging the bids-examples submodule

* Sun Apr 30 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.15.5-11
- Run tests in parallel

* Sun Apr 30 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.15.5-10
- Add plotting extra metapackage

* Sun Apr 30 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.15.5-9
- Reference Changes/EncourageI686LeafRemoval

* Sun Apr 30 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.15.5-8
- Update description from upstream

* Sun Apr 30 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.15.5-7
- Use two lines between spec file sections

* Sun Apr 30 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.15.5-6
- Fix the description in the -doc subpackage

* Sun Apr 30 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.15.5-5
- Use generated BR’s for tests

* Fri Apr 28 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.15.5-4
- Reference examples submodule by commit

* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.15.5-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Thu Nov 10 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 0.15.5-2
- chore: drop i686 support (tests fail)

* Thu Nov 10 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 0.15.5-1
- feat: update to 0.15.5 (fix rhbz#1996270, fix rhbz#2113646)
- drops doc generation
- enables all tests by default
- updates to use pyproject rpm macros

* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.13.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Mon Jul 11 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 0.13.1-5
- Fix extra newline in description
- Drop unnecessary python_enable_dependency_generator macro
- Switch URL to HTTPS

* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.13.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.13.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> - 0.13.1-2
- Rebuilt for Python 3.10

* Sat May 22 2021 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.13.1-1
- Update to latest release

* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.12.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Sat Nov 28 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.12.4-1
- Update to 0.12.4

* Sun Sep 13 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.12.1-1
- Update to new release

* Fri Sep 04 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.12.0-1
- Update to 0.12.0

* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 0.10.2-2
- Rebuilt for Python 3.9

* Tue Apr 21 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.10.2-1
- Update to 0.10.2

* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Thu Dec 12 2019 Aniket Pradhan <major@fedoraproject.org> - 0.10.0-1
- Bumped to v0.10.0

* Tue Oct 1 2019 Aniket Pradhan <major@fedoraproject.org> - 0.9.4-1
- Bumped to v0.9.4

* Thu Aug 22 2019 Aniket Pradhan <aniket17133@iiitd.ac.in> - 0.9.3-1
- Bumped to v0.9.3

* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 0.9.1-3
- Rebuilt for Python 3.8

* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Mon May 27 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.9.1-1
- Update to 0.9.1

* Mon Apr 08 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.8.0-1
- Update the latest release
- Drop dropped grabbit dep
- Add new BR: python-bids-validator: requires review: 1697498
- Unbundle new bundled libs

* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.5-3.gite35ced6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Mon Nov 12 2018 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.6.5-2.gite35ced6
- Use bconds

* Wed Nov 07 2018 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.6.5-1.gite35ced6
- Use latest git snapshot that fixes tests
- Add documentation and examples in subpackage

* Wed Nov 07 2018 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.6.3-2
- Enable tests now that duecredit is available in rawhide
- Disable py2 build since python-nibabel is only py3 even in F29

* Fri Jul 20 2018 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.6.3-1
- Update to latest release
- Use py.test
- Disable tests until nibabel is fixed

* Mon Jan 15 2018 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.4.2-2
- Use github source for license and test suite
- Fix requires and build requires

* Fri Jan 12 2018 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.4.2-1
- Initial build

## END: Generated by rpmautospec