Repository: scikit-build/cython-cmake (language: python)

Issue:
Fedora packaging
Let me know when I should start packaging this project.


Discussion / hints:
Probably after #32 is in and we make a release?
v0.2.0 is out.
Are the `UseCython.cmake` files effectively vendored or would they be forked? If the latter could you change the copyright notice for it to reflect that?
If someone uses this package, they would use the files from the package. If they prefer, they can vendor the files, which means they don't need to get this package from Fedora. What change were you thinking of?
I was thinking about the more general case:
https://github.com/scikit-build/cython-cmake/blob/ec03867a41ded0a91d1b22e51f659a480d9a3da8/src/cython_cmake/cmake/UseCython.cmake#L58

If the file is being maintained externally than I would need to add a `Bundles` to show that, otherwise it would be fine as-is
I think that date was inherited. @jcfr?
Was thinking you could just add
```
# Copyright 202x Scikit-build developers
```
Or equivalent, marking when it got forked from kitware's
I don't think it's a good idea to assign copyright to something that's not a legal entity. A person works, or a company, but "... developers" is too fuzzy and unclear. That's what I remember from a discussion with a lawyer a long time ago, I might be misremembering it though.
I remember there being some discussion on Fedora mail list[^1] about jaraco removing copyright notice[^2]. I need to read through the mail list more carefully, but afaiu it is ok if the authorship is self contained. There is also [this article](https://www.linuxfoundation.org/blog/blog/copyright-notices-in-open-source-software-projects) which many people resonate with, but of course inal.

[^1]: https://lists.fedoraproject.org/archives/list/legal@lists.fedoraproject.org/thread/FOS55EPT4MEJXIY3CHWM26X5ACG66TQU/
[^2]: https://github.com/jaraco/skeleton/issues/78

Fix patch:
diff --git a/.distro/.fmf/version b/.distro/.fmf/version
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/.distro/.fmf/version
@@ -0,0 +1,1 @@
+1
diff --git a/.distro/cython-cmake.rpmlintrc b/.distro/cython-cmake.rpmlintrc
new file mode 100644
index 0000000..7019023
--- /dev/null
+++ b/.distro/cython-cmake.rpmlintrc
@@ -0,0 +1,3 @@
+addFilter("E: devel-dependency python3-devel")
+addFilter("dangling-relative-symlink .*/FindCython\.cmake")
+addFilter("dangling-relative-symlink .*/UseCython\.cmake")
diff --git a/.distro/cython-cmake.spec b/.distro/cython-cmake.spec
new file mode 100644
index 0000000..30389ef
--- /dev/null
+++ b/.distro/cython-cmake.spec
@@ -0,0 +1,75 @@
+Name:           cython-cmake
+Version:        0.0.0
+Release:        %autorelease
+Summary:        CMake helpers for building Cython modules
+
+License:        Apache-2.0
+URL:            https://github.com/scikit-build/cython-cmake
+Source:         %{pypi_source cython_cmake}
+BuildArch:      noarch
+
+BuildRequires:  python3-devel
+# Testing dependences
+BuildRequires:  cmake
+BuildRequires:  gcc
+BuildRequires:  g++
+Requires:       cmake
+Requires:       python3-devel
+Requires:       python3dist(cython)
+
+%global _description %{expand:
+This provides helpers for using Cython. Use:
+
+find_package(Cython MODULE REQUIRED VERSION 3.0)
+include(UseCython)
+}
+
+%description %_description
+
+CMake module files.
+
+%package -n python3-cython-cmake
+Summary:        %{summary}
+Requires:       cython-cmake = %{version}-%{release}
+%description -n python3-cython-cmake %_description
+
+Python package.
+
+
+%prep
+%autosetup -n cython_cmake-%{version}
+
+
+%generate_buildrequires
+%pyproject_buildrequires -x test
+
+
+%build
+%pyproject_wheel
+
+
+%install
+%pyproject_install
+%pyproject_save_files -l cython_cmake
+# Move the actual CMake modules to /usr/share/cmake
+mkdir -p %{buildroot}%{_datadir}/cmake/Modules
+mv %{buildroot}%{python3_sitelib}/cython_cmake/cmake/*.cmake %{buildroot}%{_datadir}/cmake/Modules/
+ln -rs %{buildroot}%{_datadir}/cmake/Modules/*.cmake %{buildroot}%{python3_sitelib}/cython_cmake/cmake/
+
+
+%check
+%pyproject_check_import
+%pytest
+
+
+%files
+%{_datadir}/cmake/Modules/*.cmake
+%license LICENSE
+%doc README.md
+
+%files -n python3-cython-cmake -f %{pyproject_files}
+%{_bindir}/cython-cmake
+
+
+%changelog
+%autochangelog
diff --git a/.distro/plans/cmake.fmf b/.distro/plans/cmake.fmf
new file mode 100644
index 0000000..4dafc56
--- /dev/null
+++ b/.distro/plans/cmake.fmf
@@ -0,0 +1,12 @@
+summary: Test CMake only modules
+discover+:
+  how: fmf
+  filter: "tag: cmake"
+prepare:
+  - name: Install additional test packages
+    how: install
+    package:
+      - gcc
+      - g++
+execute:
+  how: tmt
diff --git a/.distro/plans/main.fmf b/.distro/plans/main.fmf
new file mode 100644
index 0000000..165b0fa
--- /dev/null
+++ b/.distro/plans/main.fmf
@@ -0,0 +1,11 @@
+discover:
+  how: fmf
+  path: .
+
+adjust+:
+  # Cannot use initiator: fedora-ci reliably yet
+  when: initiator is not defined or initiator != packit
+  discover+:
+    how: fmf
+    dist-git-source: true
+    dist-git-extract: cython_cmake-*/
diff --git a/.distro/plans/rpmlint.fmf b/.distro/plans/rpmlint.fmf
new file mode 100644
index 0000000..1d28ff9
--- /dev/null
+++ b/.distro/plans/rpmlint.fmf
@@ -0,0 +1,10 @@
+prepare:
+  - how: shell
+    script: cp ./*.rpmlintrc $TMT_PLAN_DATA/
+discover:
+  how: fmf
+  filter: "tag: rpmlint"
+  url: https://github.com/packit/tmt-plans
+  ref: main
+execute:
+  how: tmt
diff --git a/.distro/plans/smoke.fmf b/.distro/plans/smoke.fmf
new file mode 100644
index 0000000..f545373
--- /dev/null
+++ b/.distro/plans/smoke.fmf
@@ -0,0 +1,5 @@
+summary: Basic smoke tests
+discover+:
+  filter: "tag: smoke"
+execute:
+    how: tmt
diff --git a/.fmf/version b/.fmf/version
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/.fmf/version
@@ -0,0 +1,1 @@
+1
diff --git a/.git_archival.txt b/.git_archival.txt
index 8fb235d..7c51009 100644
--- a/.git_archival.txt
+++ b/.git_archival.txt
@@ -1,4 +1,3 @@
 node: $Format:%H$
 node-date: $Format:%cI$
 describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
-ref-names: $Format:%D$
diff --git a/.gitignore b/.gitignore
index 25cf9a4..f41e0f9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -156,3 +156,8 @@ Thumbs.db
 # Common editor files
 *~
 *.swp
+
+# Fedora packaging
+*.rpm
+*.tar.gz
+!.distro/*.spec
diff --git a/.packit.yaml b/.packit.yaml
new file mode 100644
index 0000000..c847c67
--- /dev/null
+++ b/.packit.yaml
@@ -0,0 +1,57 @@
+files_to_sync:
+  - src: .distro/
+    dest: ./
+    delete: true
+    filters:
+      - "protect .git*"
+      - "protect sources"
+      - "protect changelog"
+      - "- plans/rpmlint.fmf"
+  - .packit.yaml
+
+upstream_package_name: cython-cmake
+specfile_path: .distro/cython-cmake.spec
+downstream_package_name: cython-cmake
+upstream_tag_template: v{version}
+
+targets: &targets
+  - fedora-all-x86_64
+  - fedora-all-aarch64
+  # TODO: Package for epel-10 once scikit-build-core is packaged there
+#  - epel-10-x86_64
+#  - epel-10-aarch64
+
+jobs:
+  - &copr_build
+    job: copr_build
+    trigger: pull_request
+  - &tests
+    job: tests
+    trigger: pull_request
+    fmf_path: .distro
+  - <<: *copr_build
+    trigger: release
+    owner: "@scikit-build"
+    project: release
+  - <<: *tests
+    trigger: release
+  - <<: *copr_build
+    trigger: commit
+    branch: main
+    owner: "@scikit-build"
+    project: nightly
+  - <<: *tests
+    trigger: commit
+    branch: main
+  - job: propose_downstream
+    trigger: release
+    dist_git_branches:
+      - fedora-rawhide
+  - job: koji_build
+    trigger: commit
+    dist_git_branches:
+      - fedora-all
+  - job: bodhi_update
+    trigger: commit
+    dist_git_branches:
+      - fedora-branched


Test patch:
diff --git a/tests/main.fmf b/tests/main.fmf
new file mode 100644
index 0000000..1a57587
--- /dev/null
+++ b/tests/main.fmf
@@ -0,0 +1,4 @@
+path: /
+test: ./tests/test_pure_cmake.sh
+framework: beakerlib
+tag: [ cmake ]
diff --git a/tests/packages/multiple_packages/main.fmf b/tests/packages/multiple_packages/main.fmf
new file mode 100644
index 0000000..4d9b5e4
--- /dev/null
+++ b/tests/packages/multiple_packages/main.fmf
@@ -0,0 +1,1 @@
+summary: Multiple packages
diff --git a/tests/packages/simple/main.fmf b/tests/packages/simple/main.fmf
new file mode 100644
index 0000000..f342447
--- /dev/null
+++ b/tests/packages/simple/main.fmf
@@ -0,0 +1,1 @@
+summary: Simplest project
diff --git a/tests/smoke.fmf b/tests/smoke.fmf
new file mode 100644
index 0000000..970dd29
--- /dev/null
+++ b/tests/smoke.fmf
@@ -0,0 +1,19 @@
+/:
+  inherit: false
+
+tag: [ smoke ]
+tier: 0
+path: /
+
+/python-version:
+  test: |
+    python3 -c "import cython_cmake; print(cython_cmake.__version__)"
+
+/cmake-modules:
+  # Cannot test for FindCython because it uses `add_executable`
+  test: |
+    cat <<-EOF > test_modules.cmake
+      include(UseCython RESULT_VARIABLE UseCython_PATH)
+      message("UseCython_PATH=\${UseCython_PATH}")
+    EOF
+    cmake -P test_modules.cmake
diff --git a/tests/test_pure_cmake.sh b/tests/test_pure_cmake.sh
new file mode 100755
index 0000000..c2f0e25
--- /dev/null
+++ b/tests/test_pure_cmake.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# shellcheck disable=all
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+rlJournalStart
+  rlPhaseStartSetup
+    rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
+    rlRun "root=\$(pwd)" 0 "Save the tmt root path"
+    rlRun "pushd $tmp"
+    rlRun "set -o pipefail"
+  rlPhaseEnd
+
+  rlPhaseStartTest
+    rlRun "cmake -S $root$TMT_TEST_NAME -B ./build" 0 "Configure project"
+    rlRun "cmake --build ./build" 0 "Build project"
+  rlPhaseEnd
+
+  rlPhaseStartCleanup
+    rlRun "popd"
+    rlRun "rm -r $tmp" 0 "Remove tmp directory"
+  rlPhaseEnd
+rlJournalEnd