Skip to content

example app now works with Qt4 and Python2 again#1302

Merged
j9ac9k merged 11 commits intopyqtgraph:masterfrom
j9ac9k:fix-1301-example-app-py2
Oct 19, 2020
Merged

example app now works with Qt4 and Python2 again#1302
j9ac9k merged 11 commits intopyqtgraph:masterfrom
j9ac9k:fix-1301-example-app-py2

Conversation

@j9ac9k
Copy link
Copy Markdown
Member

@j9ac9k j9ac9k commented Jul 8, 2020

This PR fixes an issue introduced in #1124 where the example application was not compatible with Python2 (due to a python3 method of calling super()) and Qt4 (due to depending on paletteChanged signal which only exists in Qt5).

Fixes #1301

@ksunden
Copy link
Copy Markdown
Contributor

ksunden commented Jul 8, 2020

Is there a reason our tests didn't catch this? We do run the examples in the test suite, pretty sure.

@j9ac9k
Copy link
Copy Markdown
Member Author

j9ac9k commented Jul 8, 2020

Our test site runs the examples, but not the example application funny enough.

Should I look to add launching the example application as part of the test suite?

Also that CI failure, I am able to intermittently reproduce locally, but not reliably.

@j9ac9k
Copy link
Copy Markdown
Member Author

j9ac9k commented Jul 8, 2020

Been thinking, I think using hasattr is the wrong way to go about this, I should check with if QT_LIB in ['PyQt4', 'PySide']: which is how the rest of the library does it... will update the PR ...I'll see about adding the example app to the test suite as well.

@j9ac9k
Copy link
Copy Markdown
Member Author

j9ac9k commented Jul 8, 2020

Hmm getting the example app to run as part of the test suite is tricky haha

@j9ac9k j9ac9k force-pushed the fix-1301-example-app-py2 branch from 98ea370 to 9dd5372 Compare July 8, 2020 19:51
@j9ac9k
Copy link
Copy Markdown
Member Author

j9ac9k commented Jul 8, 2020

@ksunden can you think of a way we can add the example app as part of the test suite? I just added it to https://github.com/pyqtgraph/pyqtgraph/blob/master/examples/utils.py#L93 where instead of files = [] to files = [("Example App", "__main__.py")] but that just ran successfully (When it should have blown up).

@j9ac9k
Copy link
Copy Markdown
Member Author

j9ac9k commented Jul 8, 2020

whoops, accidentally pushed the wrong commit; going to put this in draft commit form until ready...

@j9ac9k j9ac9k marked this pull request as draft July 8, 2020 22:47
@j9ac9k j9ac9k force-pushed the fix-1301-example-app-py2 branch 4 times, most recently from 51d0f59 to 8634834 Compare July 9, 2020 04:24
@j9ac9k j9ac9k marked this pull request as ready for review July 9, 2020 15:52
@j9ac9k j9ac9k force-pushed the fix-1301-example-app-py2 branch from 8634834 to fff6567 Compare October 17, 2020 15:34
@j9ac9k j9ac9k force-pushed the fix-1301-example-app-py2 branch from 159f828 to 18b015a Compare October 18, 2020 06:01
@j9ac9k
Copy link
Copy Markdown
Member Author

j9ac9k commented Oct 18, 2020

While this branch now works for having the example application launch on Python2 successfully, I want to try and minimize the warnings on python3 when launching the application, specifically....

/Users/ogi/.zinit/plugins/pyenv---pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/runpy.py:127: RuntimeWarning: 'pyqtgraph.examples.__main__' found in sys.modules after import of package 'pyqtgraph.examples', but prior to execution of 'pyqtgraph.examples.__main__'; this may result in unpredictable behaviour
  warn(RuntimeWarning(msg))
qt.qpa.fonts: Populating font family aliases took 291 ms. Replace uses of missing font family "FreeMono" with one that exists to avoid this cost.

I get this warning when launching examples via python -m pyqtgraph.examples, but I do not get it when running

import pyqtgraph.examples
pyqtgraph.examples.run()

or

$ python examples

EDIT:

lastly, when installing pyqtgraph in editable mode, running python -m pyqtgraph.examples (from not within the git repo) will not run.

@j9ac9k
Copy link
Copy Markdown
Member Author

j9ac9k commented Oct 18, 2020

Scary warning no longer comes up; still want python -m pyqtgraph.examples to work when installing in editable mode (pip install -e .) as well as the font warning:

qt.qpa.fonts: Populating font family aliases took 299 ms. Replace uses of missing font family "FreeMono" with one that exists to avoid this cost.

@j9ac9k
Copy link
Copy Markdown
Member Author

j9ac9k commented Oct 18, 2020

Apparently running examples in editable mode is related to a long-standing setuptools issue: pypa/setuptools#230

We can work around this by changing the directory structure, but I don't think we actually want to do that for the additional functionality... last issue is fixing the font warning...

@j9ac9k j9ac9k force-pushed the fix-1301-example-app-py2 branch from 8a51295 to c4ad4ae Compare October 19, 2020 05:10
@j9ac9k
Copy link
Copy Markdown
Member Author

j9ac9k commented Oct 19, 2020

Switched font family to Courier New, which is available everywhere by default, had to regenerate the uic templates (always annoying)...

Did last bit of code cleanup, I think this PR is ready for merging.

@j9ac9k
Copy link
Copy Markdown
Member Author

j9ac9k commented Oct 19, 2020

just kidding, still not ready for merging, test app didn't actually get run...

@j9ac9k
Copy link
Copy Markdown
Member Author

j9ac9k commented Oct 19, 2020

ok, now the test application is tested as part of the test suite.

@j9ac9k j9ac9k force-pushed the fix-1301-example-app-py2 branch from 6d91dd0 to 05ee86c Compare October 19, 2020 16:28
@j9ac9k
Copy link
Copy Markdown
Member Author

j9ac9k commented Oct 19, 2020

ok now that docs/CI and so on work, I think I'll just merge this guy...

@j9ac9k j9ac9k merged commit 7e57e07 into pyqtgraph:master Oct 19, 2020
@j9ac9k j9ac9k deleted the fix-1301-example-app-py2 branch October 19, 2020 18:51
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.

Example Application Cannot be Launched with Python2 Environment

3 participants