Skip to content

Commit 3a0c0bb

Browse files
author
wonder
committedFeb 4, 2007
By default install bindings to QGIS directory -> no need to install as root.
It's possible to override it with BINDINGS_GLOBAL_INSTALL set to TRUE, that will cause bindings to be installed to global python's site-packages dir. git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6516 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed
 

‎CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@ SET (PLUGINS_ALSO_BINARIES FALSE)
2525

2626

2727
# try to configure and build GRASS plugin by default
28-
SET (WITH_GRASS TRE CACHE BOOL "Determines whether GRASS plugin should be built")
28+
SET (WITH_GRASS TRUE CACHE BOOL "Determines whether GRASS plugin should be built")
2929
SET (GRASS_PREFIX "" CACHE PATH "Path to GRASS base directory")
3030

3131
# try to configure and build python bindings by default
3232
SET (WITH_BINDINGS TRUE CACHE BOOL "Determines whether python bindings should be built")
3333

34+
# By default bindings will be installed only to QGIS directory
35+
# Someone might want to install it to python site-packages directory
36+
# as otherwise user has to use PYTHONPATH environemnt variable to add
37+
# QGIS bindings to package search path
38+
SET (BINDINGS_GLOBAL_INSTALL FALSE CACHE BOOL "Install bindings to global python directory? (might need root)")
39+
3440

3541
#############################################################
3642
# check if lexer and parser are not missing

‎python/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ ADD_CUSTOM_COMMAND(OUTPUT ${BINDINGS_GUI_LIB} PRE_LINK
4848
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gui
4949
DEPENDS ${BINDINGS_GUI_MAKEFILE})
5050

51+
IF (BINDINGS_GLOBAL_INSTALL)
5152

5253
# python's site-packages dir: bindings will be installed here
5354
IF (UNIX)
@@ -65,6 +66,12 @@ ENDIF (UNIX)
6566

6667
EXEC_PROGRAM(${PYTHON_EXECUTABLE} ARGS -c "\"${CMD}\"" OUTPUT_VARIABLE SITE_PKG_PATH)
6768

69+
ELSE (BINDINGS_GLOBAL_INSTALL)
70+
71+
SET (SITE_PKG_PATH ${QGIS_DATA_DIR}/python)
72+
73+
ENDIF (BINDINGS_GLOBAL_INSTALL)
74+
75+
6876
# Step 4: install built libs to python's site packages
6977
INSTALL(FILES __init__.py ${CMAKE_CURRENT_BINARY_DIR}/qgisconfig.py ${BINDINGS_LIBS} DESTINATION ${SITE_PKG_PATH}/qgis)
70-

‎src/app/qgspythonutils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ void QgsPythonUtils::initPython(QgisInterface* interface)
4343

4444
// import sys module
4545
runString("import sys");
46+
47+
// expect that bindings are installed locally, so add the path to modules
48+
QString pythonPath = QgsApplication::pkgDataPath() + "/python";
49+
runString("sys.path.insert(0, \"" + pythonPath + "\")");
4650

4751
// import SIP
4852
if (!runString("from sip import wrapinstance, unwrapinstance"))

0 commit comments

Comments
 (0)
Please sign in to comment.