Blame SPECS/python3.11-urllib3.spec

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