We support pyside2 don't we?

This commit is contained in:
Ogi 2019-05-28 22:42:01 -07:00
parent f2426e9dd2
commit 2df71abfec
7 changed files with 156 additions and 150 deletions

View File

@ -12,8 +12,8 @@ jobs:
matrix: matrix:
Python27-Qt4: Python27-Qt4:
python.version: '2.7' python.version: '2.7'
install.method: "conda"
qt.bindings: "pyqt=4" qt.bindings: "pyqt=4"
install.method: "conda"
Python27-PySide: Python27-PySide:
python.version: '2.7' python.version: '2.7'
qt.bindings: "pyside" qt.bindings: "pyside"
@ -26,158 +26,145 @@ jobs:
python.version: "3.7" python.version: "3.7"
qt.bindings: "pyside2" qt.bindings: "pyside2"
install.method: "conda" install.method: "conda"
Python35-PyQt-5.12: Python37-PyQt-5.12:
python.version: '3.5' python.version: '3.7'
qt.bindings: "PyQt5" qt.bindings: "PyQt5"
install.method: "pip" install.method: "pip"
Python35-PySide2-5.12: Python37-PySide2-5.12:
python.version: "3.5" python.version: "3.7"
qt.bindings: "PySide2" qt.bindings: "PySide2"
install.method: "pip" install.method: "pip"
steps: steps:
- powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" - task: ScreenResolutionUtility@1
displayName: 'Windows - Add conda to PATH' inputs:
condition: and(eq(variables['install.method'], 'conda' ), eq(variables['agent.os'], 'Windows_NT' )) displaySettings: 'specific'
width: '1920'
height: '1080'
condition: eq(variables['agent.os'], 'Windows_NT' )
- task: UsePythonVersion@0
inputs:
versionSpec: $(python.version)
condition: eq(variables['install.method'], 'pip')
- bash: | - bash: |
echo "##vso[task.prependpath]$CONDA/bin" if [ $(agent.os) == 'Linux' ]
sudo chown -R $USER $CONDA then
displayName: 'MacOS - Add conda to PATH' echo '##vso[task.prependpath]/usr/share/miniconda/bin'
condition: and(eq(variables['install.method'], 'conda' ), eq(variables['agent.os'], 'Darwin' )) elif [ $(agent.os) == 'Darwin' ]
then
- bash: | echo '##vso[task.prependpath]$CONDA/bin'
brew update && brew install azure-cli sudo install -d -m 0777 /usr/local/miniconda/envs
brew update && brew install python3 && brew upgrade python3 elif [ $(agent.os) == 'Windows_NT' ]
brew link --overwrite python3 then
displayName: "MacOS - Intall Python3" echo "##vso[task.prependpath]$env:CONDA\Scripts"
condition: and(eq(variables['install.method'], 'pip' ), eq(variables['agent.os'], 'Darwin' )) else
echo 'Just what OS are you using?'
- bash: | fi
echo "##vso[task.prependpath]/usr/share/miniconda/bin" displayName: 'Add Conda to $PATH'
displayName: 'Linux - Add conda to PATH'
condition: and(eq(variables['install.method'], 'conda' ), eq(variables['agent.os'], 'Linux' ))
- bash: |
# Install & Start Windows Manager for Linux
sudo apt-get install -y xvfb libxkbcommon-x11-0 # herbstluftwm
displayName: 'Linux - Prepare OS'
condition: eq(variables['agent.os'], 'Linux' )
- bash: |
source $HOME/miniconda/etc/profile.d/conda.sh
hash -r
conda config --set always_yes yes --set auto_update_conda no
conda config --add channels conda-forge
conda create -n test_env --quiet python=$(python.version)
displayName: 'Conda Setup Test Environment'
condition: eq(variables['install.method'], 'conda' ) condition: eq(variables['install.method'], 'conda' )
- task: CondaEnvironment@0
displayName: 'Create Conda Environment'
condition: eq(variables['install.method'], 'conda')
inputs:
environmentName: 'test-environment-$(python.version)'
packageSpecs: 'python=$(python.version)'
- bash: |
if [ $(install.method) == "conda" ]
then
source activate test-environment-$(python.version)
conda install -c conda-forge $(qt.bindings) numpy scipy pyopengl pytest flake8 six coverage --yes
else
pip install $(qt.bindings) numpy scipy pyopengl pytest flake8 six coverage
fi
pip install pytest-xdist pytest-cov pytest-faulthandler
displayName: "Install Dependencies"
- script: | - bash: |
call activate test_env if [ $(install.method) == "conda" ]
conda install --quiet $(qt.bindings) then
conda install --quiet numpy scipy pyopengl pytest flake8 six coverage source activate test-environment-$(python.version)
pip install pytest-azurepipelines pytest-xdist pytest-cov fi
displayName: Conda Install Dependencies - Windows
condition: and(eq(variables['install.method'], 'conda' ), eq(variables['agent.os'], 'Windows_NT' )) pip install setuptools wheel
python setup.py bdist_wheel
pip install dist/*.whl
displayName: 'Build Wheel and Install'
- task: CopyFiles@2
inputs:
contents: 'dist/**'
targetFolder: $(Build.ArtifactStagingDirectory)
cleanTargetFolder: true # Optional
displayName: "Copy Distributions To Artifacts"
- task: PublishBuildArtifacts@1
displayName: 'Publish Distributions'
condition: always()
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)/dist
artifactName: Distributions
- bash: | - bash: |
source activate test_env sudo apt-get install -y libxkbcommon-x11-0 # herbstluftwm
conda install --quiet $(qt.bindings) if [ $(install.method) == "conda" ]
conda install --quiet numpy scipy pyopengl pytest flake8 six coverage then
pip install pytest-azurepipelines pytest-xdist pytest-cov pytest-xvfb source activate test-environment-$(python.version)
displayName: Conda Install Dependencies - MacOS+Linux fi
condition: and(eq(variables['install.method'], 'conda' ), ne(variables['agent.os'], 'Windows_NT' )) pip install pytest-xvfb
displayName: "Linux Virtual Display Setup"
condition: eq(variables['agent.os'], 'Linux' )
- bash: | - bash: |
pip3 install setuptools wheel if [ $(install.method) == "conda" ]
pip3 install $(qt.bindings) then
pip3 install numpy scipy pyopengl pytest flake8 six coverage source activate test-environment-$(python.version)
pip3 install pytest-azurepipelines pytest-xdist pytest-cov pytest-xvfb fi
displayName: "Pip - Install Dependencies" echo python location: `which python`
condition: eq(variables['install.method'], 'pip' )
- bash: |
source activate test_env
echo python location: `which python3`
echo python version: `python3 --version`
echo pytest location: `which pytest`
echo installed packages
conda list
echo pyqtgraph system info
python -c "import pyqtgraph as pg; pg.systemInfo()"
displayName: 'Debug - Conda/MacOS+Linux'
continueOnError: false
condition: and(eq(variables['install.method'], 'conda' ), ne(variables['agent.os'], 'Windows_NT' ))
- script: |
call activate test_env
echo python location
where python
echo python version
python --version
echo pytest location
where pytest
echo installed packages
conda list
echo pyqtgraph system info
python -c "import pyqtgraph as pg; pg.systemInfo()"
displayName: 'Debug - Conda/Windows'
continueOnError: false
condition: and(eq(variables['install.method'], 'conda' ), eq(variables['agent.os'], 'Windows_NT' ))
- bash: |
echo python location: `which python3`
echo python version: `python3 --version`
echo pytest location: `which pytest`
echo installed packages
pip3 list
echo pyqtgraph system info
python3 -c "import pyqtgraph as pg; pg.systemInfo()"
displayName: 'Debug - System/MacOS+Linux'
continueOnError: false
condition: and(eq(variables['install.method'], 'pip' ), ne(variables['agent.os'], 'Windows_NT' ))
- bash: |
echo python location: `where python`
echo python version: `python --version` echo python version: `python --version`
echo pytest location: `where pytest` echo pytest location: `which pytest`
echo installed packages echo installed packages
python -m pip list pip list
echo pyqtgraph system info echo pyqtgraph system info
python -c "import pyqtgraph as pg; pg.systemInfo()" python -c "import pyqtgraph as pg; pg.systemInfo()"
displayName: 'Debug - System/Windows' displayName: 'Debug Info'
continueOnError: false continueOnError: false
condition: and(eq(variables['install.method'], 'pip' ), eq(variables['agent.os'], 'Windows_NT' ))
- bash: python3 -m pytest --cov pyqtgraph -sv --test-run-title="Tests for $(Agent.OS) - Python $(python.version) - Install Method $(install.method)- Bindings $(qt.bindings)" --napoleon-docstrings - bash: |
displayName: 'Tests - Run - Pip/MacOS+Linux' if [ $(install.method) == "conda" ]
continueOnError: false then
source activate test-environment-$(python.version)
fi
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 \
--junitxml=junit/test-results.xml \
--cov pyqtgraph --cov-report=xml --cov-report=html
displayName: 'Unit tests'
env: env:
DISPLAY: :99.0 AZURE: 1
condition: and(eq(variables['install.method'], 'pip' ), ne(variables['agent.os'], 'Windows_NT' )) SCREENSHOT_DIR: $(Build.ArtifactStagingDirectory)/screenshots
- bash: python -m pytest --cov pyqtgraph -sv --test-run-title="Tests for $(Agent.OS) - Python $(python.version) - Install Method $(install.method)- Bindings $(qt.bindings)" --napoleon-docstrings - task: PublishBuildArtifacts@1
displayName: 'Tests - Run - Pip/Windows' displayName: 'Publish Screenshots'
continueOnError: false condition: failed()
env: inputs:
DISPLAY: :99.0 pathtoPublish: $(Build.ArtifactStagingDirectory)/screenshots
condition: and(eq(variables['install.method'], 'pip' ), eq(variables['agent.os'], 'Windows_NT' )) artifactName: Screenshots
- bash: | - task: PublishTestResults@2
source activate test_env condition: succeededOrFailed()
pytest --cov pyqtgraph -sv --test-run-title="Tests for $(Agent.OS) - Python $(python.version) - Install Method $(install.method)- Bindings $(qt.bindings)" --napoleon-docstrings inputs:
displayName: 'Tests - Run - Conda/MacOS+Linux' testResultsFiles: '**/test-*.xml'
continueOnError: false testRunTitle: 'Test Results for $(agent.os) - $(python.version) - $(qt.bindings) - $(install.method)'
env: publishRunAttachments: true
DISPLAY: :99.0
condition: and(eq(variables['install.method'], 'conda' ), ne(variables['agent.os'], 'Windows_NT' )) - task: PublishCodeCoverageResults@1
inputs:
- script: | codeCoverageTool: Cobertura
call activate test_env summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
python -m pytest --cov pyqtgraph -sv --test-run-title="Tests for $(Agent.OS) - Python $(python.version) - Install Method $(install.method)- Bindings $(qt.bindings)" --napoleon-docstrings reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov'
displayName: 'Tests - Run - Conda/Windows'
continueOnError: false
env:
DISPLAY: :99.0
condition: and(eq(variables['install.method'], 'conda' ), eq(variables['agent.os'], 'Windows_NT' ))

