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
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
libgpgme-dev
libgtest-dev
make
python3-pytest
valgrind
env:
DEBIAN_FRONTEND: noninteractive
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/python.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Python Packaging

on: # yamllint disable-line rule:truthy
push:
tags: ['*']
workflow_dispatch:

jobs:
sdist:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
- run: python -m pip install -U build
- run: python -m build --sdist
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
wheel:
strategy:
matrix:
include:
- os: ubuntu-24.04
arch: x86_64
- os: ubuntu-24.04-arm
arch: aarch64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- uses: pypa/[email protected]
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.arch }}
path: ./wheelhouse/*.whl
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/build
/build/
/dist/
/wheelhouse/
.*.swp
72 changes: 71 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.15)

project(createrepo-agent C)

Expand Down Expand Up @@ -35,6 +35,7 @@ target_link_libraries(createrepo-cache PUBLIC
target_compile_definitions(createrepo-cache PRIVATE
-DG_LOG_DOMAIN="CREATEREPO_CACHE")
set_target_properties(createrepo-cache PROPERTIES
POSITION_INDEPENDENT_CODE ON
SOVERSION ${CRA_VERSION_MAJOR}
VERSION ${CRA_VERSION})

Expand All @@ -60,6 +61,8 @@ target_link_libraries(createrepo-agent-lib PUBLIC
glib-2.0)
target_compile_definitions(createrepo-agent-lib PRIVATE
-DG_LOG_DOMAIN="CREATEREPO_AGENT")
set_target_properties(createrepo-agent-lib PROPERTIES
POSITION_INDEPENDENT_CODE ON)

# Executable
add_executable(${PROJECT_NAME}
Expand All @@ -75,6 +78,73 @@ install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
COMPONENT bin)

# Python bindings
cmake_policy(SET CMP0094 NEW)
set(Python_FIND_UNVERSIONED_NAMES FIRST
CACHE STRING "Defines how the generic names will be searched for Python")
if(CMAKE_VERSION VERSION_LESS "3.18")
set(Python_COMPONENTS Interpreter Development)
else()
set(Python_COMPONENTS Interpreter Development.Module)
endif()
find_package(Python 3 QUIET COMPONENTS ${Python_COMPONENTS})
option(WITH_PYTHON "Build Python bindings" ${Python_FOUND})
if(WITH_PYTHON)
# Find Python again, this time REQUIRED
find_package(Python 3 REQUIRED COMPONENTS ${Python_COMPONENTS})

python_add_library(createrepo_agent MODULE
src/python/client.c
src/python/init.c
src/python/server.c)
target_link_libraries(createrepo_agent PRIVATE
createrepo-agent-lib)

if(SKBUILD)
set(PYTHON_INSTALL_DIR ${SKBUILD_PLATLIB_DIR})
else()
# Determine package installation location
string(JOIN "; " PYTHON_INSTALL_DIR_CMD
"from os.path import sep"
"from sys import stdout"
"from sysconfig import get_path"
"stdout.write(get_path('platlib', vars={'base': '', 'platbase': ''}).lstrip(sep))"
)
execute_process(COMMAND ${Python_EXECUTABLE} -c "${PYTHON_INSTALL_DIR_CMD}"
OUTPUT_VARIABLE PYTHON_INSTALL_DIR)

set(DISTINFO_NAME "createrepo_agent-${CRA_VERSION}.dist-info")
set(DISTINFO_DIR "${CMAKE_CURRENT_BINARY_DIR}/${DISTINFO_NAME}")
file(GENERATE
OUTPUT "${DISTINFO_DIR}/INSTALLER"
CONTENT "cmake\n")
file(GENERATE
OUTPUT "${DISTINFO_DIR}/METADATA"
CONTENT "Metadata-Version: 1.1\nName: createrepo-agent\nVersion: ${CRA_VERSION}\n")
string(JOIN "\n" RECORD_CONTENT
"$<TARGET_FILE_NAME:createrepo_agent>,,"
"${DISTINFO_NAME}/INSTALLER,,"
"${DISTINFO_NAME}/METADATA,,"
"${DISTINFO_NAME}/RECORD,,"
"${DISTINFO_NAME}/top_level.txt,,"
)
file(GENERATE
OUTPUT "${DISTINFO_DIR}/RECORD"
CONTENT "${RECORD_CONTENT}\n")
file(GENERATE
OUTPUT "${DISTINFO_DIR}/top_level.txt"
CONTENT "createrepo_agent\n")
install(DIRECTORY ${DISTINFO_DIR}
DESTINATION ${PYTHON_INSTALL_DIR}
COMPONENT python)
endif()

install(TARGETS createrepo_agent
RUNTIME DESTINATION ${PYTHON_INSTALL_DIR}
LIBRARY DESTINATION ${PYTHON_INSTALL_DIR}
COMPONENT python)
endif()

add_subdirectory(doc)

set(MEMORYCHECK_SUPPRESSIONS_FILE "${CMAKE_CURRENT_SOURCE_DIR}/test/valgrind.supp"
Expand Down
46 changes: 46 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[build-system]
requires = ["scikit-build-core"]
build-backend = "scikit_build_core.build"

[project]
name = "createrepo-agent"
dynamic = ["version"]

[project.optional-dependencies]
test = [
"pytest",
]

[tool.scikit-build]
install.components = ["python"]
sdist.exclude = [
".editorconfig",
".github",
".gitignore",
"CONTRIBUTING.md",
]
wheel.packages = []

[tool.scikit-build.cmake.define]
BUILD_TESTING = false
WITH_PYTHON = true

[tool.scikit-build.metadata.version]
provider = "scikit_build_core.metadata.regex"
input = "CMakeLists.txt"
regex = '''
set\(CRA_VERSION_MAJOR\s+(?P<major>\d+)\)
set\(CRA_VERSION_MINOR\s+(?P<minor>\d+)\)
set\(CRA_VERSION_PATCH\s+(?P<patch>\d+)\)
'''
result = "{major}.{minor}.{patch}"

[tool.cibuildwheel]
skip = "*-musllinux_*"
test-extras = ["test"]
test-command = [
"python -m pytest {project}/test",
]

[tool.cibuildwheel.linux]
before-all = "dnf install -y createrepo_c-devel glib2-devel gpgme-devel libassuan-devel libgpg-error-devel"
Loading