Skip to content

Commit

Permalink
Merge pull request #2 from jcfr/python-pkg
Browse files Browse the repository at this point in the history
Python pkg
  • Loading branch information
dralley authored Jul 30, 2018
2 parents e880bf0 + ee6df5f commit da85933
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 18 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ if(NOT BUILD_LIBCREATEREPO_C_SHARED)
set(CMAKE_POSITION_INDEPENDENT_CODE 1)
endif()

option(CREATEREPO_C_INSTALL_DEVELOPMENT "Install createrepo_c development files." ON)
option(CREATEREPO_C_INSTALL_MANPAGES "Install createrepo_c man-pages." ON)

# Add path with own cmake modules

INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR})
Expand Down Expand Up @@ -133,9 +136,6 @@ endif()
# Other files

OPTION(ENABLE_BASHCOMP "Install Bash autocompletions?" ON)
IF (SKBUILD)
SET (ENABLE_BASHCOMP OFF)
ENDIF ()
IF (ENABLE_BASHCOMP)
pkg_check_modules(BASHCOMP bash-completion)
IF (BASHCOMP_FOUND)
Expand Down
10 changes: 5 additions & 5 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ if(DOXYGEN_FOUND)
COMMENT "Building C API documentation with Doxygen" VERBATIM)
endif(DOXYGEN_FOUND)

IF (NOT SKBUILD)
INSTALL(FILES createrepo_c.8 mergerepo_c.8 modifyrepo_c.8 sqliterepo_c.8
DESTINATION share/man/man8
COMPONENT bin)
ENDIF (NOT SKBUILD)
IF(CREATEREPO_C_INSTALL_MANPAGES)
INSTALL(FILES createrepo_c.8 mergerepo_c.8 modifyrepo_c.8 sqliterepo_c.8
DESTINATION share/man/man8
COMPONENT bin)
ENDIF(CREATEREPO_C_INSTALL_MANPAGES)

ADD_CUSTOM_TARGET (doc)
ADD_DEPENDENCIES (doc doc-python doc-c)
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
setuptools
wheel
scikit-build
23 changes: 21 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,32 @@
'Programming Language :: C',
'Topic :: System :: Software Distribution',
'Topic :: System :: Systems Administration',
"Programming Language :: Python :: 2",
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
),
python_requires=">=3.5",
packages=['createrepo_c'],
package_dir={
'createrepo_c': 'src/python'
},
cmake_args=['-DPYTHON_DESIRED:STRING=3', '-DBUILD_LIBCREATEREPO_C_SHARED:BOOL=OFF'],
cmake_args=[
'-DBIN_INSTALL_DIR:PATH=src/python/data/bin',
'-DBUILD_LIBCREATEREPO_C_SHARED:BOOL=OFF',
'-DCREATEREPO_C_INSTALL_DEVELOPMENT:BOOL=OFF',
'-DCREATEREPO_C_INSTALL_MANPAGES:BOOL=OFF',
'-DENABLE_BASHCOMP:BOOL=OFF',
],
cmake_languages=['C'],
entry_points={
'console_scripts': [
'createrepo_c=createrepo_c:createrepo_c',
'mergerepo_c=createrepo_c:mergerepo_c',
'modifyrepo_c=createrepo_c:modifyrepo_c',
'sqliterepo_c=createrepo_c:sqliterepo_c'
]
},
)
30 changes: 22 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,32 @@ IF (CMAKE_SIZEOF_VOID_P MATCHES "8")
SET (LIB_SUFFIX "64")
ENDIF (CMAKE_SIZEOF_VOID_P MATCHES "8")

IF (BUILD_LIBCREATEREPO_C_SHARED)
SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
IF (CREATEREPO_C_INSTALL_DEVELOPMENT OR "${createrepo_c_library_type}" STREQUAL "SHARED")
INSTALL(
TARGETS libcreaterepo_c
RUNTIME DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} COMPONENT Development
)
ENDIF (CREATEREPO_C_INSTALL_DEVELOPMENT OR "${createrepo_c_library_type}" STREQUAL "SHARED")

IF (CREATEREPO_C_INSTALL_DEVELOPMENT)
INSTALL(FILES ${headers} DESTINATION "include/createrepo_c")
INSTALL(FILES "createrepo_c.pc" DESTINATION "${LIB_INSTALL_DIR}/pkgconfig")
INSTALL(TARGETS libcreaterepo_c LIBRARY DESTINATION ${LIB_INSTALL_DIR})
ENDIF (BUILD_LIBCREATEREPO_C_SHARED)
ENDIF (CREATEREPO_C_INSTALL_DEVELOPMENT)

INSTALL(TARGETS createrepo_c DESTINATION bin/)
INSTALL(TARGETS mergerepo_c DESTINATION bin/)
INSTALL(TARGETS modifyrepo_c DESTINATION bin/)
INSTALL(TARGETS sqliterepo_c DESTINATION bin/)
IF (NOT DEFINED BIN_INSTALL_DIR)
SET(BIN_INSTALL_DIR "bin/")
ENDIF (NOT DEFINED BIN_INSTALL_DIR)
INSTALL(
TARGETS
createrepo_c
mergerepo_c
modifyrepo_c
sqliterepo_c
RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime
)

IF (ENABLE_PYTHON)
ADD_SUBDIRECTORY(python)
Expand Down
37 changes: 37 additions & 0 deletions src/python/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""
"""

import os
import subprocess
import sys

from . import _createrepo_c
from ._createrepo_c import *

Expand Down Expand Up @@ -326,3 +330,36 @@ def decompress_file(src, dst, comtype, stat=None):
compression_suffix = _createrepo_c.compression_suffix
detect_compression = _createrepo_c.detect_compression
compression_type = _createrepo_c.compression_type


DATA = os.path.join(os.path.dirname(__file__), 'data')

# Support running tests from the source tree
if not os.path.exists(DATA):
from skbuild.constants import CMAKE_INSTALL_DIR as SKBUILD_CMAKE_INSTALL_DIR
_data = os.path.abspath(os.path.join(
os.path.dirname(__file__), '..', SKBUILD_CMAKE_INSTALL_DIR, 'src/python/data'))
if os.path.exists(_data):
DATA = _data

BIN_DIR = os.path.join(DATA, 'bin')


def _program(name, args):
return subprocess.call([os.path.join(BIN_DIR, name)] + args)


def createrepo_c():
raise SystemExit(_program('createrepo_c', sys.argv[1:]))


def mergerepo_c():
raise SystemExit(_program('mergerepo_c', sys.argv[1:]))


def modifyrepo_c():
raise SystemExit(_program('modifyrepo_c', sys.argv[1:]))


def sqliterepo_c():
raise SystemExit(_program('sqliterepo_c', sys.argv[1:]))

0 comments on commit da85933

Please sign in to comment.