View File

@ -135,6 +135,8 @@ if __name__ == '__main__':
lib = 'PyQt4' lib = 'PyQt4'
elif '--pyqt5' in args: elif '--pyqt5' in args:
lib = 'PyQt5' lib = 'PyQt5'
elif '--pyside2' in args:
lib = 'PySide2'
else: else:
lib = '' lib = ''

View File

@ -31,7 +31,6 @@ def init_viewbox():
g = pg.GridItem() g = pg.GridItem()
vb.addItem(g) vb.addItem(g)
app.processEvents() app.processEvents()
def test_ViewBox(): def test_ViewBox():

View File

@ -213,7 +213,7 @@ def assertImageApproved(image, standardFile, message=None, **kwargs):
if os.getenv('TRAVIS') is not None: if os.getenv('TRAVIS') is not None:
saveFailedTest(image, stdImage, standardFile, upload=True) saveFailedTest(image, stdImage, standardFile, upload=True)
elif os.getenv('AZURE') is not None: elif os.getenv('AZURE') is not None:
standardFile = r"artifacts/" + standardFile standardFile = os.path.join(os.getenv("SCREENSHOT_DIR", "screenshots"), standardFile)
saveFailedTest(image, stdImage, standardFile) saveFailedTest(image, stdImage, standardFile)
print(graphstate) print(graphstate)
raise raise
@ -288,11 +288,6 @@ def assertImageMatch(im1, im2, minCorr=None, pxThreshold=50.,
def saveFailedTest(data, expect, filename, upload=False): def saveFailedTest(data, expect, filename, upload=False):
"""Upload failed test images to web server to allow CI test debugging. """Upload failed test images to web server to allow CI test debugging.
""" """
commit = runSubprocess(['git', 'rev-parse', 'HEAD'])
name = filename.split('/')
name.insert(-1, commit.strip())
filename = '/'.join(name)
# concatenate data, expect, and diff into a single image # concatenate data, expect, and diff into a single image
ds = data.shape ds = data.shape
es = expect.shape es = expect.shape
@ -309,7 +304,7 @@ def saveFailedTest(data, expect, filename, upload=False):
img[2:2+diff.shape[0], -diff.shape[1]-2:-2] = diff img[2:2+diff.shape[0], -diff.shape[1]-2:-2] = diff
png = makePng(img) png = makePng(img)
directory, _, _ = filename.rpartition("/") directory = os.path.dirname(filename)
if not os.path.isdir(directory): if not os.path.isdir(directory):
os.makedirs(directory) os.makedirs(directory)
with open(filename + ".png", "wb") as png_file: with open(filename + ".png", "wb") as png_file:
@ -317,9 +312,15 @@ def saveFailedTest(data, expect, filename, upload=False):
print("\nImage comparison failed. Test result: %s %s Expected result: " print("\nImage comparison failed. Test result: %s %s Expected result: "
"%s %s" % (data.shape, data.dtype, expect.shape, expect.dtype)) "%s %s" % (data.shape, data.dtype, expect.shape, expect.dtype))
if upload: if upload:
uploadFailedTest(filename) uploadFailedTest(filename, png)
def uploadFailedTest(filename):
def uploadFailedTest(filename, png):
commit = runSubprocess(['git', 'rev-parse', 'HEAD'])
name = filename.split(os.path.sep)
name.insert(-1, commit.strip())
filename = os.path.sep.join(name)
host = 'data.pyqtgraph.org' host = 'data.pyqtgraph.org'
conn = httplib.HTTPConnection(host) conn = httplib.HTTPConnection(host)
req = urllib.urlencode({'name': filename, req = urllib.urlencode({'name': filename,

View File

@ -0,0 +1,10 @@
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

View File

@ -0,0 +1,7 @@
from .. import mkQApp
def getResolution():
qApp = mkQApp()
desktop = qApp.desktop().screenGeometry()
return (desktop.width(), desktop.height())

View File

@ -15,10 +15,10 @@ elif '--pyqt4' in args:
elif '--pyqt5' in args: elif '--pyqt5' in args:
args.remove('--pyqt5') args.remove('--pyqt5')
import PyQt5 import PyQt5
elif '--pyside2' in args:
args.remove('--pyside2')
import PySide2
import pyqtgraph as pg import pyqtgraph as pg
pg.systemInfo() pg.systemInfo()
pytest.main(args) pytest.main(args)