Blame SPECS/python3.11-urllib3.spec

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