Accepting request 1094318 from home:bnavigator:branches:devel:languages:python

- Add hatch-pr828-pth-tests.patch, gh#pypa/hatch#828 fixing
  test failure with hatchling >= 1.17.1

OBS-URL: https://build.opensuse.org/request/show/1094318
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-hatch?expand=0&rev=20
This commit is contained in:
Markéta Machová 2023-06-21 17:27:58 +00:00 committed by Git OBS Bridge
parent dc112c19ff
commit c5cf20c607
3 changed files with 121 additions and 0 deletions

111
hatch-pr828-pth-tests.patch Normal file
View File

@ -0,0 +1,111 @@
From d07463ea6afcecd83fd55bdac975516de6f3bc10 Mon Sep 17 00:00:00 2001
From: Ryan Morshead <ryan.morshead@gmail.com>
Date: Mon, 17 Apr 2023 22:02:59 -0700
Subject: [PATCH 1/3] Name .pth file so it loads first
Users adding their own .pth files likely need to be loaded after the one inserted by hatchling. The only way to do this is by naming it so the hatchling .pth file comes first alphabetically.
---
backend/src/hatchling/builders/wheel.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: hatch-hatch-v1.7.0/backend/src/hatchling/builders/wheel.py
===================================================================
--- hatch-hatch-v1.7.0.orig/backend/src/hatchling/builders/wheel.py
+++ hatch-hatch-v1.7.0/backend/src/hatchling/builders/wheel.py
@@ -438,6 +438,9 @@ class WheelBuilder(BuilderInterface):
editable_project.add_to_path(os.path.dirname(relative_path))
for filename, content in sorted(editable_project.files()):
+ if filename.endswith('.pth') and not filename.startswith('_'):
+ filename = f'_{filename}'
+
record = archive.write_file(filename, content)
records.write(record)
@@ -475,7 +478,7 @@ class WheelBuilder(BuilderInterface):
for relative_directory in self.config.dev_mode_dirs
)
- record = archive.write_file(f"{self.metadata.core.name.replace('-', '_')}.pth", '\n'.join(directories))
+ record = archive.write_file(f"_{self.metadata.core.name.replace('-', '_')}.pth", '\n'.join(directories))
records.write(record)
for included_file in self.recurse_forced_files(self.get_forced_inclusion_map(build_data)):
Index: hatch-hatch-v1.7.0/tests/helpers/templates/wheel/standard_editable_exact.py
===================================================================
--- hatch-hatch-v1.7.0.orig/tests/helpers/templates/wheel/standard_editable_exact.py
+++ hatch-hatch-v1.7.0/tests/helpers/templates/wheel/standard_editable_exact.py
@@ -16,7 +16,7 @@ def get_files(**kwargs):
if str(f.path) == 'LICENSE.txt':
files.append(File(Path(metadata_directory, 'licenses', f.path), f.contents))
- pth_file_name = f"{kwargs['package_name']}.pth"
+ pth_file_name = f"_{kwargs['package_name']}.pth"
loader_file_name = f"_editable_impl_{kwargs['package_name']}.py"
files.append(File(Path(pth_file_name), f"import _editable_impl_{kwargs['package_name']}"))
files.append(
Index: hatch-hatch-v1.7.0/tests/helpers/templates/wheel/standard_editable_exact_extra_dependencies.py
===================================================================
--- hatch-hatch-v1.7.0.orig/tests/helpers/templates/wheel/standard_editable_exact_extra_dependencies.py
+++ hatch-hatch-v1.7.0/tests/helpers/templates/wheel/standard_editable_exact_extra_dependencies.py
@@ -16,7 +16,7 @@ def get_files(**kwargs):
if str(f.path) == 'LICENSE.txt':
files.append(File(Path(metadata_directory, 'licenses', f.path), f.contents))
- pth_file_name = f"{kwargs['package_name']}.pth"
+ pth_file_name = f"_{kwargs['package_name']}.pth"
loader_file_name = f"_editable_impl_{kwargs['package_name']}.py"
files.append(File(Path(pth_file_name), f"import _editable_impl_{kwargs['package_name']}"))
files.append(
Index: hatch-hatch-v1.7.0/tests/helpers/templates/wheel/standard_editable_exact_force_include.py
===================================================================
--- hatch-hatch-v1.7.0.orig/tests/helpers/templates/wheel/standard_editable_exact_force_include.py
+++ hatch-hatch-v1.7.0/tests/helpers/templates/wheel/standard_editable_exact_force_include.py
@@ -18,7 +18,7 @@ def get_files(**kwargs):
elif f.path.parts[-1] == '__about__.py':
files.append(File(Path('zfoo.py'), f.contents))
- pth_file_name = f"{kwargs['package_name']}.pth"
+ pth_file_name = f"_{kwargs['package_name']}.pth"
loader_file_name = f"_editable_impl_{kwargs['package_name']}.py"
files.append(File(Path(pth_file_name), f"import _editable_impl_{kwargs['package_name']}"))
files.append(
Index: hatch-hatch-v1.7.0/tests/helpers/templates/wheel/standard_editable_pth.py
===================================================================
--- hatch-hatch-v1.7.0.orig/tests/helpers/templates/wheel/standard_editable_pth.py
+++ hatch-hatch-v1.7.0/tests/helpers/templates/wheel/standard_editable_pth.py
@@ -16,7 +16,7 @@ def get_files(**kwargs):
if str(f.path) == 'LICENSE.txt':
files.append(File(Path(metadata_directory, 'licenses', f.path), f.contents))
- pth_file_name = f"{kwargs['package_name']}.pth"
+ pth_file_name = f"_{kwargs['package_name']}.pth"
files.append(File(Path(pth_file_name), '\n'.join(package_paths)))
files.append(
File(
Index: hatch-hatch-v1.7.0/tests/helpers/templates/wheel/standard_editable_pth_extra_dependencies.py
===================================================================
--- hatch-hatch-v1.7.0.orig/tests/helpers/templates/wheel/standard_editable_pth_extra_dependencies.py
+++ hatch-hatch-v1.7.0/tests/helpers/templates/wheel/standard_editable_pth_extra_dependencies.py
@@ -16,7 +16,7 @@ def get_files(**kwargs):
if str(f.path) == 'LICENSE.txt':
files.append(File(Path(metadata_directory, 'licenses', f.path), f.contents))
- pth_file_name = f"{kwargs['package_name']}.pth"
+ pth_file_name = f"_{kwargs['package_name']}.pth"
files.append(File(Path(pth_file_name), '\n'.join(package_paths)))
files.append(
File(
Index: hatch-hatch-v1.7.0/tests/helpers/templates/wheel/standard_editable_pth_force_include.py
===================================================================
--- hatch-hatch-v1.7.0.orig/tests/helpers/templates/wheel/standard_editable_pth_force_include.py
+++ hatch-hatch-v1.7.0/tests/helpers/templates/wheel/standard_editable_pth_force_include.py
@@ -18,7 +18,7 @@ def get_files(**kwargs):
elif f.path.parts[-1] == '__about__.py':
files.append(File(Path('zfoo.py'), f.contents))
- pth_file_name = f"{kwargs['package_name']}.pth"
+ pth_file_name = f"_{kwargs['package_name']}.pth"
files.append(File(Path(pth_file_name), '\n'.join(package_paths)))
files.append(
File(

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Jun 21 08:39:40 UTC 2023 - Ben Greiner <code@bnavigator.de>
- Add hatch-pr828-pth-tests.patch, gh#pypa/hatch#828 fixing
test failure with hatchling >= 1.17.1
-------------------------------------------------------------------
Sun Jun 11 08:38:31 UTC 2023 - ecsos <ecsos@opensuse.org>

View File

@ -35,6 +35,8 @@ URL: https://hatch.pypa.io/latest/
Source: https://github.com/pypa/hatch/archive/refs/tags/hatch-v%{version}.tar.gz
# PATCH-FIX-UPSTREAM fix-sdist-target.patch -- gh#pypa/hatch@1b10663e645e
Patch0: fix-sdist-target.patch
# PATCH-FIX-UPSTREAM hatch-pr828-pth-tests.patch, gh#pypa/hatch#828
Patch1: hatch-pr828-pth-tests.patch
BuildRequires: %{python_module base >= 3.7}
BuildRequires: %{python_module hatchling >= 1.14}
BuildRequires: %{python_module pip}
@ -48,6 +50,8 @@ Requires: git-core
%if %{with test}
BuildRequires: %{python_module filelock >= 3.7.1}
BuildRequires: %{python_module hatch = %{version}}
# Due to Patch1, gh#pypa/hatch#828
BuildRequires: %{python_module hatchling >= 1.17.1}
BuildRequires: %{python_module pytest-mock}
BuildRequires: %{python_module pytest-randomly}
BuildRequires: %{python_module pytest-rerunfailures}