Skip to content

Commit

Permalink
Merge pull request #2921 from m-kuhn/py33
Browse files Browse the repository at this point in the history
Python 3.3 and future
  • Loading branch information
m-kuhn committed Mar 22, 2016
2 parents 5fb64bd + 45a364e commit e6939b8
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 58 deletions.
15 changes: 6 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: cpp

matrix:
include:
# QT4 based build with Python 2 // using a sudo environment
- os: linux
language: cpp
env: QT_VERSION=4
sudo: true
dist: precise
Expand All @@ -14,13 +14,15 @@ matrix:
- clang
# QT5 based build with Python 3 // using container based builds and prebuild binary dependencies in osgeo4travis
- os: linux
language: python # This lets us use newer python versions from virtualenv
env: QT_VERSION=5
sudo: false
cache:
apt: true
# ccache: true # Temporarily disabled https://github.com/qgis/QGIS/pull/2908
compiler:
- clang
directories:
- $HOME/.ccache
compiler: clang
python: "3.3"
addons:
postgresql: "9.4"
apt:
Expand All @@ -37,21 +39,16 @@ matrix:
- libfcgi-dev
- pkg-config
- poppler-utils
- python3
- python3-dev
- python3-setuptools
- txt2tags
- xvfb
- flip
- clang-3.6
# OSX based build with QT4 and Python 2
- os: osx


git:
depth: 30


notifications:
irc: "chat.freenode.net#qgis-test"
on_failure: change
Expand Down
2 changes: 1 addition & 1 deletion ci/travis/linux/qt4/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ sudo apt-get install --force-yes --no-install-recommends --no-install-suggests \
postgresql-9.1-postgis-2.1/precise # from ubuntugis-unstable, not pgdg

sudo -H pip install autopep8 # TODO when switching to trusty or above: replace python-pip with python-autopep8
sudo -H pip install nose2 pyyaml mock
sudo -H pip install nose2 pyyaml mock future

#update clang
sudo apt-get install --force-yes llvm-3.8 llvm-3.8-dev clang-3.8 libstdc++-4.9-dev
Expand Down
4 changes: 2 additions & 2 deletions ci/travis/linux/qt5/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export CORES=2

pushd ${HOME}

curl -L https://github.com/opengisch/osgeo4travis/raw/binary/osgeo4travis.tar.xz | tar -JxC /home/travis
curl -L https://github.com/opengisch/osgeo4travis/raw/binary-py33/osgeo4travis.tar.xz | tar -JxC /home/travis
curl -L https://cmake.org/files/v3.5/cmake-3.5.0-Linux-x86_64.tar.gz | tar --strip-components=1 -zxC /home/travis/osgeo4travis
popd

# easy_install3 --prefix=${HOME}/osgeo4travis/ pyspatialite
pip install psycopg2 numpy nose2 pyyaml mock future
26 changes: 1 addition & 25 deletions ci/travis/linux/qt5/blacklist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ PyQgsDelimitedTextProvider
PyQgsDistanceArea
PyQgsDocCoverage
PyQgsEditWidgets
PyQgsExpression
PyQgsFeature
PyQgsFeatureIterator
PyQgsField
Expand Down Expand Up @@ -74,9 +73,7 @@ PyQgsVirtualLayerDefinition
PyQgsVirtualLayerProvider
PyQgsZonalStatistics
qgis_alignrastertest
qgis_attributetabletest
qgis_authmanagertest
qgis_blendmodestest
qgis_atlascompositiontest
qgis_composereffectstest
qgis_composermapgridtest
qgis_composermapoverviewtest
Expand All @@ -91,40 +88,19 @@ qgis_composertabletest
qgis_composertablev2test
qgis_composerutils
qgis_coordinatereferencesystemtest
qgis_doublespinbox
qgis_dualviewtest
qgis_ellipsemarkertest
qgis_fieldcalculatortest
qgis_fieldexpressionwidget
qgis_fieldtest
qgis_filewidget
qgis_gdalprovidertest
qgis_geometrytest
qgis_gradienttest
qgis_labelingenginev2
qgis_legendrenderertest
qgis_linefillsymboltest
qgis_mapcanvastest
qgis_maprenderertest
qgis_maprotationtest
qgis_maptoolidentifyaction
qgis_markerlinessymboltest
qgis_measuretool
qgis_openstreetmaptest
qgis_painteffecttest
qgis_pointpatternfillsymboltest
qgis_projectionissues
qgis_qgisappclipboard
qgis_qgsguitest
qgis_rastercalculatortest
qgis_rasterfilewritertest
qgis_rasterlayertest
qgis_rubberbandtest
qgis_scalecombobox
qgis_simplemarkertest
qgis_spinbox
qgis_svgmarkertest
qgis_vectorlayerjoinbuffer
qgis_wcsprovidertest
qgis_ziplayertest
qgis_zoomtest
7 changes: 3 additions & 4 deletions ci/travis/linux/qt5/install.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
mkdir build
cd build

