Skip to content

Qt5 v3 - #264

Merged
corranwebster merged 25 commits into
masterfrom
feature/qt5-v3
Mar 24, 2017
Merged

Qt5 v3#264
corranwebster merged 25 commits into
masterfrom
feature/qt5-v3

Conversation

@corranwebster

@corranwebster corranwebster commented Mar 10, 2017 •

Copy link
Copy Markdown
Contributor

This is another attempt at Qt5 compatibility. Following #256 we should have removed all old-style signals and slots, so at the object level, we have compatibility with Qt5. This PR takes a different approach to the previous PRs like #171 and is inspired by a comment by @pankajp there.

This PR tries to make the PyQt5 API compatible with PyQt4, so that code which depends on pyface.qt does not need to be modified. We may, at some future point, add a pyface.qt5 module or something similar which attempts forward compatibility instead of backwards compatibility.

To do:

  • CI integration for Qt5. This is still a blocker for merging.

@codecov-io

codecov-io commented Mar 10, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #264 into master will decrease coverage by 2.49%.
The diff coverage is 24.19%.

@@           Coverage Diff            @@
##           master    #264     +/-   ##
========================================
- Coverage    35.7%   33.2%   -2.5%     
========================================
  Files         454     454             
  Lines       25343   25384     +41     
  Branches     3805    3818     +13     
========================================
- Hits         9048    8429    -619     
- Misses      15890   16577    +687     
+ Partials      405     378     -27
Impacted Files Coverage Δ
pyface/__init__.py 71.42% <ø> (ø) ⬆️
pyface/qt/QtWebKit.py 0% <0%> (ø) ⬆️
pyface/qt/QtOpenGL.py 0% <0%> (ø) ⬆️
pyface/qt/QtSvg.py 66.66% <0%> (-33.34%) ⬇️
pyface/qt/QtGui.py 50% <0%> (-50%) ⬇️
pyface/qt/QtNetwork.py 0% <0%> (ø) ⬆️
pyface/qt/QtScript.py 0% <0%> (ø) ⬆️
pyface/qt/QtCore.py 54.16% <0%> (-32.5%) ⬇️
pyface/qt/QtTest.py 66.66% <0%> (-33.34%) ⬇️
pyface/ui/qt4/directory_dialog.py 92.59% <100%> (ø) ⬆️
... and 34 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e499888...5d8d73f. Read the comment docs.

@pankajp

pankajp commented Mar 10, 2017 •

Copy link
Copy Markdown
Contributor

For more api changes you can take inspiration from https://github.com/rwarren/qt_backport https://github.com/rwarren/qt_backport/blob/master/qt_backport/qt5_backport.py
Also, imho we should directly use the qtpy module for using qt5 style code instead of adding another pyface.qt5 abstraction

@pankajp

pankajp commented Mar 10, 2017 •

Copy link
Copy Markdown
Contributor

Thanks for PR @corranwebster . I really think this approach will involve less code and help in gradual move to Qt5.
Btw, i could get pyqt5 tests working on python3 in travis-ci since it now has wheels for linux via the manylinux1 platform tag, except that those wheels do not bind QtWebkit.
https://travis-ci.org/enthought/pyface/jobs/209678577

Addendum: The tests skipped due to segfaults do not segfault on my machine's distro supplied pyqt5, but only on the wheels on pypi, i suspect some compilation issue or so, though one segfault in traitsui table_editor was definitely buggy code: enthought/traitsui@ae05ee9

@corranwebster

Copy link
Copy Markdown
Contributor Author

Qt5 tests are running, but failing with segfaults as noted by @pankajp. Suspicion should fall on the modal dialog testing code first.

Comment thread pyface/toolkit.py Outdated
try:
tk_object = plugin.load()
return tk_object
except ImportError as exc:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could just change this to except ImportError as exception:

Comment thread pyface/toolkit.py Outdated
try:
tk_object = plugin.load()
return tk_object
except ImportError as exc:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could just change this line to except ImportError as exception:

@rkern

rkern commented Mar 10, 2017

Copy link
Copy Markdown
Member

I'm somewhat in favor for moving to something like QtPy to move the Qt4-style organization of classes to Qt5-style in the longer term. But I do recognize that it causes significant short-term work to update all of the existing code.

@corranwebster

Copy link
Copy Markdown
Contributor Author

I think a reasonable proposal (and what I suspect that @pankajp is working towards) is:

  • keep pyface.qt as a Qt4 compatible API so that we don't break all of our existing code that depends on the current API.
  • incrementally move libraries to using a Qt5 compatible API imported from some other location (whether it be QtPy or we roll our own).

I think using QtPy is probably a good idea, but it may make sense to have a shim in Pyface (pyface.qt5?) so we can easily replace it with something else if there is a better alternative or QtPy goes bad in the future.

@corranwebster

Copy link
Copy Markdown
Contributor Author

At this point the segfault is happening on Travis CI, but not the Ubuntu VM I've been using for testing, so it is getting hard to diagnose. I will branch here and play around to see what works.

@pankajp

pankajp commented Mar 22, 2017

