python-urllib3/python-urllib3.spec
Benjamin A. Beasley 52671c660b Update to 2.0.7
- Add metapackage for new zstd extra
- Upstream no longer vendors six, so we no longer need to bundle it
- Assert that there is a license file in the .dist-info directory
- Greatly reduce the number of skipped tests
- Stop explicitly bounding versions of build dependencies for testing
2024-08-05 11:14:55 -04:00

181 lines
6.9 KiB
RPMSpec
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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.0.7
Release: %autorelease
Summary: HTTP library with thread-safe connection pooling, file post, and more
# SPDX
License: MIT
URL: https://github.com/urllib3/urllib3
Source: %{url}/archive/%{version}/urllib3-%{version}.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.
# coverage==7.3.2: omitted linter/coverage tool
# tornado==6.3.3
BuildRequires: %{py3_dist tornado}
# PySocks==1.7.1
BuildRequires: %{py3_dist PySocks}
# pytest==7.4.2
BuildRequires: %{py3_dist pytest}
# pytest-timeout==2.1.0
BuildRequires: %{py3_dist pytest-timeout}
# pyOpenSSL==23.2.0
BuildRequires: %{py3_dist pyOpenSSL}
# trustme==1.1.0
BuildRequires: %{py3_dist trustme}
# cryptography==41.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.8" and implementation_name=="cpython":
# not packaged, unwanted profiler
%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
%endif
%prep
%autosetup -n urllib3-%{version}
# 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
# Generate BRs 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}
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files -l urllib3
%check
# urllib3.contrib.socks requires urllib3[socks]
# 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.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
%if %{with tests}
# These tests *may* time out; https://github.com/urllib3/urllib3/pull/3206
# purports to fix some of them, but there is still a lot of flakiness here.
ignore="${ignore-} --ignore=test/with_dummyserver/test_socketlevel.py"
# 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
# These require network access:
k="${k-}${k+ and }not (TestPoolManager and test_deprecated_no_scheme)"
# 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-}"
%endif
%files -n python3-urllib3 -f %{pyproject_files}
%doc CHANGES.rst README.md
%changelog
%autochangelog