Skip to content

Commit 3dda098

Browse files
author
dom
committed
possibility to override the PYTHON_SITE_PACKAGES_INSTALL_DIR
1 parent 149785d commit 3dda098

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

docs/developer/developer.adoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,22 @@ $ cd build/
9797
$ cmake ../
9898
$ make
9999
----
100+
101+
On Ubuntu 18.04 and potentially other distro, the python3 install path is wrong.
102+
If the following command:
103+
104+
----
105+
$ python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(True))"
106+
----
107+
108+
return "/usr/local/lib/python3/dist-packages" instead of a path like
109+
"/usr/local/lib/python3.6/dist-packages", you must override this path,
110+
otherwise you will not be able to import openscap_api.
111+
112+
----
113+
$ cmake ../ -DPYTHON_SITE_PACKAGES_INSTALL_DIR=/usr/local/lib/python3.6/dist-packages
114+
----
115+
100116
--
101117

102118
. *Build the HTML documentation*

swig/python3/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ add_custom_command(OUTPUT ${PYTHON_COMPILED_FILES}
2424
)
2525
add_custom_target(python3_compile ALL DEPENDS ${PYTHON_COMPILED_FILES})
2626

27+
if(NOT PYTHON_SITE_PACKAGES_INSTALL_DIR)
2728
execute_process(COMMAND
2829
${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(True, prefix='${CMAKE_INSTALL_PREFIX}'))"
2930
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_INSTALL_DIR
3031
OUTPUT_STRIP_TRAILING_WHITESPACE
3132
)
33+
endif()
34+
3235
install(TARGETS ${SWIG_MODULE_openscap_py_REAL_NAME}
3336
DESTINATION ${PYTHON_SITE_PACKAGES_INSTALL_DIR}
3437
)

utils/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ if(ENABLE_OSCAP_UTIL_DOCKER)
4545
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
4646
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
4747
)
48+
49+
if(NOT PYTHON_SITE_PACKAGES_INSTALL_DIR)
4850
execute_process(COMMAND
4951
${OSCAP_DOCKER_PYTHON} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(False, False, prefix='${CMAKE_INSTALL_PREFIX}'))"
5052
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_INSTALL_DIR
5153
OUTPUT_STRIP_TRAILING_WHITESPACE
5254
)
55+
endif()
56+
5357
install(DIRECTORY oscap_docker_python
5458
DESTINATION ${PYTHON_SITE_PACKAGES_INSTALL_DIR}
5559
)

0 commit comments

Comments
 (0)