From d7171f5edbdfe16122668f323f001631c804aa2e Mon Sep 17 00:00:00 2001 From: Shawn Wang Date: Wed, 12 Apr 2023 10:45:52 +0800 Subject: [PATCH] Optimize the spec file and add doc package Signed-off-by: Shawn Wang --- python-urllib3.spec | 78 ++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 50 deletions(-) diff --git a/python-urllib3.spec b/python-urllib3.spec index 1294819..30cb4b9 100644 --- a/python-urllib3.spec +++ b/python-urllib3.spec @@ -1,77 +1,52 @@ -%define anolis_release 1 -%global srcname urllib3 +%define anolis_release 2 +%bcond_with tests +%global pypi_name urllib3 -# When bootstrapping Python, we cannot test this yet -%bcond_without tests - -Name: python-%{srcname} +Name: python-%{pypi_name} Version: 1.26.13 Release: %{anolis_release}%{dist} Summary: Python HTTP library with thread-safe connection pooling and file post - License: MIT URL: https://github.com/urllib3/urllib3 -Source0: %{url}/archive/%{version}/%{srcname}-%{version}.tar.gz +Source0: %{url}/archive/%{version}/%{pypi_name}-%{version}.tar.gz BuildArch: noarch %description Python HTTP module with connection pooling and file POST abilities. -%package -n python3-%{srcname} +%package -n python3-%{pypi_name} Summary: Python3 HTTP library with thread-safe connection pooling and file post -BuildRequires: python3-devel -BuildRequires: python3-setuptools +BuildRequires: python3-devel python3-setuptools pyproject-rpm-macros %if %{with tests} -BuildRequires: python3-dateutil -BuildRequires: python3-six -BuildRequires: python3-pysocks -BuildRequires: python3-pytest -BuildRequires: python3-pytest-freezegun -BuildRequires: python3-pytest-timeout -BuildRequires: python3-tornado -BuildRequires: python3-trustme -BuildRequires: python3-idna +BuildRequires: python3-dateutil python3-six python3-pysocks +BuildRequires: python3-pytest python3-pytest-freezegun python3-pytest-timeout +BuildRequires: python3-tornado python3-trustme python3-idna %endif Requires: ca-certificates -Requires: python3-idna -Requires: python3-six >= 1.16.0 -Requires: python3-pysocks +Requires: python3-idna python3-six >= 1.16.0 python3-pysocks -%description -n python3-%{srcname} +%description -n python3-%{pypi_name} Python3 HTTP module with connection pooling and file POST abilities. +%package -n python3-%{pypi_name}-doc +Summary: Documentation files for python3-%{pypi_name} +Requires: python3-%{pypi_name} = %{version}-%{release} +BuildArch: noarch + +%description -n python3-%{pypi_name}-doc +Documentation fliles for python3-%{pypi_name}. %prep -%autosetup -p1 -n %{srcname}-%{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. +%autosetup -p1 -n %{pypi_name}-%{version} 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 -# Drop the dummyserver tests in koji. They fail there in real builds, but not -# in scratch builds (weird). rm -rf test/with_dummyserver/ -# Don't run the Google App Engine tests rm -rf test/appengine/ -# Lots of these tests started failing, even for old versions. rm -rf test/contrib/ -# Use the standard library instead of a backport sed -i -e 's/^import mock/from unittest import mock/' \ -e 's/^from mock import /from unittest.mock import /' \ test/*.py docs/conf.py @@ -82,23 +57,26 @@ sed -i -e 's/^import mock/from unittest import mock/' \ %build %pyproject_wheel - %install %pyproject_install +%pyproject_save_files %{pypi_name} %if %{with tests} %check %pytest -v %endif - -%files -n python3-%{srcname} +%files -n python3-%{pypi_name} -f %{pyproject_files} %license LICENSE.txt + +%files -n python3-%{pypi_name}-doc %doc CHANGES.rst README.rst -%{python3_sitelib}/urllib3/ -%{python3_sitelib}/urllib3-%{version}.dist-info/ %changelog +* Wed Apr 12 2023 Shawn Wang - 1.26.13-2 +- Add doc package +- Optimize the spec file + * Tue Jan 03 2023 mgb01105731 - 1.26.13-1 - update to version 1.26.13 -- Gitee