Skip to content

Commit da85933

Browse files
authored
Merge pull request #2 from jcfr/python-pkg
Python pkg
2 parents e880bf0 + ee6df5f commit da85933

File tree

6 files changed

+91
-18
lines changed

6 files changed

+91
-18
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ if(NOT BUILD_LIBCREATEREPO_C_SHARED)
1919
set(CMAKE_POSITION_INDEPENDENT_CODE 1)
2020
endif()
2121

22+
option(CREATEREPO_C_INSTALL_DEVELOPMENT "Install createrepo_c development files." ON)
23+
option(CREATEREPO_C_INSTALL_MANPAGES "Install createrepo_c man-pages." ON)
24+
2225
# Add path with own cmake modules
2326

2427
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR})
@@ -133,9 +136,6 @@ endif()
133136
# Other files
134137

135138
OPTION(ENABLE_BASHCOMP "Install Bash autocompletions?" ON)
136-
IF (SKBUILD)
137-
SET (ENABLE_BASHCOMP OFF)
138-
ENDIF ()
139139
IF (ENABLE_BASHCOMP)
140140
pkg_check_modules(BASHCOMP bash-completion)
141141
IF (BASHCOMP_FOUND)

doc/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ if(DOXYGEN_FOUND)
88
COMMENT "Building C API documentation with Doxygen" VERBATIM)
99
endif(DOXYGEN_FOUND)
1010

11-
IF (NOT SKBUILD)
12-
INSTALL(FILES createrepo_c.8 mergerepo_c.8 modifyrepo_c.8 sqliterepo_c.8
13-
DESTINATION share/man/man8
14-
COMPONENT bin)
15-
ENDIF (NOT SKBUILD)
11+
IF(CREATEREPO_C_INSTALL_MANPAGES)
12+
INSTALL(FILES createrepo_c.8 mergerepo_c.8 modifyrepo_c.8 sqliterepo_c.8
13+
DESTINATION share/man/man8
14+
COMPONENT bin)
15+
ENDIF(CREATEREPO_C_INSTALL_MANPAGES)
1616

1717
ADD_CUSTOM_TARGET (doc)
1818
ADD_DEPENDENCIES (doc doc-python doc-c)

requirements-dev.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
setuptools
2+
wheel
3+
scikit-build

setup.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,32 @@
1414
'Programming Language :: C',
1515
'Topic :: System :: Software Distribution',
1616
'Topic :: System :: Systems Administration',
17+
"Programming Language :: Python :: 2",
18+
'Programming Language :: Python :: 2.7',
1719
'Programming Language :: Python :: 3',
20+
'Programming Language :: Python :: 3.4',
21+
'Programming Language :: Python :: 3.5',
22+
'Programming Language :: Python :: 3.6',
23+
'Programming Language :: Python :: 3.7',
1824
),
19-
python_requires=">=3.5",
2025
packages=['createrepo_c'],
2126
package_dir={
2227
'createrepo_c': 'src/python'
2328
},
24-
cmake_args=['-DPYTHON_DESIRED:STRING=3', '-DBUILD_LIBCREATEREPO_C_SHARED:BOOL=OFF'],
29+
cmake_args=[
30+
'-DBIN_INSTALL_DIR:PATH=src/python/data/bin',
31+
'-DBUILD_LIBCREATEREPO_C_SHARED:BOOL=OFF',
32+
'-DCREATEREPO_C_INSTALL_DEVELOPMENT:BOOL=OFF',
33+
'-DCREATEREPO_C_INSTALL_MANPAGES:BOOL=OFF',
34+
'-DENABLE_BASHCOMP:BOOL=OFF',
35+
],
2536
cmake_languages=['C'],
37+
entry_points={
38+
'console_scripts': [
39+
'createrepo_c=createrepo_c:createrepo_c',
40+
'mergerepo_c=createrepo_c:mergerepo_c',
41+
'modifyrepo_c=createrepo_c:modifyrepo_c',
42+
'sqliterepo_c=createrepo_c:sqliterepo_c'
43+
]
44+
},
2645
)

