Skip to content

Commit 30df95a

Browse files
committedApr 12, 2016
Add new target port-plugins to run 2to3 on plugins as build step
1 parent f7354ff commit 30df95a

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed
 

‎ci/travis/linux/qt5/install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ cmake \
3737
-DWITH_SERVER=ON \
3838
-DENABLE_QT5=ON \
3939
-DENABLE_PYTHON3=ON \
40+
-DPORT_PLUGINS=ON \
4041
-DCXX_EXTRA_FLAGS="$CLANG_WARNINGS" \
4142
..

‎python/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ MACRO(PY_COMPILE TARGET_NAME RESOURCE_PATHS)
5353
ENDIF(WITH_PY_COMPILE)
5454
ENDMACRO(PY_COMPILE)
5555

56+
# Macro to auto migrate resources
57+
MACRO(PY_2TO3 TARGET_NAME RESOURCE_PATHS)
58+
ADD_CUSTOM_COMMAND(TARGET ${TARGET_NAME}
59+
POST_BUILD
60+
COMMAND "${CMAKE_SOURCE_DIR}/scripts/2to3" -w ${RESOURCE_PATHS}
61+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
62+
COMMENT "Porting to Python 3 and Qt5"
63+
)
64+
ENDMACRO(PY_2TO3)
65+
5666
ADD_SUBDIRECTORY(plugins)
5767
ADD_SUBDIRECTORY(qsci_apis)
5868
ADD_SUBDIRECTORY(console)

‎python/plugins/CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88

99
FILE(WRITE ${CMAKE_BINARY_DIR}/stagecount 0)
1010

11+
# The target port-plugins acts as a container for all port-plugin-XXX targets
12+
# Each port-plugin-XXX target will run scripts/2to3 on a plugin and migrate
13+
# Python 3 and Qt 5 code.
14+
ADD_CUSTOM_TARGET(port-plugins)
15+
SET (PORT_PLUGINS FALSE CACHE BOOL "Determines whether python plugins in staged or installed locations should be migrated to Python 3 and Qt 5")
16+
IF(PORT_PLUGINS)
17+
ADD_CUSTOM_TARGET(port-plugins-on-build ALL DEPENDS port-plugins)
18+
ENDIF(PORT_PLUGINS)
19+
1120
MACRO (PLUGIN_INSTALL plugin subdir )
1221
FILE(READ ${CMAKE_BINARY_DIR}/stagecount n)
1322
MATH(EXPR n "${n}+1")
@@ -24,13 +33,17 @@ MACRO (PLUGIN_INSTALL plugin subdir )
2433
ADD_DEPENDENCIES(zzz-${plugin}-stageinstall zzz-${plugin}-depend)
2534

2635
ADD_CUSTOM_COMMAND(TARGET zzz-${plugin}-stageinstall
27-
COMMAND ${CMAKE_COMMAND} -P ${_cmake}
36+
COMMAND ${CMAKE_COMMAND} -P ${_cmake}
2837
)
2938

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

43+
ADD_CUSTOM_TARGET(port-plugin-${plugin})
44+
PY_2TO3(port-plugin-${plugin} ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin})
45+
ADD_DEPENDENCIES(port-plugins port-plugin-${plugin})
46+
3447
ADD_DEPENDENCIES(staged-plugins zzz-${plugin}-stageinstall)
3548
ADD_CUSTOM_TARGET(staged-${plugin} DEPENDS zzz-${plugin}-stageinstall)
3649
FILE(WRITE ${_cmake} "")

‎python/plugins/processing/tests/AlgorithmsTestBase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_algorithms(self):
5555
This is the main test function. All others will be executed based on the definitions in testdata/algorithm_tests.yaml
5656
"""
5757
ver = processing.version()
58-
print "Processing {}.{}.{}".format(ver / 10000, ver / 100 % 100, ver % 100)
58+
print("Processing {}.{}.{}".format(ver / 10000, ver / 100 % 100, ver % 100))
5959
with open(os.path.join(processingTestDataPath(), self.test_definition_file()), 'r') as stream:
6060
algorithm_tests = yaml.load(stream)
6161

0 commit comments

Comments
 (0)
Please sign in to comment.