224 lines
8.9 KiB
RPMSpec
224 lines
8.9 KiB
RPMSpec
# When bootstrapping Python, we cannot test this yet
|
||
# RHEL does not include the test dependencies and the dependencies for extras
|
||
%if 0%{?rhel}
|
||
%bcond_with tests
|
||
%bcond_with extras
|
||
%else
|
||
%bcond_without tests
|
||
%bcond_without extras
|
||
%endif
|
||
|
||
Name: python-urllib3
|
||
Version: 2.2.3
|
||
Release: %autorelease
|
||
Summary: HTTP library with thread-safe connection pooling, file post, and more
|
||
|
||
# SPDX
|
||
License: MIT
|
||
URL: https://github.com/urllib3/urllib3
|
||
Source0: %{url}/archive/%{version}/urllib3-%{version}.tar.gz
|
||
# A special forked copy of Hypercorn is required for testing. We asked about
|
||
# the possiblility of using a released version in the future in:
|
||
# Path toward testing with a released version of hypercorn?
|
||
# https://github.com/urllib3/urllib3/3334
|
||
# Upstream would like to get the necessary changes merged into Hypercorn, but
|
||
# explained clearly why the forked copy is needed for now.
|
||
#
|
||
# Note that dev-requirements.txt references the urllib3-changes branch of
|
||
# https://github.com/urllib3/hypercorn/, and we should use the latest commit
|
||
# from that branch, but we package using a commit hash for reproducibility.
|
||
#
|
||
# We do not need to treat this as a bundled dependency because it is not
|
||
# installed in the buildroot or otherwise included in any of the binary RPMs.
|
||
%global hypercorn_url https://github.com/urllib3/hypercorn
|
||
%global hypercorn_commit d1719f8c1570cbd8e6a3719ffdb14a4d72880abb
|
||
Source1: %{hypercorn_url}/archive/%{hypercorn_commit}/hypercorn-%{hypercorn_commit}.tar.gz
|
||
|
||
BuildArch: noarch
|
||
|
||
BuildRequires: python3-devel
|
||
|
||
%if %{with tests}
|
||
# Test dependencies are listed only in dev-requirements.txt. Because there are
|
||
# linters and coverage tools mixed in, and exact versions are pinned, we resort
|
||
# to manual listing.
|
||
# h2==4.1.0: also in the h2 extra
|
||
BuildRequires: %{py3_dist h2}
|
||
# coverage==7.4.1: omitted linter/coverage tool
|
||
# PySocks==1.7.1
|
||
BuildRequires: %{py3_dist PySocks}
|
||
# pytest==8.0.2
|
||
BuildRequires: %{py3_dist pytest}
|
||
# pytest-timeout==2.1.0
|
||
BuildRequires: %{py3_dist pytest-timeout}
|
||
# pyOpenSSL==24.0.0
|
||
BuildRequires: %{py3_dist pyOpenSSL}
|
||
# idna==3.7
|
||
BuildRequires: %{py3_dist idna}
|
||
# # As of v1.1.0, child CA certificates generated by trustme fail
|
||
# # verification by CPython 3.13.
|
||
# # https://github.com/python-trio/trustme/pull/642
|
||
# trustme @ git+https://github.com/python-trio/trustme@b3a767f336e20600f30c9ff78385a58352ff6ee3
|
||
BuildRequires: %{py3_dist trustme}
|
||
# cryptography==42.0.4
|
||
BuildRequires: %{py3_dist cryptography}
|
||
# backports.zoneinfo==0.2.1;python_version<"3.9"
|
||
# towncrier==23.6.0: used for generating a changelog
|
||
# pytest-memray==1.5.0;python_version<"3.13" and sys_platform!="win32" and
|
||
# implementation_name=="cpython": not packaged, unwanted profiler
|
||
# trio==0.25.0
|
||
BuildRequires: %{py3_dist trio}
|
||
# Quart==0.19.4
|
||
BuildRequires: %{py3_dist Quart}
|
||
# quart-trio==0.11.1
|
||
BuildRequires: %{py3_dist quart-trio}
|
||
# # https://github.com/pgjones/hypercorn/issues/62
|
||
# # https://github.com/pgjones/hypercorn/issues/168
|
||
# # https://github.com/pgjones/hypercorn/issues/169
|
||
# hypercorn @ git+https://github.com/urllib3/hypercorn@urllib3-changes
|
||
# hypercorn is packaged, but we need the forked/bundled version
|
||
# httpx==0.25.2
|
||
BuildRequires: %{py3_dist httpx}
|
||
# pytest-socket==0.7.0: not packaged, not strictly required
|
||
# cffi==1.17.0rc1
|
||
BuildRequires: %{py3_dist cffi}
|
||
%endif
|
||
|
||
%global _description %{expand:
|
||
urllib3 is a powerful, user-friendly HTTP client for Python. urllib3 brings
|
||
many critical features that are missing from the Python standard libraries:
|
||
|
||
• Thread safety.
|
||
• Connection pooling.
|
||
• Client-side SSL/TLS verification.
|
||
• File uploads with multipart encoding.
|
||
• Helpers for retrying requests and dealing with HTTP redirects.
|
||
• Support for gzip, deflate, brotli, and zstd encoding.
|
||
• Proxy support for HTTP and SOCKS.
|
||
• 100% test coverage.}
|
||
|
||
%description %{_description}
|
||
|
||
|
||
%package -n python3-urllib3
|
||
Summary: %{summary}
|
||
|
||
BuildRequires: ca-certificates
|
||
Requires: ca-certificates
|
||
|
||
# There has historically been a manual hard dependency on python3-idna.
|
||
BuildRequires: %{py3_dist idna}
|
||
Requires: %{py3_dist idna}
|
||
|
||
%if %{with extras}
|
||
# There has historically been a manual hard dependency on python3-pysocks;
|
||
# since bringing it in is the sole function of python3-urllib3+socks,
|
||
# we recommend it, so it is installed by default.
|
||
Recommends: python3-urllib3+socks
|
||
%endif
|
||
|
||
%description -n python3-urllib3 %{_description}
|
||
|
||
|
||
%if %{with extras}
|
||
%pyproject_extras_subpkg -n python3-urllib3 brotli zstd socks h2
|
||
%endif
|
||
|
||
|
||
%prep
|
||
%autosetup -n urllib3-%{version}
|
||
%setup -q -n urllib3-%{version} -T -D -b 1
|
||
|
||
# Make sure that the RECENT_DATE value doesn't get too far behind what the current date is.
|
||
# RECENT_DATE must not be older that 2 years from the build time, or else test_recent_date
|
||
# (from test/test_connection.py) would fail. However, it shouldn't be to close to the build time either,
|
||
# since a user's system time could be set to a little in the past from what build time is (because of timezones,
|
||
# corner cases, etc). As stated in the comment in src/urllib3/connection.py:
|
||
# When updating RECENT_DATE, move it to within two years of the current date,
|
||
# and not less than 6 months ago.
|
||
# Example: if Today is 2018-01-01, then RECENT_DATE should be any date on or
|
||
# after 2016-01-01 (today - 2 years) AND before 2017-07-01 (today - 6 months)
|
||
# There is also a test_ssl_wrong_system_time test (from test/with_dummyserver/test_https.py) that tests if
|
||
# user's system time isn't set as too far in the past, because it could lead to SSL verification errors.
|
||
# That is why we need RECENT_DATE to be set at most 2 years ago (or else test_ssl_wrong_system_time would
|
||
# result in false positive), but before at least 6 month ago (so this test could tolerate user's system time being
|
||
# set to some time in the past, but not to far away from the present).
|
||
# Next few lines update RECENT_DATE dynamically.
|
||
recent_date=$(date --date "7 month ago" +"%Y, %_m, %_d")
|
||
sed -i "s/^RECENT_DATE = datetime.date(.*)/RECENT_DATE = datetime.date($recent_date)/" src/urllib3/connection.py
|
||
|
||
|
||
%generate_buildrequires
|
||
export SETUPTOOLS_SCM_PRETEND_VERSION='%{version}'
|
||
# Generate BR’s from packaged extras even when tests are disabled, to ensure
|
||
# the extras metapackages are installable if the build succeeds.
|
||
%pyproject_buildrequires %{?with_extras:-x brotli,zstd,socks,h2}
|
||
|
||
|
||
%build
|
||
export SETUPTOOLS_SCM_PRETEND_VERSION='%{version}'
|
||
%pyproject_wheel
|
||
|
||
|
||
%install
|
||
%pyproject_install
|
||
|
||
%pyproject_save_files -l urllib3
|
||
|
||
|
||
%check
|
||
# urllib3.contrib.socks requires urllib3[socks]
|
||
#
|
||
# urllib3.contrib.emscripten is “special” (import js will fail)
|
||
# urllib3.contrib.ntlmpool is deprecated and requires ntlm
|
||
# urllib3.contrib.securetransport is macOS only
|
||
# urllib3.contrib.pyopenssl requires pyOpenSSL
|
||
%{pyproject_check_import %{!?with_extras:-e urllib3.contrib.socks -e urllib3.http2*}
|
||
-e urllib3.contrib.emscripten*
|
||
-e urllib3.contrib.ntlmpool
|
||
-e urllib3.contrib.securetransport
|
||
-e urllib3.contrib.pyopenssl}
|
||
|
||
# Increase the “long timeout” for slower environments; as of this writing, it
|
||
# is increased from 0.1 to 0.5 second.
|
||
export CI=1
|
||
# Interpose the special forked copy of Hypercorn.
|
||
hypercorndir="${PWD}/../hypercorn-%{hypercorn_commit}/src"
|
||
export PYTHONPATH="${hypercorndir}:%{buildroot}%{python3_sitelib}"
|
||
|
||
%if %{with tests}
|
||
# This test still times out sometimes, especially on certain architectures,
|
||
# even when we export the CI environment variable to increase timeouts.
|
||
k="${k-}${k+ and }not (TestHTTPProxyManager and test_tunneling_proxy_request_timeout[https-https])"
|
||
%if 0%{?__isa_bits} == 32
|
||
# These fail on i686 and presumably on other 32-bit architectures. Note that
|
||
# since the base package is noarch and the package may be assigned to a builder
|
||
# of any architecture, there is no guarantee that these tests run at all in a
|
||
# particular build. See discussion in
|
||
# https://src.fedoraproject.org/rpms/python-urllib3/pull-request/33.
|
||
k="${k-}${k+ and }not (TestSSL and test_requesting_large_resources_via_ssl)"
|
||
k="${k-}${k+ and }not (TestSocketSSL and test_requesting_large_resources_via_ssl)"
|
||
%endif
|
||
# The error message does not quite match what upstream expects; this is fixed
|
||
# in later urllib3 releases.
|
||
# > with pytest.raises(
|
||
# SSLError, match=r"(wrong version number|record overflow)"
|
||
# ):
|
||
# E AssertionError: Regex pattern did not match.
|
||
# E Regex: '(wrong version number|record overflow)'
|
||
# E Input: '("read error: Error([(\'SSL routines\', \'\',
|
||
# \'packet length too long\'), (\'SSL routines\', \'\',
|
||
# \'record layer failure\')])",)'
|
||
k="${k-}${k+ and }not (TestSocketSSL and test_ssl_failure_midway_through_conn)"
|
||
|
||
%pytest -v -rs ${ignore-} -k "${k-}"
|
||
%pytest -v -rs ${ignore-} -k "${k-}" --integration
|
||
%endif
|
||
|
||
|
||
%files -n python3-urllib3 -f %{pyproject_files}
|
||
%doc CHANGES.rst README.md
|
||
|
||
|
||
%changelog
|
||
%autochangelog
|