From 7184349f7fb0c5c63368a7d749c77665b2db04ce Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 3 Oct 2023 20:36:12 +0000 Subject: [PATCH] Include dist-info for python3-libdnf5 This is the DNF 4 cousin to this patch [0] for DNF 5. Per [1], Python packages should include some minimal distribution metadata, e.g. to make the package appear in `pip list`. Perhaps the "proper way" to generate this dist-info metadata would be to write a pyproject.toml and use a conventional Python build system like Poetry to build `python3-dnf` rather than doing it with CMake, but this is a way to do it with minimal changes to the build process. Closes RhBug:2239323 [2] [0] https://github.com/rpm-software-management/dnf5/pull/447 [1] https://packaging.python.org/en/latest/specifications/core-metadata/#core-metadata, [2] https://bugzilla.redhat.com/show_bug.cgi?id=2239323 = changelog = msg: Add metadata for `dnf` Python package type: bugfix resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2239323 --- dnf.spec | 1 + dnf/CMakeLists.txt | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/dnf.spec b/dnf.spec index d756ec012a..e3ac036039 100644 --- a/dnf.spec +++ b/dnf.spec @@ -363,6 +363,7 @@ popd %{_bindir}/%{name}-3 %{_bindir}/%{name}4 %exclude %{python3_sitelib}/%{name}/automatic +%{python3_sitelib}/%{name}-*.dist-info %{python3_sitelib}/%{name}/ %dir %{py3pluginpath} %dir %{py3pluginpath}/__pycache__ diff --git a/dnf/CMakeLists.txt b/dnf/CMakeLists.txt index b423bdd92b..ed464a4f0b 100644 --- a/dnf/CMakeLists.txt +++ b/dnf/CMakeLists.txt @@ -3,6 +3,15 @@ INSTALL (FILES ${dnf_SRCS} DESTINATION ${PYTHON_INSTALL_DIR}/dnf) # const.py is generated so the glob alone won't see it: INSTALL (FILES const.py DESTINATION ${PYTHON_INSTALL_DIR}/dnf) +# Generate dist-info metadata +SET(DISTINFO_PATH "${CMAKE_CURRENT_BINARY_DIR}/dnf-${DNF_VERSION}.dist-info") +SET(METADATA_FILE "${DISTINFO_PATH}/METADATA") +FILE(MAKE_DIRECTORY ${DISTINFO_PATH}) +FILE(WRITE ${METADATA_FILE} "Metadata-Version: 2.1\n") +FILE(APPEND ${METADATA_FILE} "Name: dnf\n") +FILE(APPEND ${METADATA_FILE} "Version: ${DNF_VERSION}\n") +INSTALL(DIRECTORY ${DISTINFO_PATH} DESTINATION ${PYTHON_INSTALL_DIR}) + ADD_SUBDIRECTORY (automatic) ADD_SUBDIRECTORY (cli) ADD_SUBDIRECTORY (conf)