Skip to content

Commit

Permalink
Add new target port-plugins to run 2to3 on plugins as build step
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Apr 12, 2016
1 parent f7354ff commit 30df95a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions ci/travis/linux/qt5/install.sh
Expand Up @@ -37,5 +37,6 @@ cmake \
-DWITH_SERVER=ON \
-DENABLE_QT5=ON \
-DENABLE_PYTHON3=ON \
-DPORT_PLUGINS=ON \
-DCXX_EXTRA_FLAGS="$CLANG_WARNINGS" \
..
10 changes: 10 additions & 0 deletions python/CMakeLists.txt
Expand Up @@ -53,6 +53,16 @@ MACRO(PY_COMPILE TARGET_NAME RESOURCE_PATHS)
ENDIF(WITH_PY_COMPILE)
ENDMACRO(PY_COMPILE)

# Macro to auto migrate resources
MACRO(PY_2TO3 TARGET_NAME RESOURCE_PATHS)
ADD_CUSTOM_COMMAND(TARGET ${TARGET_NAME}
POST_BUILD
COMMAND "${CMAKE_SOURCE_DIR}/scripts/2to3" -w ${RESOURCE_PATHS}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Porting to Python 3 and Qt5"
)
ENDMACRO(PY_2TO3)

ADD_SUBDIRECTORY(plugins)
ADD_SUBDIRECTORY(qsci_apis)
ADD_SUBDIRECTORY(console)
Expand Down
15 changes: 14 additions & 1 deletion python/plugins/CMakeLists.txt
Expand Up @@ -8,6 +8,15 @@

FILE(WRITE ${CMAKE_BINARY_DIR}/stagecount 0)

# The target port-plugins acts as a container for all port-plugin-XXX targets
# Each port-plugin-XXX target will run scripts/2to3 on a plugin and migrate
# Python 3 and Qt 5 code.
ADD_CUSTOM_TARGET(port-plugins)
SET (PORT_PLUGINS FALSE CACHE BOOL "Determines whether python plugins in staged or installed locations should be migrated to Python 3 and Qt 5")
IF(PORT_PLUGINS)
ADD_CUSTOM_TARGET(port-plugins-on-build ALL DEPENDS port-plugins)
ENDIF(PORT_PLUGINS)

MACRO (PLUGIN_INSTALL plugin subdir )
FILE(READ ${CMAKE_BINARY_DIR}/stagecount n)
MATH(EXPR n "${n}+1")
Expand All @@ -24,13 +33,17 @@ MACRO (PLUGIN_INSTALL plugin subdir )
ADD_DEPENDENCIES(zzz-${plugin}-stageinstall zzz-${plugin}-depend)

ADD_CUSTOM_COMMAND(TARGET zzz-${plugin}-stageinstall
COMMAND ${CMAKE_COMMAND} -P ${_cmake}
COMMAND ${CMAKE_COMMAND} -P ${_cmake}
)

ADD_CUSTOM_TARGET(clean-staged-${plugin}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}
)

ADD_CUSTOM_TARGET(port-plugin-${plugin})
PY_2TO3(port-plugin-${plugin} ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin})
ADD_DEPENDENCIES(port-plugins port-plugin-${plugin})

ADD_DEPENDENCIES(staged-plugins zzz-${plugin}-stageinstall)
ADD_CUSTOM_TARGET(staged-${plugin} DEPENDS zzz-${plugin}-stageinstall)
FILE(WRITE ${_cmake} "")
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/tests/AlgorithmsTestBase.py
Expand Up @@ -55,7 +55,7 @@ def test_algorithms(self):
This is the main test function. All others will be executed based on the definitions in testdata/algorithm_tests.yaml
"""
ver = processing.version()
print "Processing {}.{}.{}".format(ver / 10000, ver / 100 % 100, ver % 100)
print("Processing {}.{}.{}".format(ver / 10000, ver / 100 % 100, ver % 100))
with open(os.path.join(processingTestDataPath(), self.test_definition_file()), 'r') as stream:
algorithm_tests = yaml.load(stream)

Expand Down

0 comments on commit 30df95a

Please sign in to comment.