Blame SPECS/python3.11-urllib3.spec

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