ln -s /usr/bin/ccache ${HOME}/osgeo4travis/bin/clang++-3.6
ln -s /usr/bin/ccache ${HOME}/osgeo4travis/bin/clang-3.6
ln -s ${HOME}/osgeo4travis/bin/ccache ${HOME}/osgeo4travis/bin/clang++-3.6
ln -s ${HOME}/osgeo4travis/bin/ccache ${HOME}/osgeo4travis/bin/clang-3.6

ccache -s

export CXX="clang++-3.6"
export CC="clang-3.6"
export PATH=${HOME}/osgeo4travis/bin:${PATH}
export PYTHONPATH=${HOME}/osgeo4travis/lib/python3/dist-packages/
export PYTHONPATH=${HOME}/osgeo4travis/lib/python3.3/site-packages/

cmake --version
${CC} --version
Expand Down Expand Up @@ -38,5 +38,4 @@ cmake \
-DENABLE_QT5=ON \
-DENABLE_PYTHON3=ON \
-DCXX_EXTRA_FLAGS="$CLANG_WARNINGS" \
-DPYTHON_LIBRARY=/usr/lib/libpython3.2mu.so \
..
3 changes: 2 additions & 1 deletion ci/travis/linux/qt5/script.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export PYTHONPATH=${HOME}/osgeo4travis/lib/python3/dist-packages/
export PYTHONPATH=${HOME}/osgeo4travis/lib/python3.3/site-packages/

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

xvfb-run ctest -V -E "$(cat ${DIR}/blacklist.txt | paste -sd '|' -)" -S ./qgis-test-travis.ctest --output-on-failure
# xvfb-run ctest -V -S ./qgis-test-travis.ctest --output-on-failure
2 changes: 1 addition & 1 deletion ci/travis/osx/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ mkdir -p ${HOME}/Library/Python/2.7/lib/python/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> ${HOME}/Library/Python/2.7/lib/python/site-packages/homebrew.pth

# Needed for Processing
pip install psycopg2 numpy nose2 pyyaml mock
pip install psycopg2 numpy nose2 pyyaml mock future
4 changes: 4 additions & 0 deletions ci/travis/osx/script.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
echo $PATH

export PATH=/usr/bin:${PATH}

ctest -V -E 'qgis_openstreetmaptest|qgis_wcsprovidertest|PyQgsServer' -S ./qgis-test-travis.ctest --output-on-failure

2 changes: 1 addition & 1 deletion cmake/UsePythonTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#

# Need python interpreter:
FIND_PACKAGE(PythonInterp REQUIRED)
FIND_PACKAGE(PythonInterp ${PYTHON_VER} REQUIRED)
MARK_AS_ADVANCED(PYTHON_EXECUTABLE)

