Skip to content

Commit

Permalink
Fedora packaging (#56)
Browse files Browse the repository at this point in the history
* Remove `ref-names`

* Initial Fedora packaging

* Add pure CMake tests

* Split the rpm package

* Add rpmlint exceptions

* Disable epel-10 packaging for now
  • Loading branch information
LecrisUT authored Oct 25, 2024
1 parent 894d3c5 commit a98c7c9
Show file tree
Hide file tree
Showing 16 changed files with 228 additions and 1 deletion.
1 change: 1 addition & 0 deletions .distro/.fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
3 changes: 3 additions & 0 deletions .distro/cython-cmake.rpmlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
addFilter("E: devel-dependency python3-devel")
addFilter("dangling-relative-symlink .*/FindCython\.cmake")
addFilter("dangling-relative-symlink .*/UseCython\.cmake")
75 changes: 75 additions & 0 deletions .distro/cython-cmake.spec
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions .distro/plans/cmake.fmf
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions .distro/plans/main.fmf
Original file line number Diff line number Diff line change
@@ -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-*/
10 changes: 10 additions & 0 deletions .distro/plans/rpmlint.fmf
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions .distro/plans/smoke.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
summary: Basic smoke tests
discover+:
filter: "tag: smoke"
execute:
how: tmt
1 change: 1 addition & 0 deletions .fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
1 change: 0 additions & 1 deletion .git_archival.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,8 @@ Thumbs.db
# Common editor files
*~
*.swp

# Fedora packaging
*.rpm
*.tar.gz
!.distro/*.spec
57 changes: 57 additions & 0 deletions .packit.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions tests/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
path: /
test: ./tests/test_pure_cmake.sh
framework: beakerlib
tag: [ cmake ]
1 change: 1 addition & 0 deletions tests/packages/multiple_packages/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
summary: Multiple packages
1 change: 1 addition & 0 deletions tests/packages/simple/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
summary: Simplest project
19 changes: 19 additions & 0 deletions tests/smoke.fmf
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions tests/test_pure_cmake.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a98c7c9

Please sign in to comment.