Skip to content

Commit

Permalink
By default install bindings to QGIS directory -> no need to install a…
Browse files Browse the repository at this point in the history
…s 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@6516 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Feb 4, 2007
1 parent 880a93a commit fb7b670
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Expand Up @@ -25,12 +25,18 @@ SET (PLUGINS_ALSO_BINARIES FALSE)


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

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

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


#############################################################
# check if lexer and parser are not missing
Expand Down
9 changes: 8 additions & 1 deletion python/CMakeLists.txt
Expand Up @@ -48,6 +48,7 @@ ADD_CUSTOM_COMMAND(OUTPUT ${BINDINGS_GUI_LIB} PRE_LINK
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gui
DEPENDS ${BINDINGS_GUI_MAKEFILE})

IF (BINDINGS_GLOBAL_INSTALL)

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

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

ELSE (BINDINGS_GLOBAL_INSTALL)

SET (SITE_PKG_PATH ${QGIS_DATA_DIR}/python)

ENDIF (BINDINGS_GLOBAL_INSTALL)


# Step 4: install built libs to python's site packages
INSTALL(FILES __init__.py ${CMAKE_CURRENT_BINARY_DIR}/qgisconfig.py ${BINDINGS_LIBS} DESTINATION ${SITE_PKG_PATH}/qgis)

4 changes: 4 additions & 0 deletions src/app/qgspythonutils.cpp
Expand Up @@ -43,6 +43,10 @@ void QgsPythonUtils::initPython(QgisInterface* interface)

// import sys module
runString("import sys");

// expect that bindings are installed locally, so add the path to modules
QString pythonPath = QgsApplication::pkgDataPath() + "/python";
runString("sys.path.insert(0, \"" + pythonPath + "\")");

// import SIP
if (!runString("from sip import wrapinstance, unwrapinstance"))
Expand Down

0 comments on commit fb7b670

Please sign in to comment.