MACRO(ADD_PYTHON_TEST TESTNAME FILENAME)
Expand Down
29 changes: 22 additions & 7 deletions python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
* *
***************************************************************************
"""
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
from builtins import str

__author__ = 'Martin Dobias'
__date__ = 'November 2009'
Expand All @@ -37,7 +41,10 @@
import traceback
import glob
import os.path
import ConfigParser
try:
import configparser
except ImportError:
import ConfigParser as configparser
import warnings
import codecs
import time
Expand Down Expand Up @@ -237,7 +244,7 @@ def findPlugins(path):
if not os.path.exists(metadataFile):
continue

cp = ConfigParser.ConfigParser()
cp = configparser.ConfigParser()

try:
f = codecs.open(metadataFile, "r", "utf8")
Expand Down Expand Up @@ -476,7 +483,7 @@ def reloadProjectMacros():
mod = imp.new_module("proj_macros_mod")

# set the module code and store it sys.modules
exec(unicode(code), mod.__dict__)
exec(str(code), mod.__dict__)
sys.modules["proj_macros_mod"] = mod

# load new macros
Expand Down Expand Up @@ -574,9 +581,15 @@ def startServerPlugin(packageName):
#######################
# IMPORT wrapper

import __builtin__
try:
import builtins

_builtin_import = builtins.__import__
except AttributeError:
import __builtin__

_builtin_import = __builtin__.__import__

_builtin_import = __builtin__.__import__
_plugin_modules = {}


Expand All @@ -603,5 +616,7 @@ def _import(name, globals={}, locals={}, fromlist=[], level=None):

return mod


__builtin__.__import__ = _import
try:
builtins.__import__ = _import
except AttributeError:
__builtin__.__import__ = _import
10 changes: 5 additions & 5 deletions qgis-test-travis.ctest
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ SET (CTEST_BINARY_DIRECTORY "$ENV{TRAVIS_BUILD_DIR}/build")
#SET (CTEST_SOURCE_DIRECTORY /usr/src/QGIS)
#SET (CTEST_BINARY_DIRECTORY /usr/src/qgis-build)

SET( CTEST_CMAKE_GENERATOR "Unix Makefiles" )
SET (CTEST_CMAKE_COMMAND "cmake" )
SET (CTEST_BUILD_COMMAND "/usr/bin/make -j2 -i -k" )
SET (CTEST_SITE "travis-ci.org" )
SET (CTEST_CMAKE_GENERATOR "Unix Makefiles")
SET (CTEST_CMAKE_COMMAND "cmake")
SET (CTEST_BUILD_COMMAND "/usr/bin/make -j2 -i -k")
SET (CTEST_SITE "travis-ci.org")
IF ($ENV{TRAVIS_PULL_REQUEST} STREQUAL "false")
# No pull request
SET (CTEST_BUILD_NAME "$ENV{TRAVIS_BRANCH} ($ENV{TRAVIS_COMMIT})")
ELSE()
SET (CTEST_BUILD_NAME "PR: $ENV{TRAVIS_PULL_REQUEST} / $ENV{TRAVIS_BRANCH} ($ENV{TRAVIS_COMMIT})")
ENDIF()
SET (CTEST_BUILD_CONFIGURATION "Release")

SET (CTEST_TEST_TIMEOUT 60) # 60 seconds

SET (INITIAL_CACHE "
BUILDNAME:STRING=${CTEST_BUILD_NAME}
Expand Down
2 changes: 2 additions & 0 deletions src/python/qgspythonutilsimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <QMessageBox>
#include <QStringList>
#include <QDir>
#include <QDebug>

#if (PY_VERSION_HEX < 0x03000000)
#define PYOBJ2QSTRING(obj) PyString_AsString( obj )
Expand Down Expand Up @@ -335,6 +336,7 @@ bool QgsPythonUtilsImpl::runString( const QString& command, QString msgOnError,
+ QObject::tr( "Python path:" ) + "<br>" + path;
str.replace( '\n', "<br>" ).replace( " ", "&nbsp; " );

qDebug() << str;
QgsMessageOutput* msg = QgsMessageOutput::createMessageOutput();
msg->setTitle( QObject::tr( "Python error" ) );
msg->setMessage( str, QgsMessageOutput::MessageHtml );
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_qgsexpression.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def testBlockComment(self):
comment
**/""": 'test*/'
}
for e, exp_res in expressions.iteritems():
for e, exp_res in expressions.items():
exp = QgsExpression(e)
result = exp.evaluate()
self.assertEqual(exp_res, result)
Expand All @@ -164,7 +164,7 @@ def testComment(self):
"'test--'": 'test--',
"'--test'": '--test',
}
for e, exp_res in expressions.iteritems():
for e, exp_res in expressions.items():
exp = QgsExpression(e)
result = exp.evaluate()
self.assertEqual(exp_res, result)
Expand Down

0 comments on commit e6939b8

Please sign in to comment.