## START: Set by rpmautospec
## (rpmautospec version 0.3.5)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 7;
    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 tests 1

# Use this to package a pre-release
#global commit xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#global snapdate yyyymmdd

Name:           hatch
Version:        1.7.0%{?commit:^%{snapdate}git%(c='%{commit}'; echo "${c:0:7}")}
Release:        %autorelease
Summary:        A modern project, package, and virtual env manager

%global tag hatch-v%{version}
%global ref %{?commit:%{commit}}%{?!commit:%{tag}}
%global archivename hatch-%{ref}

# The entire source is (SPDX) MIT. Apache-2.0 license text in the tests is used
# as a sample license text, not as a license for the source.
License:        MIT
URL:            https://github.com/pypa/hatch
Source0:        %{url}/archive/%{ref}/%{archivename}.tar.gz
# For now, we need a helper script to access environments defined with
# hatch/hatchling (https://hatch.pypa.io/latest/config/environment/).
Source1:        extract-hatchling-environments

# Written for Fedora in groff_man(7) format based on --help output
Source100:      hatch.1
Source200:      hatch-build.1
Source300:      hatch-clean.1
Source400:      hatch-config.1
Source410:      hatch-config-explore.1
Source420:      hatch-config-find.1
Source430:      hatch-config-restore.1
Source440:      hatch-config-set.1
Source450:      hatch-config-show.1
Source460:      hatch-config-update.1
Source500:      hatch-dep.1
Source510:      hatch-dep-hash.1
Source520:      hatch-dep-show.1
Source521:      hatch-dep-show-requirements.1
Source522:      hatch-dep-show-table.1
Source600:      hatch-env.1
Source610:      hatch-env-create.1
Source620:      hatch-env-find.1
Source630:      hatch-env-prune.1
Source640:      hatch-env-remove.1
Source650:      hatch-env-run.1
Source660:      hatch-env-show.1
Source700:      hatch-new.1
Source800:      hatch-project.1
Source810:      hatch-project-metadata.1
Source900:      hatch-publish.1
Source1000:     hatch-run.1
Source1100:     hatch-shell.1
Source1200:     hatch-status.1
Source1300:     hatch-version.1

# Fix the sdist target when strict-naming is disabled (#834)
# https://github.com/pypa/hatch/commit/1b10663e645efd6f37d616c5de34451dc2e015c0
#
# Backporting this commit makes tests/backend/builders/test_sdist.py compatible
# with hatchling 1.14.1.
Patch:          %{url}/commit/1b10663e645efd6f37d616c5de34451dc2e015c0.patch

BuildArch:      noarch

BuildRequires:  python3-devel

BuildRequires:  git-core
Requires:       git-core

%description
Hatch is a modern, extensible Python project manager.

Features:

  • Standardized build system with reproducible builds by default
  • Robust environment management with support for custom scripts
  • Easy publishing to PyPI or other sources
  • Version management
  • Configurable project generation with sane defaults
  • Responsive CLI, ~2-3x faster than equivalent tools


%prep
%autosetup -n %{archivename} -p1


%generate_buildrequires
'%{SOURCE1}' -v
%pyproject_buildrequires %{?with_tests:_req/env.test.txt}


%build
%pyproject_wheel

# The Markdown documentation is meant to be built with mkdocs. The HTML result
# is unsuitable for packaging due to various bundled and pre-minified
# JavaScript and CSS. See https://bugzilla.redhat.com/show_bug.cgi?id=2006555
# for discussion of similar problems with Sphinx and Doxygen. We therefore do
# not build or install the documentation.


%install
%pyproject_install
%pyproject_save_files hatch

