Skip to content

Commit

Permalink
[pyqgis-console] Fix build error. Revert adding of qsci-pap-master ta…
Browse files Browse the repository at this point in the history
…rget

- Leave only qsci-pap-src target for updating default pyqgis.pap in source tree
- Mark WITH_QSCIAPI as advanced in CMake, since it mostly a dev function
  • Loading branch information
dakcarto committed Aug 31, 2013
1 parent b4002f8 commit 6e19748
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 39 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Expand Up @@ -86,7 +86,9 @@ IF (WITH_BINDINGS)
SET (WITH_STAGED_PLUGINS TRUE CACHE BOOL "Stage-install core Python plugins to run from build directory? (utilities and console are always staged)")
SET (WITH_PY_COMPILE FALSE CACHE BOOL "Determines whether Python modules in staged or installed locations are byte-compiled")
# concatenate QScintilla2 API files
SET (WITH_QSCIAPI TRUE CACHE BOOL "Whether to generate PyQGIS QScintilla2 API file. Run 'make qsci-pap-master or qsci-pap-src' in between QGIS build and install, to generate .pap file for console auto-completion.")
SET (WITH_QSCIAPI TRUE CACHE BOOL "Whether to generate PyQGIS QScintilla2 API file. (For devs) run 'make qsci-pap-src' in between QGIS build and install to regenerate .pap file in source tree for console auto-completion.")
# keep casual users from updating their source tree via WITH_QSCIAPI
MARK_AS_ADVANCED (WITH_QSCIAPI)
# path to custom Python framework on Mac
IF (APPLE)
SET (PYTHON_CUSTOM_FRAMEWORK "" CACHE PATH "Path to custom Python.framework on Mac. (should not have to specify other Python options)")
Expand Down
23 changes: 3 additions & 20 deletions python/CMakeLists.txt
Expand Up @@ -140,38 +140,21 @@ IF(WITH_QSCIAPI)

INSTALL(FILES ${QGIS_PYTHON_API_FILE} DESTINATION "${QGIS_DATA_DIR}/python/qsci_apis")

# create targets for generating console auto-completion *.pap binary file
# these take too long to build (> 1 minute) for targets to have ALL property
# create target for generating console auto-completion *.pap binary file
# takes too long to build (> 1 minute) for targets to have ALL property
SET(APIS_SRC_DIR "${CMAKE_SOURCE_DIR}/python/qsci_apis")
SET(APIS_BIN_DIR "${CMAKE_BINARY_DIR}/python/qsci_apis")

# generate a local-only .pap file based upon current master branch,
# which will override (but not replace) the default .pap from source
# run before 'make install' to have the local-only .pap file included in the install;
# console will use it when running from build directory, regardless of whether it is installed
ADD_CUSTOM_TARGET(qsci-pap-master
DEPENDS qsci-api ${QGIS_PYTHON_API_FILE})

SET(PAP_NAME "pyqgis-master.pap")
ADD_CUSTOM_COMMAND(TARGET qsci-pap-master
POST_BUILD
COMMAND ${PYTHON_EXECUTABLE} "${APIS_SRC_DIR}/generate_console_pap.py" "${PAP_NAME}" "${APIS_SRC_DIR}" "${APIS_BIN_DIR}" "${APIS_BIN_DIR}"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Generating local-only ${PAP_NAME} for console auto-completion (MAY TAKE > 1 MINUTE!)" VERBATIM)

INSTALL(FILES "${APIS_BIN_DIR}/pyqgis-master.pap" DESTINATION "${QGIS_DATA_DIR}/python/qsci_apis")

# generate a .pap file to be immediately installed in QGIS source tree (the default .pap)
ADD_CUSTOM_TARGET(qsci-pap-src
DEPENDS qsci-api ${QGIS_PYTHON_API_FILE})

SET(PAP_NAME "pyqgis.pap")
ADD_CUSTOM_COMMAND(TARGET qsci-pap-src
POST_BUILD
COMMAND ${PYTHON_EXECUTABLE} "${APIS_SRC_DIR}/generate_console_pap.py" "${PAP_NAME}" "${APIS_SRC_DIR}" "${APIS_BIN_DIR}" "${APIS_SRC_DIR}"
COMMAND ${PYTHON_EXECUTABLE} "${APIS_SRC_DIR}/generate_console_pap.py" "${APIS_SRC_DIR}/${PAP_NAME}" "${APIS_SRC_DIR}" "${APIS_BIN_DIR}"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Generating ${PAP_NAME} for console auto-completion (MAY TAKE > 1 MINUTE!)" VERBATIM)

ENDIF(WITH_QSCIAPI)

# Plugin utilities files to copy to staging or install
Expand Down
12 changes: 1 addition & 11 deletions python/console/console_sci.py
Expand Up @@ -192,17 +192,7 @@ def setLexers(self):
chekBoxAPI = self.settings.value("pythonConsole/preloadAPI", True, type=bool)
chekBoxPreparedAPI = self.settings.value("pythonConsole/usePreparedAPIFile", False, type=bool)
if chekBoxAPI:
apisdir = os.path.join(QgsApplication.pkgDataPath(), "python", "qsci_apis")
pap = os.path.join(apisdir, "pyqgis.pap")
mpap = os.path.join(apisdir, "pyqgis-master.pap")
if os.path.exists(mpap): # override installed with master .pap build
pap = mpap
if QgsApplication.isRunningFromBuildDir():
bdir = os.path.dirname(QgsApplication.buildOutputPath())
bpap = os.path.join(bdir, "python", "qsci_apis", "pyqgis-master.pap")
if os.path.exists(bpap):
# if not generated .pap exists, else fall back to preprepared one
pap = bpap
pap = os.path.join(QgsApplication.pkgDataPath(), "python", "qsci_apis", "pyqgis.pap")
self.api.loadPrepared(pap)
elif chekBoxPreparedAPI:
self.api.loadPrepared(self.settings.value("pythonConsole/preparedAPIFile"))
Expand Down
10 changes: 3 additions & 7 deletions python/qsci_apis/generate_console_pap.py
Expand Up @@ -69,23 +69,19 @@ def prepareAPI(self):


if __name__ == '__main__':
if len(sys.argv) != 5:
print 'Usage: python <script> <pap_name_w-ext> ' \
'<apis_src_dir> <api_bin_dir> <output_dir>'
if len(sys.argv) != 4:
print 'Usage: python <script> <pap_file> <apis_src_dir> <api_bin_dir>'
sys.exit(1)
pap_name = sys.argv[1]
pap_file = sys.argv[1]
api_src_dir = sys.argv[2]
api_bin_dir = sys.argv[3]
output_dir = sys.argv[4]

api_files = [
os.path.join(api_bin_dir, 'PyQGIS.api'),
os.path.join(api_src_dir, 'Python-2.7.api'),
os.path.join(api_src_dir, 'PyQt4-4.7.4.api'),
os.path.join(api_src_dir, 'OSGeo_GDAL-OGR-1.9.1.api')
]
pap_file= os.path.join(output_dir, pap_name)

# print api_files.__repr__()
# print pap_file.__repr__()

Expand Down

0 comments on commit 6e19748

Please sign in to comment.