%bcond_with tests

Name:           python-requests
Version:        2.26.0
Release:        9
Summary:        Python HTTP Library
License:        ASL 2.0
URL:            http://python-requests.org/
Source0:        https://github.com/psf/requests/archive/refs/tags/v%{version}.tar.gz

Patch1:         requests-2.12.4-tests_nonet.patch
Patch2:         requests-2.20.0-no-py2-httpbin.patch
Patch3:         patch-requests-certs.py-to-use-the-system-CA-bundle.patch
Patch4:         Remove-tests-that-use-the-tarpit.patch
Patch5:         Update-dependency-with-chardet.patch
Patch6000:      backport-CVE-2023-32681.patch
Patch6001:      backport-CVE-2024-1682.patch

BuildArch:      noarch

%description
Requests is an HTTP library, written in Python, as an alternative
to Python's builtin urllib2 which requires work (even
method overrides) to perform basic tasks.
Features of Requests:
 - GET, HEAD, POST, PUT, DELETE Requests:
   + HTTP Header Request Attachment.
   + Data/Params Request Attachment.
   + Multipart File Uploads.
   + CookieJar Support.
   + Redirection History.
   + Redirection Recursion Urllib Fix.
   + Automatic Decompression of GZipped Content.
   + Unicode URL Support.
 - Authentication:
   + URL + HTTP Auth Registry.

%package -n      python%{python3_pkgversion}-requests
Summary:         Awesome Python HTTP Library That's Actually Usable

%{?python_provide:%python_provide python%{python3_pkgversion}-requests}

BuildRequires:   python%{python3_pkgversion}-devel
BuildRequires:   python%{python3_pkgversion}-chardet
BuildRequires:   python%{python3_pkgversion}-urllib3
BuildRequires:   python%{python3_pkgversion}-idna

%if %{with tests}
BuildRequires:   python%{python3_pkgversion}-pytest
BuildRequires:   python%{python3_pkgversion}-pytest-cov
BuildRequires:   python%{python3_pkgversion}-pytest-httpbin
BuildRequires:   python%{python3_pkgversion}-pytest-mock
%endif

Provides:       python%{python3_pkgversion}dist(requests) = %{version}
Provides:       python%{python3_version}dist(requests) = %{version}

Requires:        python%{python3_pkgversion}-chardet
Requires:        python%{python3_pkgversion}-urllib3
Requires:        python%{python3_pkgversion}-idna
Requires:        ca-certificates
Requires:        python%{python3_pkgversion}-charset-normalizer

%description -n  python%{python3_pkgversion}-requests
Requests is an ISC Licensed HTTP library, written in Python, for human
beings.
Most existing Python modules for sending HTTP requests are extremely
verbose and cumbersome. Python's builtin urllib2 module provides most of
the HTTP capabilities you should need, but the api is thoroughly broken.
It requires an enormous amount of work (even method overrides) to
perform the simplest of tasks.

%package_help

%prep
%autosetup -p1 -n requests-%{version}
rm -rf requests/cacert.pem
sed -i '/#!\/usr\/.*python/d' requests/certs.py

%build
%py3_build

%install
%py3_install

%if %{with tests}
%check
PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} -m pytest -v
%endif 

%files -n python%{python3_pkgversion}-requests 
%defattr(-,root,root)
%license LICENSE
%{python3_sitelib}/requests*/*

%files    help
%defattr(-,root,root)
%doc HISTORY.md README.md

%changelog
* Mon Nov 18 2024 zhangpan <zhangpan103@h-partners.com> - 2.26.0-9
- fix CVE-2024-1682

* Wed May 31 2023 zhangpan <zhangpan103@h-partners.com> - 2.26.0-8
- fix CVE-2023-32681

* Sat Nov 05 2022 yaoxin <yaoxin30@h-partners.com> - 2.26.0-7
- Fix the mailman build error caused by the python-chardet update.

* Tue Oct 25 2022 wangkerong <wangkerong@h-partners.com> - 2.26.0-6
- rebuild for next release

* Tue Jan 11 2022 zhujunhao <zhujunhao8@huawei.com> - 2.26.0-5
- modify build failed

* Thu Dec 30 2021 yangcheng <yangcheng87@huawei.com> - 2.26.0-4
- Adapt to python 3.9.9

* Wed Dec 22 2021 wangkerong <wangkerong@huawei.com> - 2.26.0-3
- add python-charset-normalizer

* Mon Dec 13 2021 wangkerong <wangkerong@huawei.com> - 2.26.0-2
- provide pythonxdist(requests)

* Sat Dec 04 2021 wangkerong <wangkerong@huawei.com> - 2.26.0-1
- update to 2.26.0

* Thu Feb 4 2021 chengguipeng <chengguipeng1@huawei.com> - 2.25.1-1
- update to 2.25.1

* Wed Oct 14 2020 shangyibin <shangyibin1@huawei.com> - 2.24.0-3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC: remove python2-requests package

*Tue Aug 4 2020 wuchaochao <wuchaochao4@huawei.com> - 2.24.0-2
- Type:bugfix
- ID:NA
- SUG:NA
- DESC: remove reliance on  "certifi" 

* Thu Jul 23 2020 wuchaochao <wuchaochao4@huawei.com> - 2.24.0-1
- update package to 2.24.0

* Sat Jan 11 2020 openEuler Buildteam <buildteam@openeuler.org> - 2.21.0-5
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: delete describe info

* Fri Dec 20 2019 openEuler Buildteam <buildteam@openeuler.org> - 2.21.0-4
- Type:bugfix
- Id:NA
- SUG:NA
- DESC:modify the patch

* Wed Oct 30 2019 hexiaowen <hexiaowen@huawei.com> - 2.21.0-3
- disable tests

* Thu Oct 17 2019 openEuler Buildteam <buildteam@openeuler.org> - 2.21.0-2
- Type:bugfix
- Id:NA
- SUG:NA
- DESC:add the provides of python3

* Wed Sep 25 2019 openEuler Buildteam <buildteam@openeuler.org> - 2.21.0-1
- Package init
