python3: seperate pip & setuptools

Use system provided pip & setuptools whl.

Change-Id: I4b2e1fbe1d03bd93a8e447fe61e26814c10e498f
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/c/photon/+/23363
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
This commit is contained in:
Shreenidhi Shedi 2024-02-23 02:54:08 +00:00
parent 990b3fa0d6
commit 4b20174027
7 changed files with 353 additions and 48 deletions

View File

@ -0,0 +1,127 @@
From 09c983fdeabe3fa0b90b73f32ddf84a61e498e09 Mon Sep 17 00:00:00 2001
From: Karolina Surma <ksurma@redhat.com>
Date: Tue, 15 Nov 2022 09:22:46 +0100
Subject: [PATCH] Dummy certifi patch
---
src/pip/_vendor/certifi/core.py | 105 ++------------------------------
1 file changed, 6 insertions(+), 99 deletions(-)
diff --git a/src/pip/_vendor/certifi/core.py b/src/pip/_vendor/certifi/core.py
index c3e5466..eb297f7 100644
--- a/src/pip/_vendor/certifi/core.py
+++ b/src/pip/_vendor/certifi/core.py
@@ -4,105 +4,12 @@ certifi.py
This module returns the installation location of cacert.pem or its contents.
"""
-import sys
+# The RPM-packaged certifi always uses the system certificates
+def where() -> str:
+ return '/etc/pki/tls/certs/ca-bundle.crt'
-if sys.version_info >= (3, 11):
+def contents() -> str:
+ with open(where(), encoding='utf=8') as data:
+ return data.read()
- from importlib.resources import as_file, files
-
- _CACERT_CTX = None
- _CACERT_PATH = None
-
- def where() -> str:
- # This is slightly terrible, but we want to delay extracting the file
- # in cases where we're inside of a zipimport situation until someone
- # actually calls where(), but we don't want to re-extract the file
- # on every call of where(), so we'll do it once then store it in a
- # global variable.
- global _CACERT_CTX
- global _CACERT_PATH
- if _CACERT_PATH is None:
- # This is slightly janky, the importlib.resources API wants you to
- # manage the cleanup of this file, so it doesn't actually return a
- # path, it returns a context manager that will give you the path
- # when you enter it and will do any cleanup when you leave it. In
- # the common case of not needing a temporary file, it will just
- # return the file system location and the __exit__() is a no-op.
- #
- # We also have to hold onto the actual context manager, because
- # it will do the cleanup whenever it gets garbage collected, so
- # we will also store that at the global level as well.
- _CACERT_CTX = as_file(files("pip._vendor.certifi").joinpath("cacert.pem"))
- _CACERT_PATH = str(_CACERT_CTX.__enter__())
-
- return _CACERT_PATH
-
- def contents() -> str:
- return files("pip._vendor.certifi").joinpath("cacert.pem").read_text(encoding="ascii")
-
-elif sys.version_info >= (3, 7):
-
- from importlib.resources import path as get_path, read_text
-
- _CACERT_CTX = None
- _CACERT_PATH = None
-
- def where() -> str:
- # This is slightly terrible, but we want to delay extracting the
- # file in cases where we're inside of a zipimport situation until
- # someone actually calls where(), but we don't want to re-extract
- # the file on every call of where(), so we'll do it once then store
- # it in a global variable.
- global _CACERT_CTX
- global _CACERT_PATH
- if _CACERT_PATH is None:
- # This is slightly janky, the importlib.resources API wants you
- # to manage the cleanup of this file, so it doesn't actually
- # return a path, it returns a context manager that will give
- # you the path when you enter it and will do any cleanup when
- # you leave it. In the common case of not needing a temporary
- # file, it will just return the file system location and the
- # __exit__() is a no-op.
- #
- # We also have to hold onto the actual context manager, because
- # it will do the cleanup whenever it gets garbage collected, so
- # we will also store that at the global level as well.
- _CACERT_CTX = get_path("pip._vendor.certifi", "cacert.pem")
- _CACERT_PATH = str(_CACERT_CTX.__enter__())
-
- return _CACERT_PATH
-
- def contents() -> str:
- return read_text("pip._vendor.certifi", "cacert.pem", encoding="ascii")
-
-else:
- import os
- import types
- from typing import Union
-
- Package = Union[types.ModuleType, str]
- Resource = Union[str, "os.PathLike"]
-
- # This fallback will work for Python versions prior to 3.7 that lack the
- # importlib.resources module but relies on the existing `where` function
- # so won't address issues with environments like PyOxidizer that don't set
- # __file__ on modules.
- def read_text(
- package: Package,
- resource: Resource,
- encoding: str = 'utf-8',
- errors: str = 'strict'
- ) -> str:
- with open(where(), encoding=encoding) as data:
- return data.read()
-
- # If we don't have importlib.resources, then we will just do the old logic
- # of assuming we're on the filesystem and munge the path directly.
- def where() -> str:
- f = os.path.dirname(__file__)
-
- return os.path.join(f, "cacert.pem")
-
- def contents() -> str:
- return read_text("pip._vendor.certifi", "cacert.pem", encoding="ascii")
--
2.37.3

View File

@ -0,0 +1,89 @@
%define srcname pip
%define python_wheel_dir %{_datadir}/python-wheels
%define python_wheel_name %{srcname}-%{version}-py3-none-any.whl
Summary: The PyPA recommended tool for installing Python packages.
Name: python3-pip
# if you make any security fix in this package, package the whl files
# python3.spec without miss
Version: 23.3.2
Release: 1%{?dist}
License: MIT
Group: Development/Languages/Python
Vendor: VMware, Inc.
Distribution: Photon
Url: https://pypi.org/project/pip/
Source0: https://files.pythonhosted.org/packages/6b/8b/0b16094553ecc680e43ded8f920c3873b01b1da79a54274c98f08cb29fca/%{srcname}-%{version}.tar.gz
%define sha512 %{srcname}=b2d8bcff02fe196163e88e02702861bfccba202e5c71d8c6843eeebc84066efa6987574e26a89ff25f096645e99c824dde585fbae415b66d5eb88657bb4d9cb4
Patch0: dummy-certifi.patch
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-xml
BuildRequires: python3-wheel
Requires: python3
Requires: python3-setuptools
Requires: python3-xml
Requires: %{name}-wheel = %{version}-%{release}
BuildArch: noarch
%description
Pip is the package installer for Python.
You can use pip to install packages from the Python Package Index and
other indexes.
%package wheel
Summary: The pip wheel
Requires: ca-certificates
%description wheel
A Python wheel of pip to use with venv.
%prep
%autosetup -p1 -n %{srcname}-%{version}
%build
%{python3} setup.py bdist_wheel
%install
%{python3} dist/%{python_wheel_name}/pip install \
--root %{buildroot} \
--no-deps \
--disable-pip-version-check \
--progress-bar off \
--verbose \
--ignore-installed \
--no-warn-script-location \
--no-index \
--no-cache-dir \
--find-links dist \
'pip==%{version}'
find %{buildroot}%{python3_sitelib} -name '*.exe' | xargs rm -vf
mkdir -p %{buildroot}%{python_wheel_dir}
install -p dist/%{python_wheel_name} -t %{buildroot}%{python_wheel_dir}
%check
%{py3_test}
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,755)
%{python3_sitelib}/*
%{_bindir}/pip*
%files wheel
%defattr(-,root,root,755)
%dir %{python_wheel_dir}
%{python_wheel_dir}/%{python_wheel_name}
%changelog
* Wed Feb 28 2024 Shreenidhi Shedi <shreenidhi.shedi@broadcom.com> 23.3.2-1
- Initial addition. Seperated from python3 spec.

View File

@ -0,0 +1,74 @@
%define srcname setuptools
%define python_wheel_dir %{_datadir}/python-wheels
%define python_wheel_name %{srcname}-%{version}-py3-none-any.whl
Summary: Extensions to the standard Python datetime module
Name: python3-setuptools
# if you make any security fix in this package, package the whl files
# python3.spec without miss
Version: 69.0.3
Release: 1%{?dist}
License: MIT
Group: Development/Languages/Python
Vendor: VMware, Inc.
Distribution: Photon
Url: https://pypi.org/project/setuptools
Source0: https://files.pythonhosted.org/packages/5f/36/7374297692bb9dbd7569a0f84887c7e5e314c41d5d9518cb76fbb130620d/%{srcname}-%{version}.tar.gz
%define sha512 %{srcname}=11df934931f4b73f7e07ea5713479593c6baa134d423556b2ae7aff0f1e5bdbdee1f5b516131adb169c838231ceb0293441fbf275ef7030dabecf74122565b6d
BuildRequires: python3-devel
BuildRequires: python3-xml
%define ExtraBuildRequires: python3-wheel
Requires: python3
Requires: python3-xml
Requires: %{name}-wheel = %{version}-%{release}
BuildArch: noarch
Provides: python%{python3_version}dist(setuptools)
%description
Setuptools is a fully-featured, actively-maintained, and stable library
designed to facilitate packaging Python projects.
It helps developers to easily share reusable code (in the form of a library) and programs
(e.g., CLI/GUI tools implemented in Python), that can be installed with pip and uploaded to PyPI.
%package wheel
Summary: The setuptools wheel
%description wheel
A Python wheel of setuptools to use with venv.
%prep
%autosetup -p1 -n %{srcname}-%{version}
%build
%{python3} setup.py bdist_wheel
%install
%{py3_install}
find %{buildroot}%{python3_sitelib} -name '*.exe' | xargs rm -f
mkdir -p %{buildroot}%{python_wheel_dir}
install -p dist/%{python_wheel_name} -t %{buildroot}%{python_wheel_dir}
%check
%{py3_test}
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,755)
%{python3_sitelib}/*
%files wheel
%defattr(-,root,root,755)
%dir %{python_wheel_dir}
%{python_wheel_dir}/%{python_wheel_name}
%changelog
* Wed Feb 28 2024 Shreenidhi Shedi <shreenidhi.shedi@broadcom.com> 69.0.3-1
- Initial addition. Seperated from python3 spec.

View File

@ -0,0 +1,30 @@
From 084266c8feee75cf429a3321dbaed426396c4b83 Mon Sep 17 00:00:00 2001
From: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
Date: Wed, 21 Feb 2024 18:53:19 +0530
Subject: [PATCH] ensurepip: upgrade bundled pip to 23.3.2
upgrade setuptools to 69.0.3
Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
---
Lib/ensurepip/__init__.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
index 81db9fa..98fad80 100644
--- a/Lib/ensurepip/__init__.py
+++ b/Lib/ensurepip/__init__.py
@@ -10,8 +10,8 @@ from importlib import resources
__all__ = ["version", "bootstrap"]
_PACKAGE_NAMES = ('setuptools', 'pip')
-_SETUPTOOLS_VERSION = "65.5.0"
-_PIP_VERSION = "23.2.1"
+_SETUPTOOLS_VERSION = "69.0.3"
+_PIP_VERSION = "23.3.2"
_PROJECTS = [
("setuptools", _SETUPTOOLS_VERSION, "py3"),
("pip", _PIP_VERSION, "py3"),
--
2.25.1

View File

@ -4,20 +4,26 @@
Summary: A high-level scripting language
Name: python3
Version: 3.11.7
Release: 1%{?dist}
Release: 2%{?dist}
License: PSF
URL: http://www.python.org
Group: System Environment/Programming
Vendor: VMware, Inc.
Distribution: Photon
Source0: https://www.python.org/ftp/python/%{version}/Python-%{version}.tar.xz
%define sha512 Python=11e06f2ffe1f66888cb5b4e9f607de815294d6863a77eda6ec6d7c724ef158df9f51881f4a956d4a6fa973c2fb6fd031d495e3496e9b0bb53793fb1cc8434c63
Source0: https://www.python.org/ftp/python/%{version}/Python-%{version}.tar.xz
%define sha512 Python=11e06f2ffe1f66888cb5b4e9f607de815294d6863a77eda6ec6d7c724ef158df9f51881f4a956d4a6fa973c2fb6fd031d495e3496e9b0bb53793fb1cc8434c63
Source1: macros.python
Source1: macros.python
# check readme inside the tarball for instructions on
# how to create this tarball
Source2: setuptools-pip-wheels%{?dist}-1.0.tar.xz
%define sha512 setuptools-pip-wheels=73f478b62e7716ec19f366bb8d0866af19c5afa55a8b90664efe3760a69903be2f4b79b41ca6946c8528eaad594e19974dbb6c8a2735722b1b35b2aa77bc1569
Patch0: cgi3.patch
Patch1: use-HMAC-SHA256-in-FIPS-mode.patch
Patch2: ensurepip-upgrade-bundled-pip-and-setuptools.patch
BuildRequires: pkg-config >= 0.28
BuildRequires: bzip2-devel
@ -120,35 +126,15 @@ Requires: %{name} = %{version}-%{release}
The Python package includes several development tools that are used
to build python programs.
%package pip
Summary: The PyPA recommended tool for installing Python packages.
Group: Development/Tools
BuildArch: noarch
Requires: %{name} = %{version}-%{release}
Requires: %{name}-xml = %{version}-%{release}
%description pip
The PyPA recommended tool for installing Python packages.
%package setuptools
Summary: Download, build, install, upgrade, and uninstall Python packages.
Group: Development/Tools
BuildArch: noarch
Requires: %{name} = %{version}-%{release}
Requires: %{name}-xml = %{version}-%{release}
Provides: python%{VER}dist(setuptools)
%description setuptools
setuptools is a collection of enhancements to the Python distutils that allow you to more easily build and distribute Python packages, especially ones that have dependencies on other packages.
%package test
Summary: Regression tests package for Python.
Group: Development/Tools
Requires: %{name} = %{version}-%{release}
%description test
The test package contains all regression tests for Python as well as the modules test.support and test.regrtest. test.support is used to enhance your tests while test.regrtest drives the testing suite.
The test package contains all regression tests for Python as well as the
modules test.support and test.regrtest.
test.support is used to enhance your tests while test.regrtest drives the testing suite.
%package macros
Summary: Macros for Python packages.
@ -162,7 +148,7 @@ You should not need to install this package manually as the various
python-devel packages require it. So install a python-devel package instead.
%prep
%autosetup -p1 -n Python-%{version}
%autosetup -p1 -n Python-%{version} -a2
%build
export OPT="${CFLAGS}"
@ -173,6 +159,15 @@ if [ %{_host} != %{_build} ]; then
export ac_cv_file__dev_ptc=no
fi
rm -vf Lib/ensurepip/_bundled/pip*.whl \
Lib/ensurepip/_bundled/setuptools*.whl
pushd setuptools-pip-wheels/%{_arch}
cp pip*.whl \
setuptools*.whl \
../../Lib/ensurepip/_bundled/
popd
%configure \
--enable-shared \
--with-system-expat \
@ -208,13 +203,11 @@ cp -p Tools/scripts/pathfix.py %{buildroot}%{_bindir}/pathfix.py
%endif
%endif
%if 0%{?with_check}
%check
make %{?_smp_mflags} test
%endif
%make_build test
%post
ln -sfv %{_bindir}/%{name} %{_bindir}/python
ln -sfrv %{_bindir}/%{name} %{_bindir}/python
/sbin/ldconfig
%postun
@ -223,7 +216,7 @@ ln -sfv %{_bindir}/%{name} %{_bindir}/python
#as python will still be linked to python3
if [ $1 -eq 0 ] ; then
if [ -f "%{_bindir}/python2" ]; then
ln -sfv %{_bindir}/python2 %{_bindir}/python
ln -sfrv %{_bindir}/python2 %{_bindir}/python
else
rm -f %{_bindir}/python
fi
@ -245,6 +238,8 @@ rm -rf %{buildroot}/*
%{_libdir}/libpython3.so
%{_libdir}/libpython%{VER}.so.1.0
%exclude %{_bindir}/pip3
%exclude %{_bindir}/pip%{VER}
%exclude %{_libdir}/python%{VER}/ctypes/test
%exclude %{_libdir}/python%{VER}/distutils/tests
%exclude %{_libdir}/python%{VER}/idlelib/idle_test
@ -297,21 +292,6 @@ rm -rf %{buildroot}/*
%{_bindir}/2to3-%{VER}
%exclude %{_bindir}/idle*
%files pip
%defattr(-, root, root, 755)
%{_libdir}/python%{VER}/site-packages/pip/*
%{_bindir}/pip*
%exclude %{_libdir}/python%{VER}/site-packages/pip/_vendor/distlib/*.exe
%files setuptools
%defattr(-, root, root, 755)
%{_libdir}/python%{VER}/site-packages/distutils-precedence.pth
%{_libdir}/python%{VER}/site-packages/_distutils_hack/*
%{_libdir}/python%{VER}/site-packages/pkg_resources/*
%{_libdir}/python%{VER}/site-packages/setuptools/*
%{_libdir}/python%{VER}/site-packages/setuptools-*.dist-info/*
%exclude %{_libdir}/python%{VER}/site-packages/setuptools/*.exe
%files test
%defattr(-, root, root, 755)
%{_libdir}/python%{VER}/test/*
@ -321,6 +301,9 @@ rm -rf %{buildroot}/*
%{_rpmmacrodir}/macros.python
%changelog
* Wed Feb 28 2024 Shreenidhi Shedi <shreenidhi.shedi@broadcom.com> 3.11.7-2
- Seperate pip & setuptools
- Use pip & setuptools whl from system
* Mon Dec 11 2023 Prashant S Chauhan <psinghchauha@vmware.com> 3.11.7-1
- Update to 3.11.7
* Sun Nov 19 2023 Shreenidhi Shedi <sshedi@vmware.com> 3.11.0-9

View File

@ -113,4 +113,5 @@ noarch/autoconf-2.71-2.ph5.noarch.rpm
noarch/automake-1.16.5-1.ph5.noarch.rpm
noarch/linux-api-headers-6.0.7-1.ph5.noarch.rpm
noarch/man-pages-5.13-1.ph5.noarch.rpm
noarch/python3-wheel-0.37.1-2.ph5.noarch.rpm
noarch/systemd-rpm-macros-252.4-8.ph5.noarch.rpm

View File

@ -2,6 +2,7 @@ noarch/autoconf-2.71-2.ph5.noarch.rpm
noarch/automake-1.16.5-1.ph5.noarch.rpm
noarch/linux-api-headers-6.0.7-1.ph5.noarch.rpm
noarch/man-pages-5.13-1.ph5.noarch.rpm
noarch/python3-wheel-0.37.1-2.ph5.noarch.rpm
noarch/systemd-rpm-macros-252.4-8.ph5.noarch.rpm
x86_64/apache-maven-3.8.6-2.ph5.x86_64.rpm
x86_64/attr-2.5.1-2.ph5.x86_64.rpm