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

Feat/qtpy #61

Merged
merged 23 commits into from Oct 16, 2020
Merged

Feat/qtpy #61

merged 23 commits into from Oct 16, 2020

Conversation

nicobako
Copy link
Contributor

@nicobako nicobako commented Oct 7, 2020

This is a continuation of @GuillaumeFavelier 's work from #12 . I have updated his work with the latest master branch from pyvista, which had some merge conflicts and required replacing pyqt5 with qtpy in a few additional places.

I also updated the test files to use qtpy instead of pyqt5. I'm not exactly sure how your CI works, but I imagine that you will have to set the QT_API environment variable to inform qtpy which Qt Binding you want to use. I'm not sure if you want your CI to test multiple QT bindings, or just one... I can definitely work on this if you let me know which Qt Bindings you want to test.

Also, I replaced the pyqt5 requirement in the install_requires with QtPy. This makes the user responsible for installing the Qt bindings of their choice, and makes pyvistaqt agnostic of the specific Qt bindings.

Another thing that we must still do is update the documentation by replacing any usage of pyqt5 with qtpy. I wasn't exactly sure how you wanted to treat that, so I haven't done it yet.
Users will have to use qtpy instead, which has the additional step of setting the QT_API environment variable. From what I understand, this must be set before qtpy is imported. I can easily update the docs if you let me know what kind of guidance you want to give to users.

So, in summary, things that still need to be done are:

  • Update tests to set QT_API environment variable
    • Should probably test multiple Qt Bindings (e.g. pyqt5, PySide2, etc.)
  • Update docs to use qtpy instead of pyqt5
    • Update examples in usage.rst
    • Maybe update example in index.rst?
    • Update license info in index.rst

@codecov
Copy link

codecov bot commented Oct 7, 2020

Codecov Report

Merging #61 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #61      +/-   ##
==========================================
- Coverage   97.95%   97.95%   -0.01%     
==========================================
  Files           6        6              
  Lines         539      538       -1     
==========================================
- Hits          528      527       -1     
  Misses         11       11              

Copy link
Contributor

@GuillaumeFavelier GuillaumeFavelier left a comment

Choose a reason for hiding this comment

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

I'm not sure of the issue with MacOS configs on Azure though. It seems related to the changes to setup.py.

pyvistaqt/counter.py Show resolved Hide resolved
pyvistaqt/counter.py Show resolved Hide resolved
pyvistaqt/plotting.py Outdated Show resolved Hide resolved
@GuillaumeFavelier GuillaumeFavelier added the enhancement New feature or request label Oct 8, 2020
@nicobako
Copy link
Contributor Author

nicobako commented Oct 8, 2020

Yeah, @GuillaumeFavelier. This can easily be fixed by ensuring that a Qt Python binding is installed on the test machine, but I'm not sure exactly how you want to do that. Switching to qtpy means that it is now up to the user to have a qtpy-compatible Qt Python binding installed. In my opinion, it no longer makes sense to add a specific Qt Python binding in the install requires, since that is now up to the user.

I do have opinions on how these types of issues could be solved, but, since they lead to significant changes in how people interact with pyvistaqt, I want sure if you wanted me to make those changes or not.

@GuillaumeFavelier
Copy link
Contributor

Historically, PyQt5 has been the default Qt binding for pyvistaqt and more importantly, this is the only Qt binding tested at the moment. I would not consider removing it until at least one other Qt binding is tested. So I don't think we are ready yet to entirely change this.

In my opinon, a "transition time" (one major version?) where PyQt5 would remains with QtPy is necessary instead of a drastic change.

Does it make sense?

Also, what are your thoughts about this @pyvista/developers ?

@nicobako
Copy link
Contributor Author

nicobako commented Oct 9, 2020

In my opinon, a "transition time" (one major version?) where PyQt5 would remains with QtPy is necessary instead of a drastic change.

Does it make sense?

This makes sense to me. That way, when users pip install pyvistaqt, they still get the same functionality they are used to, but can start experimenting with different Qt bindings on their own.

@nicobako
Copy link
Contributor Author

@GuillaumeFavelier , you'll see that I made quite a few changes since your last review. Most notably, updated the docs, and formatting issues, fixed the call to pydoctest in the makefile.

The only issue left is that the docs are still not building. I'm not sure why, but maybe you understand the error message...

@GuillaumeFavelier
Copy link
Contributor

you'll see that I made quite a few changes since your last review. Most notably, updated the docs, and formatting issues, fixed the call to pydoctest in the makefile.

Those changes are welcome, thank you @nicobako 🙏

The only issue left is that the docs are still not building. I'm not sure why, but maybe you understand the error message...

I'll see what I can do

@GuillaumeFavelier
Copy link
Contributor

I'm sure I saw this error before somewhere but I can't recall exactly...

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Fatal Python error: Aborted