install -t '%{buildroot}%{_mandir}/man1' -D -p -m 0644 \
    '%{SOURCE100}' \
    '%{SOURCE200}' \
    '%{SOURCE300}' \
    '%{SOURCE400}' '%{SOURCE410}' '%{SOURCE420}' '%{SOURCE430}' \
      '%{SOURCE440}' '%{SOURCE450}' '%{SOURCE460}' \
    '%{SOURCE500}' '%{SOURCE510}' '%{SOURCE520}' '%{SOURCE521}' \
      '%{SOURCE522}' \
    '%{SOURCE600}' '%{SOURCE610}' '%{SOURCE620}' '%{SOURCE630}' \
      '%{SOURCE640}' '%{SOURCE650}' '%{SOURCE660}' \
    '%{SOURCE700}' \
    '%{SOURCE800}' '%{SOURCE810}' \
    '%{SOURCE900}' \
    '%{SOURCE1000}' \
    '%{SOURCE1100}' \
    '%{SOURCE1200}' \
    '%{SOURCE1300}'


%check
%if %{with tests}
# There is no need to deselect mark “requires_internet” manually because it
# happens automagically via a runtime connectivity check.

# TODO: What is  happening here?
# >           assert zip_info.date_time == (2020, 2, 2, 0, 0, 0)
# E           assert (2022, 5, 18, 0, 0, 0) == (2020, 2, 2, 0, 0, 0)
# E             At index 0 diff: 2022 != 2020
# E             Full diff:
# E             - (2020, 2, 2, 0, 0, 0)
# E             + (2022, 5, 18, 0, 0, 0)
k="${k-}${k+ and }not (TestBuildStandard and test_editable_pth)"
k="${k-}${k+ and }not (TestBuildStandard and test_editable_exact)"
k="${k-}${k+ and }not (TestBuildStandard and test_editable_default)"
k="${k-}${k+ and }not (TestBuildStandard and test_default_auto_detection)"
k="${k-}${k+ and }not test_explicit_path"
k="${k-}${k+ and }not test_default"

%pytest -k "${k-}" -vv
%else
%pyproject_check_import
%endif


%files -f %{pyproject_files}
%{_bindir}/hatch
%{_mandir}/man1/hatch.1*
%{_mandir}/man1/hatch-*.1*


%changelog
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.7.0-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Mon Jul 03 2023 Python Maint <python-maint@redhat.com> - 1.7.0-6
- Rebuilt for Python 3.12

* Sun Jun 18 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.0-5
- Use new (rpm 4.17.1+) bcond style

* Sat May 13 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.0-3
- Drop lower-bound on pyproject-rpm-macros

* Tue Apr 25 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.0-2
- Patch tests for hatchling 1.14.1

