Skip to content

Commit fcd93f4

Browse files
author
Your Name
committed
Include dist-info for python3-dnf
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] rpm-software-management/dnf5#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
1 parent 552e61e commit fcd93f4

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

dnf.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ popd
363363
%{_bindir}/%{name}-3
364364
%{_bindir}/%{name}4
365365
%exclude %{python3_sitelib}/%{name}/automatic
366+
%{python3_sitelib}/%{name}-*.dist-info
366367
%{python3_sitelib}/%{name}/
367368
%dir %{py3pluginpath}
368369
%dir %{py3pluginpath}/__pycache__

dnf/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ INSTALL (FILES ${dnf_SRCS} DESTINATION ${PYTHON_INSTALL_DIR}/dnf)
33
# const.py is generated so the glob alone won't see it:
44
INSTALL (FILES const.py DESTINATION ${PYTHON_INSTALL_DIR}/dnf)
55

6+
# Generate dist-info metadata
7+
SET(DISTINFO_PATH "${CMAKE_CURRENT_BINARY_DIR}/dnf-${DNF_VERSION}.dist-info")
8+
SET(METADATA_FILE "${DISTINFO_PATH}/METADATA")
9+
FILE(MAKE_DIRECTORY ${DISTINFO_PATH})
10+
FILE(WRITE ${METADATA_FILE} "Metadata-Version: 2.1\n")
11+
FILE(APPEND ${METADATA_FILE} "Name: dnf\n")
12+
FILE(APPEND ${METADATA_FILE} "Version: ${DNF_VERSION}\n")
13+
INSTALL(DIRECTORY ${DISTINFO_PATH} DESTINATION ${PYTHON_INSTALL_DIR})
14+
615
ADD_SUBDIRECTORY (automatic)
716
ADD_SUBDIRECTORY (cli)
817
ADD_SUBDIRECTORY (conf)

0 commit comments

Comments
 (0)