From f7b1f195153f84b403d7a6642bc529105fd927d3 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Thu, 30 Jun 2022 09:12:23 -0400 Subject: [PATCH] Fix test compatibility with setuptools_scm 7 --- 9.patch | 50 +++++++++++++++++++++++++++++++++++++++++++ python-hatch-vcs.spec | 12 ++++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 9.patch diff --git a/9.patch b/9.patch new file mode 100644 index 0000000..1fe6341 --- /dev/null +++ b/9.patch @@ -0,0 +1,50 @@ +From 22af1c13f637587c0182b3363e98d15f7e150eb7 Mon Sep 17 00:00:00 2001 +From: Lumir Balhar +Date: Thu, 30 Jun 2022 14:05:02 +0200 +Subject: [PATCH] Fix test compatibility with setuptools_scm 7 + +--- + hatch.toml | 1 + + tests/test_build.py | 8 +++++++- + 2 files changed, 8 insertions(+), 1 deletion(-) + +diff --git a/hatch.toml b/hatch.toml +index 269801a..22c9f86 100644 +--- a/hatch.toml ++++ b/hatch.toml +@@ -1,5 +1,6 @@ + [envs.default] + dependencies = [ ++ "importlib-metadata", + "pytest", + "pytest-cov", + ] +diff --git a/tests/test_build.py b/tests/test_build.py +index 2d719a9..a4f88fd 100644 +--- a/tests/test_build.py ++++ b/tests/test_build.py +@@ -6,9 +6,12 @@ + import zipfile + + import pytest ++from importlib_metadata import version + + from .utils import build_project, read_file + ++setuptools_scm_major = int(version("setuptools_scm").split(".")[0]) ++ + + def test_basic(new_project_basic): + build_project('-t', 'wheel') +@@ -75,7 +78,10 @@ def test_write(new_project_write): + assert os.path.isfile(version_file) + + lines = read_file(version_file).splitlines() +- assert lines[3] == "version = '1.2.3'" ++ if setuptools_scm_major < 7: ++ assert lines[3] == "version = '1.2.3'" ++ else: ++ assert lines[3] == "__version__ = version = '1.2.3'" + + + @pytest.mark.skipif(sys.version_info[0] == 2, reason='Depends on fix in 6.4.0 which is Python 3-only') diff --git a/python-hatch-vcs.spec b/python-hatch-vcs.spec index 2716c2f..a1f114b 100644 --- a/python-hatch-vcs.spec +++ b/python-hatch-vcs.spec @@ -18,12 +18,22 @@ Source0: %{pypi_source hatch_vcs} BuildArch: noarch +# Fix test compatibility with setuptools_scm 7 +# https://github.com/ofek/hatch-vcs/pull/9 +# +# Fixes: +# +# Compatibility with setuptools_scm 7 +# https://github.com/ofek/hatch-vcs/issues/8 +Patch: %{url}/pull/9.patch + BuildRequires: python3-devel # RHBZ#1985340, RHBZ#2076994 BuildRequires: pyproject-rpm-macros >= 1.2.0 %if %{with tests} BuildRequires: python3dist(pytest) +BuildRequires: python3dist(importlib-metadata) BuildRequires: git-core %endif @@ -43,7 +53,7 @@ Summary: %{summary} %prep -%autosetup -n hatch_vcs-%{version} +%autosetup -n hatch_vcs-%{version} -p1 %generate_buildrequires