src/CMakeLists.txt

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,32 @@ IF (CMAKE_SIZEOF_VOID_P MATCHES "8")
116116
SET (LIB_SUFFIX "64")
117117
ENDIF (CMAKE_SIZEOF_VOID_P MATCHES "8")
118118

119-
IF (BUILD_LIBCREATEREPO_C_SHARED)
120-
SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
119+
SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
120+
IF (CREATEREPO_C_INSTALL_DEVELOPMENT OR "${createrepo_c_library_type}" STREQUAL "SHARED")
121+
INSTALL(
122+
TARGETS libcreaterepo_c
123+
RUNTIME DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries
124+
LIBRARY DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries
125+
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} COMPONENT Development
126+
)
127+
ENDIF (CREATEREPO_C_INSTALL_DEVELOPMENT OR "${createrepo_c_library_type}" STREQUAL "SHARED")
121128

129+
IF (CREATEREPO_C_INSTALL_DEVELOPMENT)
122130
INSTALL(FILES ${headers} DESTINATION "include/createrepo_c")
123131
INSTALL(FILES "createrepo_c.pc" DESTINATION "${LIB_INSTALL_DIR}/pkgconfig")
124-
INSTALL(TARGETS libcreaterepo_c LIBRARY DESTINATION ${LIB_INSTALL_DIR})
125-
ENDIF (BUILD_LIBCREATEREPO_C_SHARED)
132+
ENDIF (CREATEREPO_C_INSTALL_DEVELOPMENT)
126133

127-
INSTALL(TARGETS createrepo_c DESTINATION bin/)
128-
INSTALL(TARGETS mergerepo_c DESTINATION bin/)
129-
INSTALL(TARGETS modifyrepo_c DESTINATION bin/)
130-
INSTALL(TARGETS sqliterepo_c DESTINATION bin/)
134+
IF (NOT DEFINED BIN_INSTALL_DIR)
135+
SET(BIN_INSTALL_DIR "bin/")
136+
ENDIF (NOT DEFINED BIN_INSTALL_DIR)
137+
INSTALL(
138+
TARGETS
139+
createrepo_c
140+
mergerepo_c
141+
modifyrepo_c
142+
sqliterepo_c
143+
RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime
144+
)
131145

132146
IF (ENABLE_PYTHON)
133147
ADD_SUBDIRECTORY(python)

src/python/__init__.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
"""
22
"""
33

4+
import os
5+
import subprocess
6+
import sys
7+
48
from . import _createrepo_c
59
from ._createrepo_c import *
610

@@ -326,3 +330,36 @@ def decompress_file(src, dst, comtype, stat=None):
326330
compression_suffix = _createrepo_c.compression_suffix
327331
detect_compression = _createrepo_c.detect_compression
328332
compression_type = _createrepo_c.compression_type
333+
334+
335+
DATA = os.path.join(os.path.dirname(__file__), 'data')
336+
337+
# Support running tests from the source tree
338+
if not os.path.exists(DATA):
339+
from skbuild.constants import CMAKE_INSTALL_DIR as SKBUILD_CMAKE_INSTALL_DIR
340+
_data = os.path.abspath(os.path.join(
341+
os.path.dirname(__file__), '..', SKBUILD_CMAKE_INSTALL_DIR, 'src/python/data'))
342+
if os.path.exists(_data):
343+
DATA = _data
344+
345+
BIN_DIR = os.path.join(DATA, 'bin')
346+
347+
348+
def _program(name, args):
349+
return subprocess.call([os.path.join(BIN_DIR, name)] + args)
350+
351+
352+
def createrepo_c():
353+
raise SystemExit(_program('createrepo_c', sys.argv[1:]))
354+
355+
356+
def mergerepo_c():
357+
raise SystemExit(_program('mergerepo_c', sys.argv[1:]))
358+
359+
360+
def modifyrepo_c():
361+
raise SystemExit(_program('modifyrepo_c', sys.argv[1:]))
362+
363+
364+
def sqliterepo_c():
365+
raise SystemExit(_program('sqliterepo_c', sys.argv[1:]))

0 commit comments

Comments
 (0)