* Mon Apr 03 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.0-1
- Update to 1.7.0 (close RHBZ#2184066)

* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.6.3-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Sun Jan 01 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.3-5
- With hatchling ≥1.12.0, pyproject_files handles license file

* Sat Dec 31 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.3-4
- Patch tests for hatchling 1.12

* Tue Dec 20 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.3-3
- No longer need to patch virtualenv version on F38+

* Tue Dec 20 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.3-2
- Trivial spec file tidying

* Tue Oct 25 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.3-1
- Update to 1.6.3 (close RHBZ#2137456)

* Thu Oct 20 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.2-1
- Update to 1.6.2 (close RHBZ#2136397)

* Mon Oct 17 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.1-1
- Update to 1.6.1 (close RHBZ#2135197)

* Sat Oct 15 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.0-3
- Drop BuildRequires on python3dist(tomli)

* Tue Oct 11 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.0-2
- Add missing man pages

* Mon Oct 10 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.0-1
- Update to 1.6.0 (close RHBZ#2133234)
- Update man pages and improve cross-references

* Tue Sep 20 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.5.0-4
- Add a temporary test skip for hatchling 1.10.0

* Sat Sep 10 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.5.0-3
- Use hatchling’s new “prepare_metadata_…” hook support for BR’s

* Sat Sep 10 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.5.0-2
- Backport test changes for hatchling 1.9.0

* Thu Sep 01 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.5.0-1
- Update to 1.5.0 (close RHBZ#2121990)

* Tue Aug 16 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.4.2-1
- Update to 1.4.2 (close RHBZ#2116097)

* Fri Aug 12 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.3.1-6
- Stop loosening pyperclip version bound

* Fri Aug 05 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.3.1-5
- Confirm that License is SPDX MIT (no License field change)

* Sun Jul 24 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.3.1-4
- Add temporary test skips for hatchling 1.6.0

* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.3.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Tue Jul 12 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.3.1-2
- Update downstream man pages for hatch 1.3.1

* Tue Jul 12 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.3.1-1
- Update to 1.3.1 (close RHBZ#2105825)

* Tue Jun 14 2022 Python Maint <python-maint@redhat.com> - 1.2.1-3
- Rebuilt for Python 3.11

* Tue May 31 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.2.1-2
- Fix boilerplate for packaging pre-releases, currently unused

* Tue May 31 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.2.1-1
- Update to 1.2.1 (close RHBZ#2091789)

* Mon May 23 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.2.0-1
- Update to 1.2.0 (close RHBZ#2089095)

* Sat May 21 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.1.2-1
- Update to 1.1.2 (close RHBZ#2088851)

* Sat May 21 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.1.1^0099c83git20220519-2
- Fix archivename spec file macro

* Fri May 20 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.1.1^0099c83git20220519-1
- Updated snapshot that depends on hatchling >=1.0.0

* Wed May 18 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.1.1^2e649eegit20220518-1
- Package a snapshot for full Hatchling 1.0.0 compatibility
- Start running the “backend” tests, too

* Wed May 18 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.1.1-2
- Run backend tests, too

* Fri May 13 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.1.1-1
- Update to 1.1.1 (close RHBZ#2085129)
- Update URLs now that PyPA has adopted Hatch

* Fri May 06 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.0-1
- Update to 1.0.0 (close RHBZ#2035978)

* Sun Feb 06 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 0.23.1-3
- Add man pages

* Fri Feb 04 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 0.23.1-2
- Add a few extra doc files

* Fri Feb 04 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 0.23.1-1
- Update to 0.23.1 (final pre-1.0 release)

* Fri Feb 04 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 0.23.0-15
- Port to pyproject-rpm-macros (“new guidelines”)

* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.23.0-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.23.0-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Wed Jul 21 2021 Lumír Balhar <lbalhar@redhat.com> - 0.23.0-10
- Fix FTBFS in Fedora rawhide

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

* Thu Jan 28 2021 Lumír Balhar <lbalhar@redhat.com> - 0.23.0-8
- Skip one more test

* Tue Jan 26 2021 Lumír Balhar <lbalhar@redhat.com> - 0.23.0-7
- Skip broken test (timeouts)

* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.23.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Mon Jan 25 2021 Lumír Balhar <lbalhar@redhat.com> - 0.23.0-5
- Extend tests timeout

* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.23.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

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

* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.23.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Mon Nov 04 2019 Lumír Balhar <lbalhar@redhat.com> - 0.23.0-1
- New upstream version 0.23.0

* Thu Oct 03 2019 Miro Hrončok <mhroncok@redhat.com> - 0.20.0-12
- Rebuilt for Python 3.8.0rc1 (#1748018)

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

* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.20.0-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Tue Feb 12 2019 Lumír Balhar <lbalhar@redhat.com> - 0.20.0-9
- Fix dependency name python3-twine → twine

* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.20.0-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.20.0-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Wed Jun 27 2018 Lumír Balhar <lbalhar@redhat.com> - 0.20.0-6
- Bump release to rebuild in side tag f29-python with Python 3.7

* Wed Jun 27 2018 Lumír Balhar <lbalhar@redhat.com> - 0.20.0-5
- Fix FTBFS due to failing tests which newly requires internet connection

* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 0.20.0-4
- Rebuilt for Python 3.7

* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.20.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Tue Dec 05 2017 Lumir Balhar <lbalhar@redhat.com> - 0.20.0-2
- Backslashes removed from description

* Wed Nov 15 2017 Lumir Balhar <lbalhar@redhat.com> - 0.20.0-1
- New upstream version
- New dependencies python-adduserpath (module userpath) and python-toml
- One test skipped due to internet connection requirement

* Wed Sep 13 2017 Lumir Balhar <lbalhar@redhat.com> - 0.11.0-1
- Initial package.