Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Add PySide2 support #84

Merged
merged 21 commits into from
May 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
579e104
Initial setup for PySide2 support, pretesting
dgovil Oct 26, 2016
9a9b66a
Updated __init__ dict and added PySide2 del to QtSvg.py
dgovil Oct 26, 2016
bfefe75
Added __init__ to tests to make them easy to load individually
dgovil Oct 26, 2016
50d2a81
Added comment to QtWebEngineWidgets for PySide2
dgovil Oct 26, 2016
135b49b
Updated tests to have PySide2 tests
dgovil Oct 26, 2016
6ad0112
Addressing notes by @Nodd
dgovil Nov 4, 2016
10327bd
Addressing notes by @Nodd
dgovil Nov 4, 2016
25d3c40
Merge branch 'master' into PySide2Support
ccordoba12 Jan 2, 2017
9c1a62e
Add missing newline in gitignore
ccordoba12 May 5, 2017
5b34639
Activate support for Pyside again
ccordoba12 May 5, 2017
450f65e
Update wih master
ccordoba12 May 5, 2017
123e2d3
Testing: Fix error in Appveyor and don't run ciocheck in CircleCI
ccordoba12 May 5, 2017
1865ddd
Testing: Add missing pytest dependencies on CircleCI
ccordoba12 May 5, 2017
b7f34eb
Testing: Simplify testing on CircleCI
ccordoba12 May 5, 2017
cd289f1
Testing: Skip a test that it's segfaulting in Python 3
ccordoba12 May 5, 2017
d8d8ac1
Testing: Add a package needed for PyQt 5.8
ccordoba12 May 5, 2017
4070af4
Testing: Fix missing pyqt 4 conda package in Python 3.6
ccordoba12 May 5, 2017
458bef8
Testing: Skip another test on Python 3 because it's failing
ccordoba12 May 6, 2017
7881f5c
Testing: Add a script to test PySide2
ccordoba12 May 8, 2017
2066fb9
Fix setting QT_API for PySide2
ccordoba12 May 8, 2017
d5dad47
Testing: Make tests work with PySide2
ccordoba12 May 8, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ lib64
# Other files
toread.md
.chache
.idea/

# End of File
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ install:
- "powershell ci-helpers/appveyor/install-miniconda.ps1"
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- "activate test"
- "python setup.py install"
- "python setup.py develop"

# Not a .NET project, we build in the install step instead
build: false
Expand Down
19 changes: 19 additions & 0 deletions ci/test-pyqt4.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

export PATH="$HOME/miniconda/bin:$PATH"
source activate test

# We use container 3 to test with pip and pyqt5
if [ "$CIRCLE_NODE_INDEX" = "3" ]; then
exit 0
else
conda remove -q qt pyqt
conda install -q -c conda-forge qt=4.* pyqt=4.*
fi

python qtpy/tests/runtests.py

# Force quitting if exit status of runtests.py was not 0
if [ $? -ne 0 ]; then
exit 1
fi
18 changes: 18 additions & 0 deletions ci/test-pyqt5.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

export PATH="$HOME/miniconda/bin:$PATH"
source activate test

# We use container 3 to test with pip
if [ "$CIRCLE_NODE_INDEX" != "3" ]; then
conda install -q qt=5.* pyqt=5.*
else
pip install -q pyqt5
fi

python qtpy/tests/runtests.py

# Force quitting if exit status of runtests.py was not 0
if [ $? -ne 0 ]; then
exit 1
fi
19 changes: 19 additions & 0 deletions ci/test-pyside.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

export PATH="$HOME/miniconda/bin:$PATH"
source activate test

# We use container 3 to test with pip and pyqt5
if [ "$CIRCLE_NODE_INDEX" = "3" ]; then
exit 0
else
conda remove -q qt pyqt
conda install -q -c conda-forge qt=4.* pyside
fi

python qtpy/tests/runtests.py

# Force quitting if exit status of runtests.py was not 0
if [ $? -ne 0 ]; then
exit 1
fi
35 changes: 35 additions & 0 deletions ci/test-pyside2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

export PATH="$HOME/miniconda/bin:$PATH"
source activate test

# Download PySide2 wheel
wget -q https://bintray.com/fredrikaverpil/pyside2-wheels/download_file?file_path=ubuntu14.04%2FPySide2-2.0.0.dev0-cp27-none-linux_x86_64.whl -O PySide2-2.0.0.dev0-cp27-none-linux_x86_64.whl

# We only use container 0 for PySide2
if [ "$CIRCLE_NODE_INDEX" = "0" ]; then
conda remove -q qt pyqt
pip install PySide2-2.0.0.dev0-cp27-none-linux_x86_64.whl
else
exit 0
fi

# Make symlinks for Qt libraries (else imports fail)
pushd "$HOME/miniconda/envs/test/lib/python2.7/site-packages/PySide2/"

for file in `ls Qt*x86_64-linux-gnu.so`
do
symlink=${file%.x86_64-linux-gnu.so}.so
ln -s $file $symlink
done

popd

python qtpy/tests/runtests.py

# Force quitting if exit status of runtests.py was not 0
if [ $? -ne 0 ]; then
exit 1
fi

pip uninstall -y -q pyside2
32 changes: 18 additions & 14 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@ machine:
# Used by test scripts
TEST_CI: "True"
# Python versions to test (Maximum of 4 different versions for now)
PY_VERSIONS: "3.5 3.4 2.7"
PY_VERSIONS: "2.7 3.5 3.6 3.5"
# For Coveralls
COVERALLS_REPO_TOKEN: xh75EzxFFMoTEyNPo3wXxXv8OVkul3eE5
# Used by astropy-ci helpers
TRAVIS_OS_NAME: "linux"
CONDA_DEPENDENCIES: "pytest pytest-cov"
PIP_DEPENDENCIES: "coveralls"

dependencies:
pre:
# We need this for QtMultimedia in 5.8
- sudo apt-get install libpulse-dev
# For PySide2
- sudo apt-get autoremove libqt5*
- sudo apt-get install apt -y
- sudo add-apt-repository -y ppa:beineri/opt-qt562-trusty
- sudo apt-get update -y; true
- sudo apt-get install -q qt56webengine
- sudo rsync -a /opt/qt56/ /usr/

override:
# First convert PY_VERSIONS to an array and then select the Python version
# based on the CIRCLE_NODE_INDEX
Expand All @@ -22,25 +34,17 @@ dependencies:
source ci-helpers/travis/setup_conda_$TRAVIS_OS_NAME.sh &&
export PATH="$HOME/miniconda/bin:$PATH" &&
source activate test &&
conda install -q ciocheck -c spyder-ide &&
python setup.py develop;

test:
override:
# Check style
- export PATH="$HOME/miniconda/bin:$PATH" && source activate test && ciocheck qtpy: # note the colon
- ./ci/test-pyqt5.sh: # note the colon
parallel: true
- ./ci/test-pyside2.sh: # note the colon
parallel: true
# Check PyQt5
- export PATH="$HOME/miniconda/bin:$PATH" && source activate test && conda install -q qt=5.* pyqt=5.* && python qtpy/tests/runtests.py: # note the colon
- ./ci/test-pyqt4.sh: # note the colon
parallel: true
# Check PySide2
# - export PATH="$HOME/miniconda/bin:$PATH" && source activate test && conda install -q qt=5.* pyside2 && python qtpy/tests/runtests.py: # note the colon
# parallel: true
# Check PyQt4
- export PATH="$HOME/miniconda/bin:$PATH" && source activate test && conda install -q qt=4.* pyqt=4.* && python qtpy/tests/runtests.py: # note the colon
- ./ci/test-pyside.sh: # note the colon
parallel: true
- export PATH="$HOME/miniconda/bin:$PATH" && source activate test && coveralls: # note the colon
parallel: true
# Check Pyside
#- export PATH="$HOME/miniconda/bin:$PATH" && source activate test && conda remove -q qt pyqt && conda install -c conda-forge qt=4.* pyside && python qtpy/tests/runtests.py: # note the colon
# parallel: true
4 changes: 3 additions & 1 deletion qtpy/QtCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Provides QtCore classes and functions.
"""

from . import PYQT5, PYQT4, PYSIDE, PythonQtError
from . import PYQT5, PYSIDE2, PYQT4, PYSIDE, PythonQtError


if PYQT5:
Expand All @@ -22,6 +22,8 @@

# Those are imported from `import *`
del pyqtSignal, pyqtSlot, pyqtProperty, QT_VERSION_STR
elif PYSIDE2:
from PySide2.QtCore import *
elif PYQT4:
from PyQt4.QtCore import *
# Those are things we inherited from Spyder that fix crazy crashes under
Expand Down
4 changes: 3 additions & 1 deletion qtpy/QtGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
the ``PyQt5.QtGui`` module.
"""

from . import PYQT5, PYQT4, PYSIDE, PythonQtError
from . import PYQT5, PYQT4, PYSIDE, PYSIDE2, PythonQtError


if PYQT5:
from PyQt5.QtGui import *
elif PYSIDE2:
from PySide2.QtGui import *
elif PYQT4:
try:
# Older versions of PyQt4 do not provide these
Expand Down
5 changes: 5 additions & 0 deletions qtpy/QtMultimedia.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
from . import PYQT5
from . import PYQT4
from . import PYSIDE
from . import PYSIDE2


