Skip to content

Commit

Permalink
generate dist-info for Python bindings
Browse files Browse the repository at this point in the history
* ensures that `libdnf5` and `libdnf5_cli` Python bindings include minimal distribution metadata (per https://packaging.python.org/en/latest/specifications/core-metadata/#core-metadata). This makes the presence of the binding and its version visible to standard Python tools like `pip`.
  • Loading branch information
nitzmahone committed Apr 12, 2023
1 parent 99f6bc4 commit 8ce551b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bindings/python3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,17 @@ function(add_python3_module LIBRARY_NAME MODULE_NAME)
swig_link_libraries(${TARGET_NAME} ${C_LIBRARY_NAME})
swig_link_libraries(${TARGET_NAME} ${Python3_LIBRARIES})

# generate a dist-info for the library (redundantly created for multi-module packages, oh well...)
set(DISTINFO_PATH "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}-${CMAKE_PROJECT_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: ${LIBRARY_NAME}\n")
file(APPEND ${METADATA_FILE} "Version: ${CMAKE_PROJECT_VERSION}\n")

install(TARGETS ${TARGET_NAME} LIBRARY DESTINATION ${Python3_SITEARCH}/${LIBRARY_NAME})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}.py DESTINATION ${Python3_SITEARCH}/${LIBRARY_NAME})
install(DIRECTORY ${DISTINFO_PATH} DESTINATION ${Python3_SITEARCH})
endfunction()


Expand Down

0 comments on commit 8ce551b

Please sign in to comment.