Copy link
Copy Markdown
Contributor

@corranwebster I'm happy with the approach of this PR (obviously).

Once it is reviewed I think we should be able to get it merged without blocking on the segfaulting modal dialog tests imho because:

  • This PR is backward compatible with no changes for existing pyside/pyqt4 codebase so no existing users would be impacted
  • The segfault only happens on travisci, and not on both my and your linux machines
  • This would give a nice starting point for users to begin trying out PyQt5 without waiting for everything to be perfect

In a subsequent PR we can add something like pyface.qt5 as you mentioned, so that people can start migrating to qt5 modular api without having to wait on all exiting code being migrated.

Squashed merge of work to fix Qt5 tests.  Currently get _occasional_ segfaults, but neither I or @pankajp can reproduce locally.

* Disable potentially problematic tests on Qt5 to see what happens.
* And disable some more.
* Temporarily remove all non-qt5 tests to streamline work.
* Disable only modal dialog tester tests.
* Remove just 'open_and_wait' tests, leave 'open_and_run' tests.
* Add back just one open_and_wait test.
* Is click_button at fault, or is it open_and_wait?
* Try explicit dialog close.
* Fix tests, minor change to modal dialog tester.
* Add back one confirmation dialog test.
* Skip certain click-based tests on pyqt5.
* Better test failure indicators when subwidget not found.
* Message dialog is similarly suspect on pyqt5.
* Missing import and bad skip message fixed.
* Restore other tests, make qt5 tests allowed failures for now.
@corranwebster

Copy link
Copy Markdown
Contributor Author

@pankajp I've merged in the test fixes branch, making the Qt5 tests "allowed failures" for now, since we still get occasional segfaults which can't be locally reproduced.

Assuming CI runs successfully, do you think this is good to merge into master?

@pankajp pankajp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than a few minor comments. Do the tests still occasionally fail even with the dialog tests skipped?

Comment thread pyface/qt/__init__.py Outdated
break

# does our environment give us a preferred API?
qt_api = os.environ.get('QT_API')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This overwrites qt_api if some qt binding is already imported

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.


def setUp(self):
self.gui = GUI()
GuiTestAssistant.setUp(self)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can super be used if GUITestAssistant was the first base class? I think mixin classes in Python have to be first base class to play nice with inheritance and super

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to do explicit call here, rather than super, because I found it surprising that TestCase didn't implement a trivial setUp and tearDown, so the explicit call flags the future readers of the code that something not usual is happening here.

Comment thread tasks.py
# XXX once pyqt5 is available in EDM, we will want it here
'pyqt5': set(),
# XXX temporary workaround for bug in recent EDM wxpython build on OS X
'wx': {'wxpython' if sys.platform != 'darwin' else 'wxpython==3.0.2.0-3'},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fixed with latest wxpython

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is an issue with the EPD/EDM build of wxpython-3.0.2.0-4 OS X which is still the current version being served. We can remove this if/when there is a 3.0.2.0-5 or higher build for OS X.

@corranwebster

Copy link
Copy Markdown
Contributor Author

And yes, tests still segfault eg. https://travis-ci.org/enthought/pyface/jobs/214604026

I think there may be a problem with the ModalDialogTester which is particularly apparent on Qt5, but @itziakos and I went through it fairly carefully a couple of weeks ago and couldn't find any obvious problems with it. I think the situation we are in is:

  • tests of QMessage based dialogs reliably segfault under Qt5 with the ModalDialogTester
  • other tests of modal dialogs occasionally segfault under Qt5.

But I think that the problem is not with Qt5, but more with the testing infrastructure.

@pankajp

pankajp commented Mar 24, 2017

Copy link
Copy Markdown
Contributor

Ok. LGTM. I'd have preferred letting pyside2 be if it doesn't harm, just in case someone wishes to try (pyside2 unofficial wheels are available on bintray). pyface could be yet another package pyside2 devs can test against

@corranwebster

Copy link
Copy Markdown
Contributor Author

The problem with Pyside2 was that it was first on the list and was not supported, so if it was installed it would be preferentially chosen and then fail (actually, it would try to use original Pyside).

I also see we are back to getting occasional PyQt4 segfaults, but that is a known issue.

@pankajp

pankajp commented Mar 24, 2017

Copy link
Copy Markdown
Contributor

Ok, let it be gone then. What about pyqt4 segfaults, i am not aware. Any pointers to issue/build failures?
And I think this PR is good to go, a great start to Qt5 support.

@corranwebster

Copy link
Copy Markdown
Contributor Author

Yes, various Qt segfaults have been collected here: #251 A lot of them cleared up when we removed old-style signals and slots; I think we had situations where old-style and new style were being used together.

I will merge this in a little bit.

@corranwebster
corranwebster merged commit 5149d7e into master Mar 24, 2017
@corranwebster
corranwebster deleted the feature/qt5-v3 branch March 24, 2017 13:19
This was referenced Mar 24, 2017
@thomasaarholt

Copy link
Copy Markdown

This is great! Over at hyperspy/hyperspy#1323 we're very excited for this, and it seems to be working well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants