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 missing imports in QtOpenGL #307

Merged
merged 6 commits into from
Jan 12, 2022

Conversation

renefritze
Copy link
Contributor

No description provided.

@dalthviz dalthviz changed the title add missing import in QtOpenGl PR: Add missing imports in QtOpenGl Dec 23, 2021
@dalthviz dalthviz added this to the v2.0.1 milestone Dec 23, 2021
@dalthviz dalthviz changed the title PR: Add missing imports in QtOpenGl PR: Add missing imports in QtOpenGL Dec 23, 2021
Copy link
Member

@dalthviz dalthviz left a comment

Choose a reason for hiding this comment

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

Thank you for helping with this @renefritze ! Could it be possible for you to add a test for this module? Otherwise this LGTM 👍

Let us know!

@renefritze
Copy link
Contributor Author

Thank you for helping with this @renefritze ! Could it be possible for you to add a test for this module? Otherwise this LGTM +1

Let us know!

Sure thing. Happy to help. Fix was basically shorter than any bug report could be 😉

@renefritze
Copy link
Contributor Author

Ofc now there's a test failure after I just added all the stuff from the Pyside2 docs to check.
The failures seem to be different across jobs and setups. And this for example contradicts the docs, I guess?

@dalthviz
Copy link
Member

Checking, seems like a couple of things are happening:

For PyQt5 the mayority of classes related with OpenGL are located in QtGui. For compatibility I think we should add them at QtOpenGL.py with something like this under the PYQT5 validation:

from PyQt5.QtGui import QOpenGLBuffer, QOpenGLFramebufferObject, QOpenGLFramebufferObjectFormat, QOpenGLShader, QOpenGLShaderProgram

In the case of PyQt6 there are more modules by default on QtOpenGL but still some are in QtGui. Something like this under the PYQT6 validation should help:

from PyQt6.QtGui import QOpenGLContext

Something similar happens with PySide6. Something like this under the PYSIDE6 validation should help:

from PySide6.QtGui import QOpenGLContext

Beside that seems like for for PySide2 the classes don't have as prefix QOpenGL* but QGL*. So for compatibility I think we need to do some aliasing with something like this under the PYSIDE2 validation:

QOpenGLBuffer = QGLBuffer
QOpenGLContext = QGLContext
QOpenGLFormat = QGLFormat
QOpenGLFramebufferObject = QGLFramebufferObject
QOpenGLFramebufferObjectFormat = QGLFramebufferObjectFormat
QOpenGLShader = QGLShader
QOpenGLShaderProgram = QGLShaderProgram

Seems like currently the test are failing for PySide2 because of an uppercase b for QGLFramebufferObject but I think we should test for the QOpenGL* variant of the classes.

Let us know if you need any help with this @renefritze !

@dalthviz
Copy link
Member

Pinging @ccordoba12 and @CAM-Gerlach just in case

@dalthviz dalthviz modified the milestones: v2.0.1, v2.1.0 Dec 23, 2021
@renefritze renefritze force-pushed the fix_missing_imports branch 3 times, most recently from deceed0 to 7ce7668 Compare December 27, 2021 14:11
@renefritze
Copy link
Contributor Author

I'm not sure this is what you had in mind, @dalthviz, but aside from an unrelated error at least the tests are now green.

@pijyoi
Copy link

pijyoi commented Jan 1, 2022

Beside that seems like for for PySide2 the classes don't have as prefix QOpenGL* but QGL*. So for compatibility I think we need to do some aliasing with something like this under the PYSIDE2 validation:

QOpenGLBuffer = QGLBuffer

I don't think QOpenGL* and QGL* are interchangeable. The QGL* classes are Qt4, provided in Qt5 for backwards compatibility. The QOpenGL* classes are available in both Qt5 and Qt6.

In [5]: from PySide2 import QtGui

In [6]: [x for x in dir(QtGui) if x.startswith('QOpenGL')]
Out[6]:
['QOpenGLBuffer',
 'QOpenGLContext',
 'QOpenGLContextGroup',
 'QOpenGLDebugLogger',
 'QOpenGLDebugMessage',
 'QOpenGLExtraFunctions',
 'QOpenGLFramebufferObject',
 'QOpenGLFramebufferObjectFormat',
 'QOpenGLFunctions',
 'QOpenGLPixelTransferOptions',
 'QOpenGLShader',
 'QOpenGLShaderProgram',
 'QOpenGLTexture',
 'QOpenGLTextureBlitter',
 'QOpenGLTimeMonitor',
 'QOpenGLTimerQuery',
 'QOpenGLVersionProfile',
 'QOpenGLVertexArrayObject',
 'QOpenGLWindow']

@dalthviz dalthviz modified the milestones: v2.1.0, v2.0.1 Jan 10, 2022
@dalthviz
Copy link
Member

I don't think QOpenGL* and QGL* are interchangeable. The QGL* classes are Qt4, provided in Qt5 for backwards compatibility. The QOpenGL* classes are available in both Qt5 and Qt6.

Thank you @pijyoi for the feedback! Reading a little bit more the qt docs I think you are totally right!

I would say that then what we need to do is to add some imports inside qtpy/QtGui.py for PYQT6 and PYSIDE6 importing QtOpenGL so something like :

from PyQt6.QtOpenGL import *
from PySide6.QtOpenGL import *

On the other hand, inside qtpy/QtOpenGL.py to keep things simetric we could under PYSIDE2 add the missing QtGui imports (as was done for PYQT5). So something like:

from PySide2.QtGui import QOpenGLBuffer, QOpenGLFramebufferObject, QOpenGLFramebufferObjectFormat, QOpenGLShader, QOpenGLShaderProgram

And don't do the aliasing for QOpenGL* = QGL* and remove the QOpenGlContext import being done inside PYQT6

For the test, I would say that we need to only check for the QOpenGL classes available in Qt5 and Qt6

Pinging @ccordoba12 and @CAM-Gerlach just in case

Also, thank you so much @renefritze for all the help with this and sorry for the incorrect initial guidance for the changes!

@CAM-Gerlach
Copy link
Member

For what its worth, given your expertise is much greater in this area, seems sensible to me!

@renefritze
Copy link
Contributor Author

Just to make sure I understood what's to be tested correctly.

def get(mod):
    ret = []
    for sub in ('QtGui', 'QtOpenGL'):
        ret.extend([f for f in dir(getattr(mod, sub)) if f.startswith('QOpenGL')])
    return set(ret)

import PySide2, PyQt5, PySide6, PyQt6
sets = [get(PySide2), get(PySide6), get(PyQt5), get(PyQt6)]
common_opengl_classes = sets[0].intersection(*sets[1:])

I've added a test for everything in common_opengl_classes and then adjusted what needs to be pulled into qtpy.QOpenGL accordingly

Copy link
Member

@dalthviz dalthviz left a comment

Choose a reason for hiding this comment

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

Thank you so much again @renefritze for your help and patience !

Yep the common_opengl_classes is what I think needs to be tested. Also, I left a suggestion to fix the failing tests (there is a missing a change in an import which is using PySide6 instead of PyQt6 in qtpy/QtOpenGL.py), otherwise this LGTM 👍

qtpy/QtOpenGL.py Outdated Show resolved Hide resolved
Co-authored-by: Daniel Althviz Moré <d.althviz10@uniandes.edu.co>
@renefritze
Copy link
Contributor Author

You're very welcome @dalthviz. I hope this can make its way into a bugfix release soon then.

@dalthviz dalthviz merged commit c7365b2 into spyder-ide:master Jan 12, 2022
@renefritze renefritze deleted the fix_missing_imports branch January 12, 2022 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants