diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index c2ebdb7..5f548c4 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -57,10 +57,10 @@ jobs: python-version: '3.x' - name: Build wheels for CPython - uses: pypa/cibuildwheel@v3.3.1 + uses: pypa/cibuildwheel@v3.4.1 env: CIBW_ARCHS: auto64 - CIBW_SKIP: "pp* *-musllinux_* cp36* cp37* cp38*" # no PyPy or musl builds, no older Python versions + CIBW_SKIP: "pp* *-musllinux_* cp38* cp39* cp310*" # no PyPy or musl builds, no older Python versions CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 # alma 8 CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28 CIBW_BEFORE_ALL_LINUX: dnf -y install epel-release && yes | dnf -y builddep libcomps.spec diff --git a/MANIFEST.in b/MANIFEST.in index 0987fe3..70aa135 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,5 @@ graft libcomps* -include version.cmake -include version.json +include VERSION include pyproject.toml -include setup.py include COPYING include README.md diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..5a48b6b --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.24 diff --git a/build_prep.cmake b/build_prep.cmake index ab3ae0a..91a8ea7 100644 --- a/build_prep.cmake +++ b/build_prep.cmake @@ -63,7 +63,12 @@ MACRO(MAKE_LOGENTRY log_entry commit) set(log_entry "${FMT_FINAL}") ENDMACRO(MAKE_LOGENTRY) -include (${CMAKE_SOURCE_DIR}/libcomps/version.cmake) +file(READ "${CMAKE_SOURCE_DIR}/VERSION" VERSION) +string(STRIP "${VERSION}" VERSION) +string(REPLACE "." ";" VERSION_LIST ${VERSION}) +list(GET VERSION_LIST 0 libcomps_VERSION_MAJOR) +list(GET VERSION_LIST 1 libcomps_VERSION_MINOR) +list(GET VERSION_LIST 2 libcomps_VERSION_PATCH) SET(changelog_commits 946584c5a01d83bf9ec4c26d3f9d73e37bfb5456; 76764059f1085abbd0eeaeab64f45ec48a58ba4d; diff --git a/libcomps.spec b/libcomps.spec index 392c1c8..5c41b06 100644 --- a/libcomps.spec +++ b/libcomps.spec @@ -50,7 +50,6 @@ Documentation files for python bindings libcomps library. %package -n python3-%{name} Summary: Python 3 bindings for libcomps library BuildRequires: python3-devel -BuildRequires: python3-setuptools BuildRequires: make %{?python_provide:%python_provide python3-%{name}} Requires: %{name}%{?_isa} = %{version}-%{release} @@ -113,6 +112,6 @@ popd %files -n python3-%{name} %{python3_sitearch}/%{name}/ -%{python3_sitearch}/%{name}-*-py%{python3_version}.egg-info +%{python3_sitearch}/%{name}-*.dist-info %changelog diff --git a/libcomps/CMakeLists.txt b/libcomps/CMakeLists.txt index 3cfe2b1..9a2783d 100644 --- a/libcomps/CMakeLists.txt +++ b/libcomps/CMakeLists.txt @@ -10,7 +10,13 @@ endif() include (GNUInstallDirs) include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) -include (${CMAKE_SOURCE_DIR}/version.cmake) +file(READ "${CMAKE_SOURCE_DIR}/../VERSION" VERSION) +string(STRIP "${VERSION}" VERSION) +string(REPLACE "." ";" VERSION_LIST ${VERSION}) +list(GET VERSION_LIST 0 libcomps_VERSION_MAJOR) +list(GET VERSION_LIST 1 libcomps_VERSION_MINOR) +list(GET VERSION_LIST 2 libcomps_VERSION_PATCH) +set (libcomps_RELEASE 1) #set (CMAKE_CXX_COMPILER g++) OPTION (ENABLE_TESTS "Build test?" ON) @@ -20,8 +26,6 @@ set(LIBCOMPS_OUT "${CMAKE_CURRENT_BINARY_DIR}/src") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --pedantic -std=c99 -Wall -Wextra -Wno-missing-field-initializers -O2 -fno-strict-aliasing") set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -ggdb -O0 -Wall -Wextra") - -set (VERSION "${libcomps_VERSION_MAJOR}.${libcomps_VERSION_MINOR}.${libcomps_VERSION_PATCH}") #set (libcomps_SOURCE comps_list.c) #set (libcomps_HEADERS comps_list.h) diff --git a/libcomps/src/python/src/CMakeLists.txt b/libcomps/src/python/src/CMakeLists.txt index d22b84e..014490d 100644 --- a/libcomps/src/python/src/CMakeLists.txt +++ b/libcomps/src/python/src/CMakeLists.txt @@ -17,17 +17,6 @@ set (pycomps_HEADERS pycomps_macros.h pycomps_sequence.h pycomps_hash.h pycomps_exc.h pycomps_lbw.h pycomps_types.h) -#set(TEST_FILES ../__init__.py __test.py test_merge_comps.py test_libcomps.py -# utest.py) -# -#set(TEST_COMPS fedora_comps.xml sample_comps.xml -# sample_comps2.xml sample_comps2.xml.gz main_comps.xml -# main_comps2.xml main_arches.xml f21-rawhide-comps.xml -# comps-f21.xml.in -# comps/comps_part1.xml comps/comps_part2.xml -# comps/merged_comps_1_2.xml comps/merged_comps_2_1.xml -# comps/comps-f21.xml) - list (LENGTH pycomps_SRC pycomps_SRCLEN) math (EXPR pycomps_SRCLEN "${pycomps_SRCLEN} - 1") foreach(i RANGE 0 ${pycomps_SRCLEN}) @@ -42,12 +31,6 @@ foreach(i RANGE 0 ${pycomps_SRCLEN}) LIST_REPLACE(pycomps_HEADERS ${i} "${CMAKE_CURRENT_SOURCE_DIR}/${val}") endforeach(i) -if (NOT SKBUILD) - find_package (PythonInterp 3 EXACT REQUIRED) - find_package (PythonLibs 3 EXACT) -endif(NOT SKBUILD) - -include_directories(${PYTHON_INCLUDE_DIR}) include_directories(${LIBCOMPS_INCLUDE_PATH}) if (ENABLE_TESTS) @@ -56,21 +39,29 @@ endif () include(../pycopy.cmake) -add_library(pycomps SHARED ${pycomps_SRC}) -set_target_properties(pycomps PROPERTIES LIBRARY_OUTPUT_DIRECTORY "./libcomps") -set_target_properties(pycomps PROPERTIES PREFIX "") -set_target_properties(pycomps PROPERTIES LIBRARY_OUTPUT_NAME "_libpycomps") -add_dependencies(pycomps src-copy) - -target_link_libraries(pycomps libcomps) -target_link_libraries(pycomps ${EXPAT_LIBRARIES}) -target_link_libraries(pycomps ${LIBXML2_LIBRARIES}) +IF (SKBUILD) + find_package(Python REQUIRED COMPONENTS Interpreter Development.Module) + Python_add_library(pycomps MODULE ${pycomps_SRC}) + set_target_properties(pycomps PROPERTIES OUTPUT_NAME "_libpycomps") +ELSE () + find_package (PythonInterp 3 EXACT REQUIRED) + find_package (PythonLibs 3 EXACT) + include_directories(${PYTHON_INCLUDE_DIR}) -if (NOT SKBUILD) + add_library(pycomps SHARED ${pycomps_SRC}) + set_target_properties(pycomps PROPERTIES PREFIX "") + set_target_properties(pycomps PROPERTIES LIBRARY_OUTPUT_NAME "_libpycomps") # manylinux links statically, no libpythonX.so available # https://github.com/pypa/manylinux/issues/255#issuecomment-450761634 - target_link_libraries(pycomps ${PYTHON_LIBRARIES}) -endif (NOT SKBUILD) + target_link_libraries(pycomps PRIVATE ${PYTHON_LIBRARIES}) +ENDIF () + +set_target_properties(pycomps PROPERTIES LIBRARY_OUTPUT_DIRECTORY "./libcomps") +add_dependencies(pycomps src-copy) + +target_link_libraries(pycomps PRIVATE libcomps) +target_link_libraries(pycomps PRIVATE ${EXPAT_LIBRARIES}) +target_link_libraries(pycomps PRIVATE ${LIBXML2_LIBRARIES}) if (ENABLE_TESTS) set(pycopy pytest_run) @@ -82,23 +73,19 @@ if (ENABLE_TESTS) endif () IF (SKBUILD) - INSTALL(FILES libcomps/__init__.py DESTINATION libcomps/src/python/src/libcomps) - INSTALL(TARGETS pycomps LIBRARY DESTINATION libcomps/src/python/src/libcomps) + INSTALL(FILES libcomps/__init__.py DESTINATION libcomps) + INSTALL(TARGETS pycomps LIBRARY DESTINATION libcomps) ELSE () EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "from sys import stdout; from sysconfig import get_path; stdout.write(get_path('platlib'))" OUTPUT_VARIABLE PYTHON_INSTALL_DIR) INSTALL(FILES ${pycomps_SRCDIR}/libcomps/__init__.py DESTINATION ${PYTHON_INSTALL_DIR}/libcomps) - #INSTALL(FILES ${pycomps_SRCDIR}/tests/__test.py DESTINATION - # ${PYTHON_INSTALL_DIR}/libcomps/) - #INSTALL(FILES ${pycomps_SRCDIR}/tests/fedora_comps.xml DESTINATION - # ${PYTHON_INSTALL_DIR}/libcomps/) - #INSTALL(FILES ${pycomps_SRCDIR}/tests/sample_comps.xml DESTINATION - # ${PYTHON_INSTALL_DIR}/libcomps/) - #INSTALL(FILES ${pycomps_SRCDIR}/tests/main_comps.xml DESTINATION - # ${PYTHON_INSTALL_DIR}/libcomps/) - #INSTALL(FILES ${pycomps_SRCDIR}/tests/main_comps2.xml DESTINATION - # ${PYTHON_INSTALL_DIR}/libcomps/) INSTALL (TARGETS pycomps LIBRARY DESTINATION ${PYTHON_INSTALL_DIR}/libcomps) - # Version has to be passed as last argument. - INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/../setup_for_python_metadata.py install_egg_info --install-dir \$ENV{DESTDIR}/${PYTHON_INSTALL_DIR}/ ${VERSION})") -ENDIF (SKBUILD) + # Install dist-info metadata so distro packaging tools can discover this package + SET(_DIST_INFO_DIR "${PYTHON_INSTALL_DIR}/libcomps-${VERSION}.dist-info") + INSTALL(CODE " + file(MAKE_DIRECTORY \$ENV{DESTDIR}/${_DIST_INFO_DIR}) + file(WRITE \$ENV{DESTDIR}/${_DIST_INFO_DIR}/METADATA \"Metadata-Version: 2.1\\nName: libcomps\\nVersion: ${VERSION}\\n\") + file(WRITE \$ENV{DESTDIR}/${_DIST_INFO_DIR}/INSTALLER \"cmake\\n\") + file(WRITE \$ENV{DESTDIR}/${_DIST_INFO_DIR}/RECORD \"\") + ") +ENDIF () diff --git a/libcomps/version.cmake b/libcomps/version.cmake deleted file mode 100644 index ebac23f..0000000 --- a/libcomps/version.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set (libcomps_VERSION_MAJOR 0) -set (libcomps_VERSION_MINOR 1) -set (libcomps_VERSION_PATCH 24) -set (libcomps_RELEASE 1) - diff --git a/libcomps/version.cmake.in b/libcomps/version.cmake.in deleted file mode 100644 index d3c4b81..0000000 --- a/libcomps/version.cmake.in +++ /dev/null @@ -1,5 +0,0 @@ -set (libcomps_VERSION_MAJOR ${libcomps_VERSION_MAJOR}) -set (libcomps_VERSION_MINOR ${libcomps_VERSION_MINOR}) -set (libcomps_VERSION_PATCH ${libcomps_VERSION_PATCH}) -set (libcomps_RELEASE ${libcomps_RELEASE}) - diff --git a/pyproject.toml b/pyproject.toml index 34ae493..021f571 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,41 @@ [build-system] -requires = ["setuptools", "wheel", "scikit-build"] -build-backend = "setuptools.build_meta" +requires = ["scikit-build-core"] +build-backend = "scikit_build_core.build" + +[project] +name = "libcomps" +description = "Comps XML file manipulation library" +readme = "README.md" +license = "GPL-2.0-or-later" +dynamic = ["version"] +authors = [ + {name = "RPM Software Management", email = "rpm-ecosystem@lists.rpm.org"}, +] +classifiers = [ + "Operating System :: POSIX :: Linux", + "Programming Language :: C", + "Topic :: System :: Software Distribution", + "Topic :: System :: Systems Administration", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", +] + +[project.urls] +Homepage = "https://github.com/rpm-software-management/libcomps" + +[tool.scikit-build] +cmake.source-dir = "libcomps" +cmake.args = [ + "-DBUILD_LIBCOMPS_SHARED:BOOL=OFF", + "-DENABLE_DEVELOPMENT:BOOL=OFF", + "-DENABLE_DOCS:BOOL=OFF", + "-DENABLE_TESTS:BOOL=OFF", +] +metadata.version.provider = "scikit_build_core.metadata.regex" +metadata.version.input = "VERSION" +metadata.version.regex = "(?P.+)" diff --git a/rel-bump.py b/rel-bump.py index 136caef..9ca16b6 100755 --- a/rel-bump.py +++ b/rel-bump.py @@ -1,18 +1,11 @@ #!/bin/env python3 -import json -import string if __name__ == "__main__": - with open("version.json", "r", encoding="utf-8") as f: - version = json.load(f) - version["libcomps_RELEASE"] += 1 + with open("VERSION", "r", encoding="utf-8") as f: + version = f.read().strip() - with open("version.json", "w", encoding="utf-8") as f: - json.dump(version, f, indent=4) + major, minor, release = version.split(".") + release = str(int(release) + 1) - with open("libcomps/version.cmake.in", "r", encoding="utf-8") as f: - version_in = f.read() - - version_out = string.Template(version_in).substitute(version) - with open("libcomps/version.cmake", "w", encoding="utf-8") as f: - f.write(version_out) + with open("VERSION", "w", encoding="utf-8") as f: + f.write(f"{major}.{minor}.{release}\n") diff --git a/setup.py b/setup.py deleted file mode 100644 index 2a86f56..0000000 --- a/setup.py +++ /dev/null @@ -1,54 +0,0 @@ -import json - -from skbuild import setup - - -with open('version.json', 'r+') as version_file: - version_dict = json.loads(version_file.read()) - # build version string - version = '{major}.{minor}.{patch}-{release}'.format( - major=version_dict['libcomps_VERSION_MAJOR'], - minor=version_dict['libcomps_VERSION_MINOR'], - patch=version_dict['libcomps_VERSION_PATCH'], - release=version_dict['libcomps_RELEASE'] - ) - -with open('README.md') as readme: - README = readme.read() - -setup( - name='libcomps', - description='Comps XML file manipulation library', - long_description_content_type='text/markdown', - long_description=README, - version=version, - license='GPLv2+', - author='RPM Software Management', - author_email='rpm-ecosystem@lists.rpm.org', - url='https://github.com/rpm-software-management', - classifiers=[ - 'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)', - 'Operating System :: POSIX :: Linux', - 'Programming Language :: C', - 'Topic :: System :: Software Distribution', - 'Topic :: System :: Systems Administration', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - ], - packages=['libcomps'], - package_dir={ - 'libcomps': 'libcomps/src/python/src/libcomps/' - }, - cmake_args=[ - '-DBIN_INSTALL_DIR:PATH=libcomps/src/python/src/libcomps/data/bin', - '-DBUILD_LIBCOMPS_SHARED:BOOL=OFF', - '-DENABLE_DEVELOPMENT:BOOL=OFF', - '-DENABLE_DOCS:BOOL=OFF', - '-DENABLE_TESTS:BOOL=OFF' - ], - cmake_languages=['C'], - cmake_source_dir="libcomps", -) diff --git a/setup_for_python_metadata.py b/setup_for_python_metadata.py deleted file mode 100755 index 1794eff..0000000 --- a/setup_for_python_metadata.py +++ /dev/null @@ -1,31 +0,0 @@ -from setuptools import setup -import sys - -# This is a simple and fragile way of creating python metadata for non -# setuptools-guided installs (RPM builds). It's duplicate because of the -# scikit-build dependency in normal setup.py. -# -# This script has to have the version always specified as last argument. -version = sys.argv.pop() - -setup( - name='libcomps', - description='Comps XML file manipulation library', - version=version, - license='GPLv2+', - author='RPM Software Management', - author_email='rpm-ecosystem@lists.rpm.org', - url='https://github.com/rpm-software-management', - classifiers=[ - 'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)', - 'Operating System :: POSIX :: Linux', - 'Programming Language :: C', - 'Topic :: System :: Software Distribution', - 'Topic :: System :: Systems Administration', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - ], -) diff --git a/ver-bump.py b/ver-bump.py index 4524c4b..56b8193 100755 --- a/ver-bump.py +++ b/ver-bump.py @@ -1,34 +1,26 @@ #!/bin/env python3 -import json import sys -import string if __name__ == "__main__": - with open("version.json", "r", encoding="utf-8") as f: - version = json.load(f) + with open("VERSION", "r", encoding="utf-8") as f: + version = f.read().strip() + + parts = [int(x) for x in version.split(".")] + major, minor, patch = parts[0], parts[1], parts[2] + try: if sys.argv[1] == "major": - version["libcomps_VERSION_MAJOR"] += 1 - version["libcomps_VERSION_MINOR"] = 1 - version["libcomps_VERSION_PATCH"] = 1 - version["libcomps_RELEASE"] = 1 + major += 1 + minor = 0 + patch = 0 elif sys.argv[1] == "minor": - version["libcomps_VERSION_MINOR"] += 1 - version["libcomps_VERSION_PATCH"] = 1 - version["libcomps_RELEASE"] = 1 + minor += 1 + patch = 0 elif sys.argv[1] == "patch": - version["libcomps_VERSION_PATCH"] += 1 - version["libcomps_RELEASE"] = 1 + patch += 1 except IndexError: - version["libcomps_VERSION_PATCH"] += 1 - version["libcomps_RELEASE"] = 1 - - with open("version.json", "w", encoding="utf-8") as f: - json.dump(version, f, indent=4) - - with open("libcomps/version.cmake.in", "r", encoding="utf-8") as f: - version_in = f.read() + patch += 1 - version_out = string.Template(version_in).substitute(version) - with open("libcomps/version.cmake", "w", encoding="utf-8") as f: - f.write(version_out) + new_version = f"{major}.{minor}.{patch}" + with open("VERSION", "w", encoding="utf-8") as f: + f.write(new_version + "\n") diff --git a/version.cmake b/version.cmake deleted file mode 100644 index ebac23f..0000000 --- a/version.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set (libcomps_VERSION_MAJOR 0) -set (libcomps_VERSION_MINOR 1) -set (libcomps_VERSION_PATCH 24) -set (libcomps_RELEASE 1) - diff --git a/version.cmake.in b/version.cmake.in deleted file mode 100644 index d3c4b81..0000000 --- a/version.cmake.in +++ /dev/null @@ -1,5 +0,0 @@ -set (libcomps_VERSION_MAJOR ${libcomps_VERSION_MAJOR}) -set (libcomps_VERSION_MINOR ${libcomps_VERSION_MINOR}) -set (libcomps_VERSION_PATCH ${libcomps_VERSION_PATCH}) -set (libcomps_RELEASE ${libcomps_RELEASE}) - diff --git a/version.json b/version.json deleted file mode 100644 index b3a8c0b..0000000 --- a/version.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "libcomps_VERSION_MAJOR": 0, - "libcomps_RELEASE": 1, - "libcomps_VERSION_MINOR": 1, - "libcomps_VERSION_PATCH": 24 -}