Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .distro/plans/python.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
summary: Test python integration

prepare:
- how: install
package:
- python3dist(pip)
- gcc-c++
- cmake
- ninja-build
# Defining all python dependencies manually here
- python3dist(scikit-build-core)
- how: shell
script: |
python3 -m venv --system-site-packages $TMT_PLAN_DATA/venv

discover+:
how: fmf
path: .
filter: "tag:python"
execute:
how: tmt
27 changes: 17 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
requires = ["scikit-build-core"]
build-backend = "scikit_build_core.build"

[project]
name = "CMake-Template-dev"
version = "0.0.0"
name = "CMake-Template"
description = "Development environment for CMake Template"
readme = "README.md"
license = { file = "LICENSE" }

dynamic = ["version"]

[project.optional-dependencies]
docs = [
Expand All @@ -22,9 +21,17 @@ docs = [
"sphinx-copybutton",
"sphinx-prompt",
]
dev = [
"pre-commit",
]

[tool.setuptools]
packages = []
[project.entry-points."cmake.prefix"]
CMakeTemplatePrefix = "cmake_template"

[tool.scikit-build]
wheel.install-dir = "cmake_template"

[tool.scikit-build.metadata.version]
provider = "scikit_build_core.metadata.regex"
# Get the project version from the CMakeLists's project()
input = "CMakeLists.txt"
regex = '''(?sm)
^project\s*\(\s*Template\s+.*VERSION\s+(?P<value>[\d\.]+).*\)$
'''
3 changes: 1 addition & 2 deletions test/ctest.fmf
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
summary: Run the bundled ctests
tag: [ cmake ]
framework: beakerlib
test: ./test.sh
2 changes: 2 additions & 0 deletions test/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
framework: beakerlib
test: ./test.sh
12 changes: 12 additions & 0 deletions test/package/pip/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.25...3.29)
project(example_spglib LANGUAGES CXX)

find_package(Template REQUIRED CONFIG)

# Make sure the executable is runnable after the pip install
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH True)

add_executable(main main.cpp)
target_link_libraries(main PRIVATE Template::Template)

install(TARGETS main DESTINATION ${SKBUILD_SCRIPTS_DIR})
1 change: 1 addition & 0 deletions test/package/pip/main.cpp
2 changes: 2 additions & 0 deletions test/package/pip/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
summary: Test the python installation
tag: [ python ]
7 changes: 7 additions & 0 deletions test/package/pip/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build-system]
requires = ["scikit-build-core", "CMake-Template"]
build-backend = "scikit_build_core.build"

[project]
name = "example-template"
version = "0.0.0"
26 changes: 26 additions & 0 deletions test/package/pip/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# shellcheck disable=all
source /usr/share/beakerlib/beakerlib.sh || exit 1

rlJournalStart
rlPhaseStartSetup
rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
rlRun "source \$TMT_PLAN_DATA/venv/bin/activate" 0 "Source the plan's virtual environment"
# Secondary venv inheriting from the main virtual environment
# keeps the plan's vnev clean
rlRun "python3 -m venv --system-site-packages \$tmp/venv" 0 "Create the test's virtual environment"
rlRun "deactivate && source \$tmp/venv/bin/activate" 0 "Source the test's virtual environment"
rlRun "set -o pipefail"
rlPhaseEnd

rlPhaseStartTest
rlRun "pip install -v --no-build-isolation ." 0 "Install the test package"
rlRun -s "main" 0 "Run the test executable"
rlAssertGrep "Hello, World!" $rlRun_LOG
rlPhaseEnd

rlPhaseStartCleanup
rlRun "rm -r $tmp" 0 "Remove tmp directory"
rlPhaseEnd
rlJournalEnd