Add some packages to help building python packages.

`python setup.py build|install` approach is deprecated. These packages
provide support for building python packages with suggested methods.

Change-Id: I6bfbbe3d788cebfe981f9ce22027e45273f36452
Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/c/photon/+/24086
Reviewed-by: Alexey Makhalov <amakhalov@vmware.com>
Tested-by: gerrit-photon <photon-checkins@vmware.com>
This commit is contained in:
Shreenidhi Shedi 2024-06-06 13:34:01 +05:30
parent 7d8232ca49
commit ad69b83aab
8 changed files with 351 additions and 1 deletions

View File

@ -0,0 +1,29 @@
From f414cc586b9256cc3c709e428ffab2419038c24b Mon Sep 17 00:00:00 2001
From: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
Date: Thu, 6 Jun 2024 13:03:18 +0530
Subject: [PATCH] Remove coverage and uv from tests
Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
---
pyproject.toml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index 74bf3ff..b217d16 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -50,10 +50,9 @@ docs = [
"sphinx-issues >= 3.0.0",
]
test = [
- "build[uv, virtualenv]",
+ "build[ virtualenv]",
"filelock >= 3",
"pytest >= 6.2.4",
- "pytest-cov >= 2.12",
"pytest-mock >= 2",
"pytest-rerunfailures >= 9.1",
"pytest-xdist >= 1.34",
--
2.34.1

View File

@ -0,0 +1,91 @@
%global srcname build
Name: python3-build
Version: 1.2.1
Release: 1%{?dist}
Summary: A simple, correct PEP517 package builder
License: MIT
URL: https://github.com/pypa/build
Group: Development/Languages/Python
Vendor: VMware, Inc.
Distribution: Photon
Source0: %{url}/archive/%{version}/%{srcname}-%{version}.tar.gz
%define sha512 %{srcname}=77003e16d3776c3a4be920251bf14650eea112b92d94116cb1893195b8e16aae57321206ae63267119247f2794f220c891b7d913e07a8258b313d34c07d54fe9
%if 0%{?with_check}
Patch0: 0001-Remove-coverage-and-uv-from-tests.patch
%endif
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: python3-wheel
BuildRequires: python3-pip
BuildRequires: python3-flit-core
%if 0%{?with_check}
BuildRequires: python3-pytest
BuildRequires: python3-tomli
BuildRequires: python3-pyproject_hooks
BuildRequires: python3-filelock
%endif
Requires: python3
Requires: python3-flit-core
Requires: python3-pyproject_hooks
%description
A simple, correct PEP517 package builder.
%prep
%autosetup -p1 -n %{srcname}-%{version}
%build
%pyproject_wheel
%install
%pyproject_install
%check
pip3 install pytest_mock flaky
# The skipped tests require internet or uv
%pytest -k "not (test_build_package or \
test_build_package_via_sdist or \
test_output[via-sdist-isolation] or \
test_output[wheel-direct-isolation] or \
test_wheel_metadata[True] or \
test_wheel_metadata_isolation or \
test_with_get_requires or \
test_build_sdist or \
test_build_wheel[from_sdist] or \
test_build_wheel[direct] or \
test_uv_impl_install_cmd_well_formed or \
test_venv_creation[uv-venv+uv-None] or \
test_requirement_installation or \
test_requirement_installation or \
test_external_uv_detection_success or \
test_output[False-via-sdist-isolation] or \
test_output[False-wheel-direct-isolation] or \
test_verbose_output or \
test_build_wheel[False-from_sdist] or \
test_build_wheel[False-direct] or \
test_wheel_metadata[False-True] or \
test_venv_creation[pip-virtualenv+pip-True] or \
test_venv_creation[pip-virtualenv+pip-None] or \
test_init[False] or \
test_output[False-via-sdist-no-isolation] or \
test_output[False-wheel-direct-no-isolation] or \
test_output[False-sdist-direct-no-isolation] or \
test_output[False-sdist-and-wheel-direct-no-isolation])"
%files
%defattr(-,root,root)
%license LICENSE
%doc README.md
%{_bindir}/pyproject-build
%{python3_sitelib}/*
%changelog
* Mon Jun 03 2024 Shreenidhi Shedi <shreenidhi.shedi@broadcom.com> 1.2.1-1
- Initial version.

View File

@ -0,0 +1,38 @@
From 28f0a1a5ed9d33567353ec930cf4702c2bc86886 Mon Sep 17 00:00:00 2001
From: Karolina Surma <ksurma@redhat.com>
Date: Thu, 11 Jan 2024 10:33:54 +0100
Subject: [PATCH] Fix removed importlib.resources.read_binary in Python 3.13
---
src/installer/scripts.py | 14 ++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/installer/scripts.py b/src/installer/scripts.py
index 7e3c8fc..a70c59f 100644
--- a/src/installer/scripts.py
+++ b/src/installer/scripts.py
@@ -2,9 +2,19 @@
import io
import shlex
+import sys
import zipfile
-from importlib.resources import read_binary
-from typing import TYPE_CHECKING, Mapping, Optional, Tuple
+from types import ModuleType
+from typing import TYPE_CHECKING, Mapping, Optional, Tuple, Union
+
+if sys.version_info >= (3, 9): # pragma: no cover
+ from importlib.resources import files
+
+ def read_binary(package: Union[str, ModuleType], file_path: str) -> bytes:
+ return (files(package) / file_path).read_bytes()
+
+else: # pragma: no cover
+ from importlib.resources import read_binary
from installer import _scripts
--
2.43.0

View File

@ -0,0 +1,55 @@
Name: python3-installer
Version: 0.7.0
Release: 1%{?dist}
Summary: A library for installing Python wheels
License: MIT
URL: https://github.com/pypa/installer
Group: Development/Languages/Python
Vendor: VMware, Inc.
Distribution: Photon
Source0: https://github.com/pypa/installer/archive/refs/tags/installer-%{version}.tar.gz
%define sha512 installer=e89c2d28ca73d9c4291d645dda675fdcfcaba2e4f8765b9fa4a2f211e27711510f3d171b96a6b024c11808ba7f06b7b560a7cb31fafba815bd5c7396f26789f7
# Fix the build with Python 3.13 - merged upstream
# https://github.com/pypa/installer/commit/b23f89b10cf5
Patch0: Fix-removed-importlib.resources.read_binary-in-Pytho.patch
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: python3-wheel
BuildRequires: python3-pip
BuildRequires: python3-build
%if 0%{?with_check}
BuildRequires: python3-pytest
BuildRequires: python3-tomli
%endif
%description
This is a low-level library for installing a Python package from
a wheel distribution. It provides basic functionality and abstractions
for handling wheels and installing packages from wheels.
%prep
%autosetup -p1 -n installer-%{version}
%build
%pyproject_wheel
%install
%pyproject_install
%check
%pytest
%files
%defattr(-,root,root)
%license LICENSE
%doc CONTRIBUTING.md README.md
%{python3_sitelib}/*
%changelog
* Mon Jun 03 2024 Shreenidhi Shedi <shreenidhi.shedi@broadcom.com> 0.7.0-1
- Initial version.

View File

@ -0,0 +1,23 @@
From 5ff26a4fbc203585e2a8dc812772fb08b9a3d611 Mon Sep 17 00:00:00 2001
From: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
Date: Thu, 6 Jun 2024 13:32:21 +0530
Subject: [PATCH] Remove flake8 from dev requires
Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
---
dev-requirements.txt | 1 -
1 file changed, 1 deletion(-)
diff --git a/dev-requirements.txt b/dev-requirements.txt
index 4a8c47a..3bf90e7 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -1,5 +1,4 @@
pytest
-flake8
testpath
setuptools>=30
tomli >=1.1.0 ; python_version<'3.11'
--
2.34.1

View File

@ -0,0 +1,54 @@
Name: python3-pyproject_hooks
Version: 1.1.0
Release: 1%{?dist}
Summary: Wrappers to call pyproject.toml-based build backend hooks
License: MIT
URL: https://pypi.org/project/pyproject_hooks
Group: Development/Languages/Python
Vendor: VMware, Inc.
Distribution: Photon
Source0: https://github.com/pypa/pyproject-hooks/archive/refs/tags/pyproject_hooks-%{version}.tar.gz
%define sha512 pyproject_hooks=256028d13adbe35126a63431a2a49e0c48adddce5ffc3ff2eebad368eee7ce52591ecfd8a8526876de20bc59dfc87156533d6a97b55538a739873e60f9509eff
Patch0: 0001-Remove-flake8-from-dev-requires.patch
BuildRequires: python3-devel
BuildRequires: python3-wheel
BuildRequires: python3-pip
BuildRequires: python3-flit-core
%if 0%{?with_check}
BuildRequires: python3-pytest
%endif
BuildArch: noarch
%description
This is a low-level library for calling build-backends in
pyproject.toml-based project. It provides the basic functionality
to help write tooling that generates distribution files from
Python projects.
%prep
%autosetup -p1 -n pyproject-hooks-%{version}
%build
%pyproject_wheel
%install
%pyproject_install
%check
pip3 install testpath
%pytest
%files
%defattr(-,root,root)
%doc README.rst
%license LICENSE
%{python3_sitelib}/*
%changelog
* Mon Jun 03 2024 Shreenidhi Shedi <shreenidhi.shedi@broadcom.com> 1.1.0-1
- Initial build.

View File

@ -1,6 +1,6 @@
Name: python3-setuptools-rust
Version: 1.9.0
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Setuptools plugin for Rust support
License: MIT
Group: Development/Languages/Python
@ -27,6 +27,7 @@ BuildRequires: python3-atmoicwrites
Requires: python3
Requires: python3-semantic-version
Requires: python3-tomli
BuildArch: noarch
@ -51,6 +52,8 @@ Compile and distribute Python extensions written in Rust as easily as if they we
%{python3_sitelib}/*
%changelog
* Sun Jun 16 2024 Shreenidhi Shedi <shreenidhi.shedi@broadcom.com> 1.9.0-2
- Add tomli to requires
* Mon Jun 03 2024 Shreenidhi Shedi <shreenidhi.shedi@broadcom.com> 1.9.0-1
- Upgrade to v1.9.0
* Mon Oct 31 2022 Prashant S Chauhan <psinghchauha@vmware.com> 1.5.2-1

View File

@ -0,0 +1,57 @@
%define srcname tomli
Name: python3-tomli
Version: 2.0.1
Release: 1%{?dist}
Summary: A little TOML parser for Python
License: MIT
URL: https://pypi.org/project/tomli
Group: Development/Languages/Python
Vendor: VMware, Inc.
Distribution: Photon
Source0: https://github.com/hukkin/tomli/archive/%{version}/%{srcname}-%{version}.tar.gz
%define sha512 %{srcname}=a467f8d48cdbd7213bd9b6f85fd48ba142ab7c9656c40bb30785e1c4b37a9e29eaed420f183458ad20112baee8413ebbec87755332795c8f02235d1018c3aa5c
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: python3-flit-core
BuildRequires: python3-pip
BuildRequires: python3-wheel
%if 0%{?with_check}
BuildRequires: python3-pytest
%endif
Requires: python3
%description
Tomli is a Python library for parsing TOML.
Tomli is fully compatible with TOML v1.0.0.
%prep
%autosetup -p1 -n %{srcname}-%{version}
%build
%pyproject_wheel
%install
%pyproject_install
%check
%pytest
%clean
rm -rf %{buidlroot}
%files
%defattr(-,root,root)
%doc README.md
%doc CHANGELOG.md
%license LICENSE
%{python3_sitelib}/*
%changelog
* Thu Jun 06 2024 Shreenidhi Shedi <shreenidhi.shedi@broadcom.com> 2.0.1-1
- Initial version. Needed by setuptools-rust.