Repository: scikit-build/scikit-build-core
Pull request #400 (2023-06-22 14:44:44)

packaging: Enable more tests in the spec file

LecrisUT: Interesting, I've enabled `git` tests and they seem to be failing in copr :thinking: 
henryiii: The version of hatch-get-fancy-readme is too old. 22.5 added substitutions, so that's probably when `config.substitutions` was added too. 22.3 is the one being used.
henryiii: If you want to support the older version too, this line:

https://github.com/scikit-build/scikit-build-core/blob/2a127fee78ef288c15b1f8ac7e0c8a0e7631bc8e/src/scikit_build_core/metadata/fancy_pypi_readme.py#L39

Would change to just a single arg (config.fragments) if using the older plugin. We should also set a minimum in our dependencies based on what we go with.
LecrisUT: Thanks, I think the best solution for this is to make a conditional patch based on the package version j
LecrisUT: /packit test. Those are some weird test failures on packit side. I'll get someone to look into it tomorrow
LecrisUT: I've checked the errors and it seems the important tests in testing-farm are passing. The linting error seems to be a bug. I've forwarded this upstream

Patch:
diff --git a/distro/plans/rpmlint.fmf b/distro/plans/rpmlint.fmf
index 6711ddd..4417c6a 100644
--- a/distro/plans/rpmlint.fmf
+++ b/distro/plans/rpmlint.fmf
@@ -12,7 +12,7 @@ prepare:
   #  script: cd /tmp && curl -O ${PACKIT_SRPM_URL}
   - name: Download rpm packages
     how: shell
-    script: cd /tmp && dnf download ${PACKIT_COPR_RPMS}
+    script: dnf download ${PACKIT_COPR_RPMS} --destdir=$TMT_PLAN_DATA
 discover+:
   how: fmf
   filter: "tag: rpmlint"
diff --git a/distro/python-scikit-build-core.spec b/distro/python-scikit-build-core.spec
index 66ec30a..8ada7f0 100644
--- a/distro/python-scikit-build-core.spec
+++ b/distro/python-scikit-build-core.spec
@@ -9,10 +9,12 @@ Source:         %{pypi_source scikit_build_core}
 
 BuildArch:      noarch
 BuildRequires:  python3-devel
+# Testing dependences
 BuildRequires:  cmake
 BuildRequires:  ninja-build
 BuildRequires:  gcc
 BuildRequires:  gcc-c++
+BuildRequires:  git
 
 %global _description %{expand:
 A next generation Python CMake adaptor and Python API for plugins
@@ -36,7 +38,7 @@ Suggests:       gcc
 
 
 %generate_buildrequires
-%pyproject_buildrequires -x test
+%pyproject_buildrequires -x test,test-meta,test-numpy
 
 
 %build
diff --git a/pyproject.toml b/pyproject.toml
index c1b5f45..ed07fd8 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -62,7 +62,7 @@ test = [
     "wheel",
 ]
 test-meta = [
-    "hatch-fancy-pypi-readme",
+    "hatch-fancy-pypi-readme>=22.3",
     "setuptools-scm",
 ]
 test-numpy = [
diff --git a/src/scikit_build_core/metadata/fancy_pypi_readme.py b/src/scikit_build_core/metadata/fancy_pypi_readme.py
index 7b2953b..1040ee9 100644
--- a/src/scikit_build_core/metadata/fancy_pypi_readme.py
+++ b/src/scikit_build_core/metadata/fancy_pypi_readme.py
@@ -33,10 +33,14 @@ def dynamic_metadata(
         pyproject_dict["tool"]["hatch"]["metadata"]["hooks"]["fancy-pypi-readme"]
     )
 
+    # Version 22.3 does not have fragment support
     return {
         "readme": {
             "content-type": config.content_type,
-            "text": build_text(config.fragments, config.substitutions),
+            "text": build_text(config.fragments, config.substitutions)
+            if hasattr(config, "substitutions")
+            # pylint: disable-next=no-value-for-parameter
+            else build_text(config.fragments),  # type: ignore[call-arg]
         }
     }
 
@@ -44,4 +48,4 @@ def dynamic_metadata(
 def get_requires_for_dynamic_metadata(
     _settings: dict[str, object] | None = None,
 ) -> list[str]:
-    return ["hatch-fancy-pypi-readme"]
+    return ["hatch-fancy-pypi-readme>=22.3"]


Test patch:
diff --git a/distro/tests/rpmlint.fmf b/distro/tests/rpmlint.fmf
index 126cdf0..dc29837 100644
--- a/distro/tests/rpmlint.fmf
+++ b/distro/tests/rpmlint.fmf
@@ -7,7 +7,7 @@ path: /distro
 # Define tests
 /rpmlint:
   summary: Rpmlint spec and rpmfiles
-  test: rpmlint -c packit.toml -r python-scikit-build-core.rpmlintrc ./*.spec /tmp/*.rpm
+  test: rpmlint -c packit.toml -r python-scikit-build-core.rpmlintrc ./*.spec $TMT_PLAN_DATA/*.rpm
 /rpminspect-rpms:
   summary: Rpminspect the rpms
-  test: ls /tmp/*.rpm | xargs -L1 rpminspect-fedora -E metadata,disttag
+  test: ls $TMT_PLAN_DATA/*.rpm | xargs -L1 rpminspect-fedora -E metadata,disttag
diff --git a/tests/test_dynamic_metadata.py b/tests/test_dynamic_metadata.py
index 06c270f..9663aa8 100644
--- a/tests/test_dynamic_metadata.py
+++ b/tests/test_dynamic_metadata.py
@@ -143,7 +143,7 @@ def test_plugin_metadata():
     )
 
     assert set(GetRequires().dynamic_metadata()) == {
-        "hatch-fancy-pypi-readme",
+        "hatch-fancy-pypi-readme>=22.3",
         "setuptools-scm",
     }