if PYQT5:
from PyQt5.QtMultimedia import *
elif PYSIDE2:
# Current wheels don't have this module
# from PySide2.QtMultimedia import *
pass
elif PYQT4:
from PyQt4.QtMultimedia import *
from PyQt4.QtGui import QSound
Expand Down
4 changes: 3 additions & 1 deletion qtpy/QtNetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
Provides QtNetwork classes and functions.
"""

from . import PYQT5, PYQT4, PYSIDE, PythonQtError
from . import PYQT5, PYSIDE2, PYQT4, PYSIDE, PythonQtError


if PYQT5:
from PyQt5.QtNetwork import *
elif PYSIDE2:
from PySide2.QtNetwork import *
elif PYQT4:
from PyQt4.QtNetwork import *
elif PYSIDE:
Expand Down
4 changes: 3 additions & 1 deletion qtpy/QtPrintSupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
Provides QtPrintSupport classes and functions.
"""

from . import PYQT5, PYQT4, PYSIDE, PythonQtError
from . import PYQT5, PYQT4,PYSIDE2, PYSIDE, PythonQtError


if PYQT5:
from PyQt5.QtPrintSupport import *
elif PYSIDE2:
from PySide2.QtPrintSupport import *
elif PYQT4:
from PyQt4.QtGui import (QAbstractPrintDialog, QPageSetupDialog,
QPrintDialog, QPrintEngine, QPrintPreviewDialog,
Expand Down
6 changes: 4 additions & 2 deletions qtpy/QtSvg.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
"""Provides QtSvg classes and functions."""

# Local imports
from . import PYQT4, PYQT5, PYSIDE, PythonQtError
from . import PYQT4, PYSIDE2, PYQT5, PYSIDE, PythonQtError

if PYQT5:
from PyQt5.QtSvg import *
elif PYSIDE2:
from PySide2.QtSvg import *
elif PYQT4:
from PyQt4.QtSvg import *
elif PYSIDE:
from PySide.QtSvg import *
else:
raise PythonQtError('No Qt bindings could be found')

del PYQT4, PYQT5, PYSIDE
del PYQT4, PYQT5, PYSIDE, PYSIDE2
4 changes: 3 additions & 1 deletion qtpy/QtTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
Provides QtTest and functions
"""

from . import PYQT5, PYQT4, PYSIDE, PythonQtError
from . import PYQT5,PYSIDE2, PYQT4, PYSIDE, PythonQtError


if PYQT5:
from PyQt5.QtTest import QTest
elif PYSIDE2:
from PySide2.QtTest import QTest
elif PYQT4:
from PyQt4.QtTest import QTest as OldQTest

Expand Down
14 changes: 13 additions & 1 deletion qtpy/QtWebEngineWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Provides QtWebEngineWidgets classes and functions.
"""

from . import PYQT5, PYQT4, PYSIDE, PythonQtError
from . import PYQT5,PYSIDE2, PYQT4, PYSIDE, PythonQtError


# To test if we are using WebEngine or WebKit
Expand All @@ -27,6 +27,18 @@
from PyQt5.QtWebKitWidgets import QWebView as QWebEngineView
from PyQt5.QtWebKit import QWebSettings as QWebEngineSettings
WEBENGINE = False
elif PYSIDE2:
try:
from PySide2.QtWebEngineWidgets import QWebEnginePage
from PySide2.QtWebEngineWidgets import QWebEngineView
# Current PySide2 wheels seem to be missing this.
# from PySide2.QtWebEngineWidgets import QWebEngineSettings
except ImportError:
from PySide2.QtWebKitWidgets import QWebPage as QWebEnginePage
from PySide2.QtWebKitWidgets import QWebView as QWebEngineView
# Current PySide2 wheels seem to be missing this.
# from PySide2.QtWebKit import QWebSettings as QWebEngineSettings
WEBENGINE = False
elif PYQT4:
from PyQt4.QtWebKit import QWebPage as QWebEnginePage
from PyQt4.QtWebKit import QWebView as QWebEngineView
Expand Down
4 changes: 3 additions & 1 deletion qtpy/QtWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
were the ``PyQt5.QtWidgets`` module.
"""

from . import PYQT5, PYQT4, PYSIDE, PythonQtError
from . import PYQT5, PYSIDE2, PYQT4, PYSIDE, PythonQtError
from ._patch.qcombobox import patch_qcombobox
from ._patch.qheaderview import introduce_renamed_methods_qheaderview


if PYQT5:
from PyQt5.QtWidgets import *
elif PYSIDE2:
from PySide2.QtWidgets import *
elif PYQT4:
from PyQt4.QtGui import *
QStyleOptionViewItem = QStyleOptionViewItemV4
Expand Down