Skip to content

Commit

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

Signed-off-by: Cristian Le <[email protected]>

* Initial Fedora packaging

Signed-off-by: Cristian Le <[email protected]>

* Add pure CMake tests

Signed-off-by: Cristian Le <[email protected]>

* Split the rpm package

Signed-off-by: Cristian Le <[email protected]>

* Add rpmlint exceptions

Signed-off-by: Cristian Le <[email protected]>

* Disable epel-10 packaging for now

Signed-off-by: Cristian Le <[email protected]>

---------

Signed-off-by: Cristian Le <[email protected]>
  • Loading branch information
LecrisUT authored Nov 11, 2024
1 parent f41e5ec commit 666d28c
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
2 changes: 2 additions & 0 deletions .distro/f2py-cmake.rpmlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
addFilter("E: devel-dependency python3-devel")
addFilter("dangling-relative-symlink .*/UseF2Py\.cmake")
74 changes: 74 additions & 0 deletions .distro/f2py-cmake.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Name: f2py-cmake
Version: 0.0.0
Release: %autorelease
Summary: F2Py helpers for CMake

License: Apache-2.0
URL: https://github.com/scikit-build/f2py-cmake
Source: %{pypi_source f2py_cmake}
BuildArch: noarch

BuildRequires: python3-devel
BuildRequires: python3-numpy-f2py
# Testing dependences
BuildRequires: cmake
BuildRequires: gfortran
Requires: cmake
Requires: python3-devel
Requires: python3-numpy-f2py

%global _description %{expand:
This provides helpers for using F2Py. Use:

include(UseF2Py)
}

%description %_description

CMake module files.

%package -n python3-f2py-cmake
Summary: %{summary}
Requires: f2py-cmake = %{version}-%{release}
%description -n python3-f2py-cmake %_description

Python package.


%prep
%autosetup -n f2py_cmake-%{version}


%generate_buildrequires
%pyproject_buildrequires -x test


%build
%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files -l f2py_cmake
# Move the actual CMake modules to /usr/share/cmake
mkdir -p %{buildroot}%{_datadir}/cmake/Modules
mv %{buildroot}%{python3_sitelib}/f2py_cmake/cmake/*.cmake %{buildroot}%{_datadir}/cmake/Modules/
ln -rs %{buildroot}%{_datadir}/cmake/Modules/*.cmake %{buildroot}%{python3_sitelib}/f2py_cmake/cmake/


%check
%pyproject_check_import
%pytest


%files
%{_datadir}/cmake/Modules/*.cmake
%license LICENSE
%doc README.md

%files -n python3-f2py-cmake -f %{pyproject_files}
%{_bindir}/f2py-cmake


%changelog
%autochangelog
11 changes: 11 additions & 0 deletions .distro/plans/cmake.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
summary: Test CMake only modules
discover+:
how: fmf
filter: "tag: cmake"
prepare:
- name: Install additional test packages
how: install
package:
- gfortran
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: f2py_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
Empty file added .distro/tests/smoke.fmf
Empty file.
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: f2py-cmake
specfile_path: .distro/f2py-cmake.spec
downstream_package_name: f2py-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/f77/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
summary: Minimal f77 example
23 changes: 23 additions & 0 deletions tests/smoke.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/:
inherit: false

tag: [ smoke ]
tier: 0
path: /

/python-version:
test: |
python3 -c "import f2py_cmake; print(f2py_cmake.__version__)"

/cmake-modules:
test: |
cat <<-EOF > test_modules.cmake
find_package(Python REQUIRED COMPONENTS NumPy)
include(UseF2Py RESULT_VARIABLE UseF2Py_PATH)
message("UseF2Py_PATH=\${UseF2Py_PATH}")
EOF
cmake -P test_modules.cmake
adjust:
enabled: false
because: |
Cannot test inside script-mode because targets are not propagated
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 666d28c

Please sign in to comment.