From 24621959914e08c9d9dff0baffa00daa9b8bddbb Mon Sep 17 00:00:00 2001 From: Ogi Date: Sat, 8 Jun 2019 18:42:37 -0700 Subject: [PATCH 1/4] Call pytest directly, ignore specific warnings, fix azure template labeling --- azure-test-template.yml | 13 ++++++------- pytest.ini | 10 +++++++++- tox.ini | 17 +++++++++++------ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/azure-test-template.yml b/azure-test-template.yml index 09ba4757..cfdb98dc 100644 --- a/azure-test-template.yml +++ b/azure-test-template.yml @@ -10,7 +10,7 @@ jobs: vmImage: ${{ parameters.vmImage }} strategy: matrix: - Python27-Qt4: + Python27-PyQt4: python.version: '2.7' qt.bindings: "pyqt=4" install.method: "conda" @@ -19,11 +19,11 @@ jobs: qt.bindings: "pyside" install.method: "conda" Python37-PyQt-5.9: - python.version: "3.7" + python.version: "3.6" qt.bindings: "pyqt" install.method: "conda" - Python37-PySide2-5.6: - python.version: "3.7" + Python37-PySide2-5.9: + python.version: "3.6" qt.bindings: "pyside2" install.method: "conda" Python37-PyQt-5.12: @@ -141,10 +141,9 @@ jobs: mkdir -p "$SCREENSHOT_DIR" # echo "If Screenshots are generated, they may be downloaded from:" # echo "https://dev.azure.com/pyqtgraph/pyqtgraph/_apis/build/builds/$(Build.BuildId)/artifacts?artifactName=Screenshots&api-version=5.0" - python -m pytest -sv \ + pytest . -sv \ --junitxml=junit/test-results.xml \ - --cov pyqtgraph --cov-report=xml --cov-report=html \ - --faulthandler-timeout=60 + --cov pyqtgraph --cov-report=xml --cov-report=html displayName: 'Unit tests' env: AZURE: 1 diff --git a/pytest.ini b/pytest.ini index 1f133c35..c2f39a6f 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,3 +1,11 @@ [pytest] - +# use this due to some issues with ndarray reshape errors on CI systems xvfb_colordepth = 24 +addopts = --faulthandler-timeout=15 +filterwarnings = + # comfortable skipping these warnings runtime warnings + # https://stackoverflow.com/questions/40845304/runtimewarning-numpy-dtype-size-changed-may-indicate-binary-incompatibility + ignore:numpy.ufunc size changed, may indicate binary incompatibility.*:RuntimeWarning + # Warnings generated from PyQt5.9 + ignore:*U.*mode is deprecated:DeprecationWarning + ignore:This method will be removed in future versions. Use 'tree.iter\(\)' or 'list\(tree.iter\(\)\)' instead.:PendingDeprecationWarning \ No newline at end of file diff --git a/tox.ini b/tox.ini index 5a86b387..6bbb5566 100644 --- a/tox.ini +++ b/tox.ini @@ -2,19 +2,22 @@ envlist = ; qt 5.12.x py{27,37}-pyside2-pip - ; qt 5.12.x py{35,37}-pyqt5-pip + ; qt 5.9.7 py{27,37}-pyqt5-conda + py{27,37}-pyside2-conda + ; qt 5.6.2 py35-pyqt5-conda - ; qt 5.6.2 - py{27,35,37}-pyside2-conda - ; pyqt 4.11.4 / qt 4.8.7 + ; consider dropping support... + ; py35-pyside2-conda + + ; qt 4.8.7 py{27,36}-pyqt4-conda - ; pyside 1.2.4 / qt 4.8.7 py{27,36}-pyside-conda + [base] deps = pytest @@ -26,10 +29,12 @@ deps = coverage [testenv] +passenv = DISPLAY XAUTHORITY deps= {[base]deps} pytest-cov pytest-xdist + pytest-faulthandler pyside2-pip: pyside2 pyqt5-pip: pyqt5 @@ -43,4 +48,4 @@ conda_channels= conda-forge commands= python -c "import pyqtgraph as pg; pg.systemInfo()" - python -m pytest {posargs:pyqtgraph -svv} + pytest {posargs:.} From 5c44d51d6c2b0e4ae2872af2ea35deb493880754 Mon Sep 17 00:00:00 2001 From: Ogi Date: Sat, 8 Jun 2019 21:55:32 -0700 Subject: [PATCH 2/4] remove resolution test, have display information printed during debug step --- azure-test-template.yml | 25 ++++++++++++++++--------- pyqtgraph/tests/test_display.py | 10 ---------- pyqtgraph/util/get_resolution.py | 16 ++++++++++++---- pytest.ini | 7 +++++-- 4 files changed, 33 insertions(+), 25 deletions(-) delete mode 100644 pyqtgraph/tests/test_display.py diff --git a/azure-test-template.yml b/azure-test-template.yml index cfdb98dc..6a237e99 100644 --- a/azure-test-template.yml +++ b/azure-test-template.yml @@ -10,19 +10,19 @@ jobs: vmImage: ${{ parameters.vmImage }} strategy: matrix: - Python27-PyQt4: + Python27-PyQt4-4.8: python.version: '2.7' qt.bindings: "pyqt=4" install.method: "conda" - Python27-PySide: + Python27-PySide-4.8: python.version: '2.7' qt.bindings: "pyside" install.method: "conda" - Python37-PyQt-5.9: + Python36-PyQt-5.9: python.version: "3.6" qt.bindings: "pyqt" install.method: "conda" - Python37-PySide2-5.9: + Python36-PySide2-5.9: python.version: "3.6" qt.bindings: "pyside2" install.method: "conda" @@ -88,7 +88,6 @@ jobs: then source activate test-environment-$(python.version) fi - pip install setuptools wheel python setup.py bdist_wheel pip install dist/*.whl @@ -98,11 +97,11 @@ jobs: inputs: contents: 'dist/**' targetFolder: $(Build.ArtifactStagingDirectory) - cleanTargetFolder: true # Optional - displayName: "Copy Distributions To Artifacts" + cleanTargetFolder: true + displayName: "Copy Binary Wheel Distribution To Artifacts" - task: PublishBuildArtifacts@1 - displayName: 'Publish Distributions' + displayName: 'Publish Binary Wheel' condition: always() inputs: pathtoPublish: $(Build.ArtifactStagingDirectory)/dist @@ -130,10 +129,18 @@ jobs: pip list echo pyqtgraph system info python -c "import pyqtgraph as pg; pg.systemInfo()" + echo display information + if [ $(agent.os) == 'Linux' ] + then + export DISPLAY=:99.0 + Xvfb :99 -screen 0 1920x1080x24 & + sleep 3 + fi + python -m pyqtgraph.util.get_resolution displayName: 'Debug Info' continueOnError: false - - bash: | + - bash: | if [ $(install.method) == "conda" ] then source activate test-environment-$(python.version) diff --git a/pyqtgraph/tests/test_display.py b/pyqtgraph/tests/test_display.py deleted file mode 100644 index 951a10f9..00000000 --- a/pyqtgraph/tests/test_display.py +++ /dev/null @@ -1,10 +0,0 @@ -from .. import mkQApp - -qApp = mkQApp() - - -def test_displayResolution(): - desktop = qApp.desktop().screenGeometry() - width, height = desktop.width(), desktop.height() - print("\n\nDisplay Resolution Logged as {}x{}\n\n".format(width, height)) - assert height > 0 and width > 0 diff --git a/pyqtgraph/util/get_resolution.py b/pyqtgraph/util/get_resolution.py index 3558a81c..79e17170 100644 --- a/pyqtgraph/util/get_resolution.py +++ b/pyqtgraph/util/get_resolution.py @@ -1,7 +1,15 @@ from .. import mkQApp - -def getResolution(): +def test_screenInformation(): qApp = mkQApp() - desktop = qApp.desktop().screenGeometry() - return (desktop.width(), desktop.height()) + desktop = qApp.desktop() + resolution = desktop.screenGeometry() + availableResolution = desktop.availableGeometry() + print("Screen resolution: {}x{}".format(resolution.width(), resolution.height())) + print("Available geometry: {}x{}".format(availableResolution.width(), availableResolution.height())) + print("Number of Screens: {}".format(desktop.screenCount())) + return None + + +if __name__ == "__main__": + test_screenInformation() \ No newline at end of file diff --git a/pytest.ini b/pytest.ini index c2f39a6f..7d27b7a2 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,11 +1,14 @@ [pytest] +xvfb_width = 1920 +xvfb_height = 1080 # use this due to some issues with ndarray reshape errors on CI systems xvfb_colordepth = 24 addopts = --faulthandler-timeout=15 + filterwarnings = # comfortable skipping these warnings runtime warnings # https://stackoverflow.com/questions/40845304/runtimewarning-numpy-dtype-size-changed-may-indicate-binary-incompatibility ignore:numpy.ufunc size changed, may indicate binary incompatibility.*:RuntimeWarning # Warnings generated from PyQt5.9 - ignore:*U.*mode is deprecated:DeprecationWarning - ignore:This method will be removed in future versions. Use 'tree.iter\(\)' or 'list\(tree.iter\(\)\)' instead.:PendingDeprecationWarning \ No newline at end of file + ignore:This method will be removed in future versions. Use 'tree.iter\(\)' or 'list\(tree.iter\(\)\)' instead.:PendingDeprecationWarning + ignore:'U' mode is deprecated\nplugin = open\(filename, 'rU'\):DeprecationWarning \ No newline at end of file From f359449715bba89bf39c9877bc916cb4c528b8fe Mon Sep 17 00:00:00 2001 From: Ogi Date: Mon, 10 Jun 2019 22:24:53 -0700 Subject: [PATCH 3/4] README and CONTRIBUTING update --- CONTRIBUTING.md | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ CONTRIBUTING.txt | 58 ---------------------------------------- README.md | 53 +++++++++++++++++++++---------------- 3 files changed, 99 insertions(+), 81 deletions(-) create mode 100644 CONTRIBUTING.md delete mode 100644 CONTRIBUTING.txt diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..3ca5e0bf --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,69 @@ +# Contributing to PyQtGraph + +Contributions to pyqtgraph are welcome! + +Please use the following guidelines when preparing changes: + +## Submitting Code Changes + +* The preferred method for submitting changes is by github pull request against the "develop" branch. +* Pull requests should include only a focused and related set of changes. Mixed features and unrelated changes may be rejected. +* For major changes, it is recommended to discuss your plans on the mailing list or in a github issue before putting in too much effort. + * Along these lines, please note that `pyqtgraph.opengl` will be deprecated soon and replaced with VisPy. + +## Documentation + +* Writing proper documentation and unit tests is highly encouraged. PyQtGraph uses nose / pytest style testing, so tests should usually be included in a tests/ directory adjacent to the relevant code. +* Documentation is generated with sphinx; please check that docstring changes compile correctly + +## Style guidelines + +* PyQtGraph prefers PEP8 for most style issues, but this is not enforced rigorously as long as the code is clean and readable. +* Use `python setup.py style` to see whether your code follows the mandatory style guidelines checked by flake8. +* Exception 1: All variable names should use camelCase rather than underscore_separation. This is done for consistency with Qt +* Exception 2: Function docstrings use ReStructuredText tables for describing arguments: + + ```text + ============== ======================================================== + **Arguments:** + argName1 (type) Description of argument + argName2 (type) Description of argument. Longer descriptions must + be wrapped within the column guidelines defined by the + "====" header and footer. + ============== ======================================================== + ``` + + QObject subclasses that implement new signals should also describe + these in a similar table. + +## Testing Setting up a test environment + +### Dependencies + +* tox +* tox-conda +* pytest +* pytest-cov +* pytest-xdist +* pytest-faulthandler +* Optional: pytest-xvfb + +### Tox + +As PyQtGraph supports a wide array of Qt-bindings, and python versions, we make use of `tox` to test against most of the configurations in our test matrix. As some of the qt-bindings are only installable via `conda`, `conda` needs to be in your `PATH`, and we utilize the `tox-conda` plugin. + +* Tests for a module should ideally cover all code in that module, i.e., statement coverage should be at 100%. +* To measure the test coverage, un `pytest --cov -n 4` to run the test suite with coverage on 4 cores. + +### Continous Integration + +For our Continuous Integration, we utilize Azure Pipelines. On each OS, we test the following 6 configurations + +* Python2.7 with PyQt4 +* Python2.7 with PySide +* Python3.6 with PyQt5-5.9 +* Python3.6 with PySide2-5.9 +* Python3.7 with PyQt5-5.12 +* Python3.7 with PySide2-5.12 + +More information on coverage and test failures can be found on the respective tabs of the [build results page](https://dev.azure.com/pyqtgraph/pyqtgraph/_build?definitionId=1) diff --git a/CONTRIBUTING.txt b/CONTRIBUTING.txt deleted file mode 100644 index 5df9703f..00000000 --- a/CONTRIBUTING.txt +++ /dev/null @@ -1,58 +0,0 @@ -Contributions to pyqtgraph are welcome! - -Please use the following guidelines when preparing changes: - -* The preferred method for submitting changes is by github pull request - against the "develop" branch. - -* Pull requests should include only a focused and related set of changes. - Mixed features and unrelated changes may be rejected. - -* For major changes, it is recommended to discuss your plans on the mailing - list or in a github issue before putting in too much effort. - - * Along these lines, please note that pyqtgraph.opengl will be deprecated - soon and replaced with VisPy. - -* Writing proper documentation and unit tests is highly encouraged. PyQtGraph - uses nose / py.test style testing, so tests should usually be included in a - tests/ directory adjacent to the relevant code. - -* Documentation is generated with sphinx; please check that docstring changes - compile correctly. - -* Style guidelines: - - * PyQtGraph prefers PEP8 for most style issues, but this is not enforced - rigorously as long as the code is clean and readable. - - * Use `python setup.py style` to see whether your code follows - the mandatory style guidelines checked by flake8. - - * Exception 1: All variable names should use camelCase rather than - underscore_separation. This is done for consistency with Qt - - * Exception 2: Function docstrings use ReStructuredText tables for - describing arguments: - - ``` - ============== ======================================================== - **Arguments:** - argName1 (type) Description of argument - argName2 (type) Description of argument. Longer descriptions must - be wrapped within the column guidelines defined by the - "====" header and footer. - ============== ======================================================== - ``` - - QObject subclasses that implement new signals should also describe - these in a similar table. - -* Setting up a test environment. - - Tests for a module should ideally cover all code in that module, - i.e., statement coverage should be at 100%. - - To measure the test coverage, install py.test, pytest-cov and pytest-xdist. - Then run 'py.test --cov -n 4' to run the test suite with coverage on 4 cores. - diff --git a/README.md b/README.md index 123949d5..e5b3a9c7 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ -[![Build Status](https://travis-ci.org/pyqtgraph/pyqtgraph.svg?branch=develop)](https://travis-ci.org/pyqtgraph/pyqtgraph) -[![codecov.io](http://codecov.io/github/pyqtgraph/pyqtgraph/coverage.svg?branch=develop)](http://codecov.io/github/pyqtgraph/pyqtgraph?branch=develop) + +[![Build Status](https://pyqtgraph.visualstudio.com/pyqtgraph/_apis/build/status/pyqtgraph.pyqtgraph?branchName=develop)](https://pyqtgraph.visualstudio.com/pyqtgraph/_build/latest?definitionId=17&branchName=develop) + PyQtGraph ========= -A pure-Python graphics library for PyQt/PySide +A pure-Python graphics library for PyQt/PySide/PyQt5/PySide2 -Copyright 2017 Luke Campagnola, University of North Carolina at Chapel Hill +Copyright 2019 Luke Campagnola, University of North Carolina at Chapel Hill @@ -15,15 +16,32 @@ Despite being written entirely in python, the library is fast due to its heavy leverage of numpy for number crunching, Qt's GraphicsView framework for 2D display, and OpenGL for 3D display. - Requirements ------------ -* PyQt 4.7+, PySide, PyQt5, or PySide2 +* PyQt 4.8+, PySide, PyQt5, or PySide2 * python 2.7, or 3.x -* NumPy -* For 3D graphics: pyopengl and qt-opengl -* Known to run on Windows, Linux, and Mac. +* Required + * `numpy`, `scipy` +* Optional + * `pyopengl` for 3D graphics + * `pyqtgraph.opengl` will be depreciated in a future version and replaced with `VisPy` + * `hdf5` for large hdf5 binary format support +* Known to run on Windows, Linux, and macOS. + +Qt Bindings Test Matrix +----------------------- + +Below is a table of the configurations we test and have confidence pyqtgraph will work with. All current operating major operating systems (Windows, macOS, Linux) are tested against this configuration. We recommend using the Qt 5.12 or 5.9 (either PyQt5 or PySide2) bindings. + +| Python Version | PyQt4 | PySide | PyQt5-5.6 | PySide2-5.6 | PyQt5-5.9 | PySide2-5.9 | PyQt5-5.12 | PySide2 5.12 | +| :-------------- | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | +| 2.7 | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | +| 3.5 | :x: | :x: | :white_check_mark: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: | +| 3.6 | :x: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| 3.7 | :x: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | + +* pyqtgraph has had some incompatabilities with PySide2-5.6, and we recommend you avoid those bindings if possible. Support ------- @@ -36,7 +54,9 @@ Installation Methods * From PyPI: * Last released version: `pip install pyqtgraph` - * Latest development version: `pip install git+https://github.com/pyqtgraph/pyqtgraph` + * Latest development version: `pip install git+https://github.com/pyqtgraph/pyqtgraph@develop` +* From conda + * Last released version: `conda install pyqtgraph` * To install system-wide from source distribution: `python setup.py install` * Many linux package repositories have release versions. * To use with a specific project, simply copy the pyqtgraph subdirectory @@ -49,16 +69,3 @@ Documentation The easiest way to learn pyqtgraph is to browse through the examples; run `python -m pyqtgraph.examples` for a menu. The official documentation lives at http://pyqtgraph.org/documentation - -Testing -------- - -To test the pyqtgraph library, clone the repository, and run `pytest pyqtgraph`. For more thurough testing, you can use `tox`, however the [tox-conda](https://github.com/tox-dev/tox-conda) plugin is required. Running `tox` on its own will run `pytest pyqtgraph -vv` on it's own, however if you want to run a specific test, you can run `tox -- pyqtgraph/exporters/tests/test_svg::test_plotscene` for example. - -Dependencies include: - -* pytest -* pytest-cov -* pytest-xdist -* tox -* tox-conda \ No newline at end of file From ed3a039d236cd0893cfb7365d32c09f22f0c7a1b Mon Sep 17 00:00:00 2001 From: Ogi Date: Tue, 11 Jun 2019 23:01:24 -0700 Subject: [PATCH 4/4] Testing segfault potential fix --- azure-test-template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-test-template.yml b/azure-test-template.yml index 6a237e99..8a68317b 100644 --- a/azure-test-template.yml +++ b/azure-test-template.yml @@ -150,7 +150,7 @@ jobs: # echo "https://dev.azure.com/pyqtgraph/pyqtgraph/_apis/build/builds/$(Build.BuildId)/artifacts?artifactName=Screenshots&api-version=5.0" pytest . -sv \ --junitxml=junit/test-results.xml \ - --cov pyqtgraph --cov-report=xml --cov-report=html + -n 1 --cov pyqtgraph --cov-report=xml --cov-report=html displayName: 'Unit tests' env: AZURE: 1