Blame SPECS/python3.11-urllib3.spec

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