Blame SPECS/python3.11-urllib3.spec

34f2ef
%global __python3 /usr/bin/python3.11
34f2ef
%global python3_pkgversion 3.11
34f2ef
34f2ef
%global srcname urllib3
34f2ef
34f2ef
# RHEL: Tests disabled during build due to missing dependencies
34f2ef
%bcond_with tests
34f2ef
34f2ef
Name:           python%{python3_pkgversion}-%{srcname}
34f2ef
Version:        1.26.12
34f2ef
Release:        1%{?dist}
34f2ef
Summary:        Python HTTP library with thread-safe connection pooling and file post
34f2ef
34f2ef
License:        MIT
34f2ef
URL:            https://github.com/urllib3/urllib3
34f2ef
Source0:        %{url}/archive/%{version}/%{srcname}-%{version}.tar.gz
34f2ef
BuildArch:      noarch
34f2ef
34f2ef
34f2ef
BuildRequires:  python%{python3_pkgversion}-devel
34f2ef
BuildRequires:  python%{python3_pkgversion}-rpm-macros
34f2ef
BuildRequires:  python%{python3_pkgversion}-setuptools
34f2ef
%if %{with tests}
34f2ef
BuildRequires:  python%{python3_pkgversion}-dateutil
34f2ef
BuildRequires:  python%{python3_pkgversion}-six
34f2ef
BuildRequires:  python%{python3_pkgversion}-pysocks
34f2ef
BuildRequires:  python%{python3_pkgversion}-pytest
34f2ef
BuildRequires:  python%{python3_pkgversion}-pytest-freezegun
34f2ef
BuildRequires:  python%{python3_pkgversion}-pytest-timeout
34f2ef
BuildRequires:  python%{python3_pkgversion}-tornado
34f2ef
BuildRequires:  python%{python3_pkgversion}-trustme
34f2ef
BuildRequires:  python%{python3_pkgversion}-idna
34f2ef
%endif
34f2ef
34f2ef
Requires:       ca-certificates
34f2ef
Requires:       python%{python3_pkgversion}-idna
34f2ef
Requires:       python%{python3_pkgversion}-six >= 1.16.0
34f2ef
Requires:       python%{python3_pkgversion}-pysocks
34f2ef
34f2ef
%description
34f2ef
Python HTTP module with connection pooling and file POST abilities.
34f2ef
34f2ef
%prep
34f2ef
%autosetup -p1 -n %{srcname}-%{version}
34f2ef
# Make sure that the RECENT_DATE value doesn't get too far behind what the current date is.
34f2ef
# RECENT_DATE must not be older that 2 years from the build time, or else test_recent_date
34f2ef
# (from test/test_connection.py) would fail. However, it shouldn't be to close to the build time either,
34f2ef
# since a user's system time could be set to a little in the past from what build time is (because of timezones,
34f2ef
# corner cases, etc). As stated in the comment in src/urllib3/connection.py:
34f2ef
#   When updating RECENT_DATE, move it to within two years of the current date,
34f2ef
#   and not less than 6 months ago.
34f2ef
#   Example: if Today is 2018-01-01, then RECENT_DATE should be any date on or
34f2ef
#   after 2016-01-01 (today - 2 years) AND before 2017-07-01 (today - 6 months)
34f2ef
# There is also a test_ssl_wrong_system_time test (from test/with_dummyserver/test_https.py) that tests if
34f2ef
# user's system time isn't set as too far in the past, because it could lead to SSL verification errors.
34f2ef
# That is why we need RECENT_DATE to be set at most 2 years ago (or else test_ssl_wrong_system_time would
34f2ef
# result in false positive), but before at least 6 month ago (so this test could tolerate user's system time being
34f2ef
# set to some time in the past, but not to far away from the present).
34f2ef
# Next few lines update RECENT_DATE dynamically.
34f2ef
recent_date=$(date --date "7 month ago" +"%Y, %_m, %_d")
34f2ef
sed -i "s/^RECENT_DATE = datetime.date(.*)/RECENT_DATE = datetime.date($recent_date)/" src/urllib3/connection.py
34f2ef
34f2ef
# Drop the dummyserver tests in koji.  They fail there in real builds, but not
34f2ef
# in scratch builds (weird).
34f2ef
rm -rf test/with_dummyserver/
34f2ef
# Don't run the Google App Engine tests
34f2ef
rm -rf test/appengine/
34f2ef
# Lots of these tests started failing, even for old versions, so it has something
34f2ef
# to do with Fedora in particular. They don't fail in upstream build infrastructure
34f2ef
rm -rf test/contrib/
34f2ef
34f2ef
# Tests for Python built without SSL, but Fedora builds with SSL. These tests
34f2ef
# fail when combined with the unbundling of backports-ssl_match_hostname
34f2ef
rm -f test/test_no_ssl.py
34f2ef
34f2ef
# Use the standard library instead of a backport
34f2ef
sed -i -e 's/^import mock/from unittest import mock/' \
34f2ef
       -e 's/^from mock import /from unittest.mock import /' \
34f2ef
    test/*.py docs/conf.py
34f2ef
34f2ef
%build
34f2ef
%py3_build
34f2ef
34f2ef
34f2ef
%install
34f2ef
%py3_install
34f2ef
34f2ef
# Unbundle the Python 3 build
34f2ef
rm -rf %{buildroot}/%{python3_sitelib}/urllib3/packages/six.py
34f2ef
rm -rf %{buildroot}/%{python3_sitelib}/urllib3/packages/__pycache__/six.*
34f2ef
34f2ef
mkdir -p %{buildroot}/%{python3_sitelib}/urllib3/packages/
34f2ef
ln -s %{python3_sitelib}/six.py %{buildroot}/%{python3_sitelib}/urllib3/packages/six.py
34f2ef
ln -s %{python3_sitelib}/__pycache__/six.cpython-%{python3_version_nodots}.opt-1.pyc \
34f2ef
      %{buildroot}/%{python3_sitelib}/urllib3/packages/__pycache__/
34f2ef
ln -s %{python3_sitelib}/__pycache__/six.cpython-%{python3_version_nodots}.pyc \
34f2ef
      %{buildroot}/%{python3_sitelib}/urllib3/packages/__pycache__/
34f2ef
34f2ef
34f2ef
%if %{with tests}
34f2ef
%check
34f2ef
%pytest -v
34f2ef
%endif
34f2ef
34f2ef
34f2ef
%files -n python%{python3_pkgversion}-%{srcname}
34f2ef
%license LICENSE.txt
34f2ef
%doc CHANGES.rst README.rst
34f2ef
%{python3_sitelib}/urllib3/
34f2ef
%{python3_sitelib}/urllib3-*.egg-info/
34f2ef
34f2ef
34f2ef
%changelog
34f2ef
* Tue Nov 29 2022 Charalampos Stratakis <cstratak@redhat.com> - 1.26.12-1
34f2ef
- Initial package
34f2ef
- Fedora contributions by:
34f2ef
      Adam Williamson <awilliam@redhat.com>
34f2ef
      Anna Khaitovich <akhaitov@redhat.com>
34f2ef
      Arun S A G <sagarun@gmail.com>
34f2ef
      Carl George <carl@george.computer>
34f2ef
      Charalampos Stratakis <cstratak@redhat.com>
34f2ef
      Dennis Gilmore <dennis@ausil.us>
34f2ef
      Haikel Guemar <hguemar@fedoraproject.org>
34f2ef
      Iryna Shcherbina <shcherbina.iryna@gmail.com>
34f2ef
      Jeremy Cline <jeremy@jcline.org>
34f2ef
      Karolina Surma <ksurma@redhat.com>
34f2ef
      Kevin Fenzi <kevin@scrye.com>
34f2ef
      Lukas Slebodnik <lslebodn@redhat.com>
34f2ef
      Lumir Balhar <lbalhar@redhat.com>
34f2ef
      Miro HronĨok <miro@hroncok.cz>
34f2ef
      Ralph Bean <rbean@redhat.com>
34f2ef
      Robert Kuska <rkuska@redhat.com>
34f2ef
      Slavek Kabrda <bkabrda@redhat.com>
34f2ef
      Tomas Hoger <thoger@redhat.com>
34f2ef
      Tom Callaway <spot@fedoraproject.org>
34f2ef
      Toshio Kuratomi <toshio@fedoraproject.org>
34f2ef
      yatinkarel <ykarel@redhat.com>