Current thread 0x00007faf5ef7e700 (most recent call first):
  File "/home/vsts/work/1/s/pyvistaqt/plotting.py", line 600 in __init__
  File "<doctest default[2]>", line 1 in <module>
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/doctest.py", line 1337 in __run
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/doctest.py", line 1483 in run
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/sphinx/ext/doctest.py", line 554 in test_group
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/sphinx/ext/doctest.py", line 470 in test_doc
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/sphinx/ext/doctest.py", line 366 in write
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 361 in build
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 299 in build_update
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/sphinx/application.py", line 348 in build
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/sphinx/cmd/build.py", line 280 in build_main
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/sphinx/cmd/make_mode.py", line 155 in run_generic_build
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/sphinx/cmd/make_mode.py", line 167 in run_make_mode
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/sphinx/cmd/build.py", line 199 in make_main
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/sphinx/cmd/build.py", line 292 in main
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/sphinx/__main__.py", line 15 in <module>
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/runpy.py", line 85 in _run_code
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/runpy.py", line 193 in _run_module_as_main
Aborted (core dumped)

Is it related to the headless display? Any idea @pyvista/developers
I would rather not hack something while being in the dark 😅

@larsoner
Copy link
Contributor

There are a slew of Linux deps that you need to use the builtin xcb (PyQt5 used to bake this into their lib IIRC then they changed), for example see what we install on CircleCI for MNE

https://github.com/mne-tools/mne-python/blob/master/.circleci/config.yml#L58-L59

IIRC that big long line is what's needed for this not to complain. These were identified by doing LD_DEBUG=libs ... and then seeing what wasn't found while on an interactive SSH CircleCI session (though in theory you could do the same locally just by pulling their docker image).

@GuillaumeFavelier
Copy link
Contributor

Many thanks for the swift answer! I will try with that then 👍

@GuillaumeFavelier
Copy link
Contributor

Alright @nicobako, I pushed a few commits and the doc is building now 👍
Let us know when it's okay on your end.

Useful material for future reference: https://doc.qt.io/qt-5/linux-requirements.html

@nicobako
Copy link
Contributor Author

Thanks @GuillaumeFavelier . I think it's all good on my end. As long as you guys are happy with the changes I made to the documentation (.rst files), then I think this is ready!

Copy link
Contributor

@GuillaumeFavelier GuillaumeFavelier left a comment

Choose a reason for hiding this comment

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

LGTM and personally, I like the changes to the *.rst files but let's ask the other @pyvista/developers what they think to be sure.

Copy link
Contributor

@larsoner larsoner left a comment

Choose a reason for hiding this comment

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

Just a question/suggestion about deprecation, otherwise LGTM

Comment on lines +92 to +98
Historically, ``pyvistaqt`` has used ``pyqt5``, which is subject
to the GPL license. See details at
`Riverbank License FAQ <https://www.riverbankcomputing.com/commercial/license-faq>`_.

``pyvistaqt`` is transitioning to using ``qtpy``

> QtPy is a small abstraction layer that lets you write applications using a single API call to either PyQt or PySide.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the leading >? I would make this more compact like:

Suggested change
Historically, ``pyvistaqt`` has used ``pyqt5``, which is subject
to the GPL license. See details at
`Riverbank License FAQ <https://www.riverbankcomputing.com/commercial/license-faq>`_.
``pyvistaqt`` is transitioning to using ``qtpy``
> QtPy is a small abstraction layer that lets you write applications using a single API call to either PyQt or PySide.
Historically, ``pyvistaqt`` has used ``pyqt5``, which is subject
to the GPL license. See details at
`Riverbank License FAQ <https://www.riverbankcomputing.com/commercial/license-faq>`_. ``pyvistaqt`` now uses QtPy if present, and will require it after version 0.3. QtPy is a small abstraction layer that lets you write applications using a single API call to either PyQt or PySide (which has a LGPL license).

The wording about being required or not should be adjusted based on whether or not there is actually going to be a deprecation period.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The leading > is because it's a quote from the qtpy docs... But I'm open to changing it to something that looks nicer.

from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot
"""This module contains a basic Qt-compatible counter class."""

from qtpy.QtCore import QObject, Signal, Slot
Copy link
Contributor

Choose a reason for hiding this comment

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

This will immediately break any pyvistaqt code without deprecation. We colud make a small compatibility layer just by making a little ._qtpy file that contains:

try:
    from qtpy import QtCore
except ImportError:
    warn('qtpy not found; falling back to PyQt5. qtpy will be required in pyvistaqt 0.4')
    from PyQt5.QtCore import ...
else:
    from qtpy import ...

And then in this file do:

Suggested change
from qtpy.QtCore import QObject, Signal, Slot
from ._qtpy.QtCore import QObject, Signal, Slot

And once we cut version 0.3, we can revert the from ._qtpy import ... lines to just be from qtpy import ...

But maybe this is overkill since pyvistaqt is still relatively new. Up to the main pyvista devs I guess...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the core developers think there needs to be a deprecation period, then this would be a good solution. I'm open to this.

Copy link
Member

Choose a reason for hiding this comment

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

I think just going ahead without the depreciation works. Users can always downgrade to an older version, and adding in a depreciation is a bit of a pain. Plus, installing qtpy should be in the setup.py, so it will be included upon install/upgrade.

We can always give a more descriptive error on import if we wish, but it's a bit of extra work making it backwards compatible and adding a depreciation warning as well.

@larsoner larsoner merged commit d960fb7 into pyvista:master Oct 16, 2020
@larsoner
Copy link
Contributor

Okay, good enough for me then!

@nicobako
Copy link
Contributor Author

Thank you @GuillaumeFavelier and @larsoner for your help! I'm really glad to see this merged into pyvistaqt!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants