Skip to content

Commit

Permalink
Drop Python 2: Initial Python 2 related code removal
Browse files Browse the repository at this point in the history
Update RELEASE instructions too
Remove py3compat module
Remove sys.version based validations
  • Loading branch information
dalthviz committed Oct 15, 2021
1 parent 3ce89db commit 17da075
Show file tree
Hide file tree
Showing 21 changed files with 80 additions and 386 deletions.
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ omit =
*/tests/*
# Omit other files
*/__init__.py
*/py3compat.py
*/compat.py
*/_version.py
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
PYTHON_VERSION: ['2.7', '3.6', '3.8']
PYTHON_VERSION: ['3.6', '3.8']
USE_CONDA: ['Yes', 'No']
steps:
- name: Checkout branch
Expand Down Expand Up @@ -61,11 +61,10 @@ jobs:
strategy:
fail-fast: false
matrix:
PYTHON_VERSION: ['2.7', '3.6', '3.8']
PYTHON_VERSION: ['3.6', '3.8']
USE_CONDA: ['Yes', 'No']
exclude:
- PYTHON_VERSION: '2.7'
USE_CONDA: 'Yes'
- USE_CONDA: 'Yes'
steps:
- name: Checkout branch
uses: actions/checkout@v2
Expand Down Expand Up @@ -95,7 +94,7 @@ jobs:
strategy:
fail-fast: false
matrix:
PYTHON_VERSION: ['2.7', '3.6', '3.8']
PYTHON_VERSION: ['3.6', '3.8']
USE_CONDA: ['Yes', 'No']
steps:
- name: Checkout branch
Expand Down
23 changes: 6 additions & 17 deletions .github/workflows/test-pyqt5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,23 @@ conda activate test-pyqt5
# Select build with QtMultimedia
if [ "$(uname)" == "Darwin" ]; then

if [ "$PYTHON_VERSION" = "2.7" ]; then
export QT_VER=5.9
elif [ "$PYTHON_VERSION" = "3.6" ]; then
if [ "$PYTHON_VERSION" = "3.6" ]; then
export QT_VER=5.12
else
export QT_VER=5.*
fi

elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then

if [ "$PYTHON_VERSION" = "2.7" ]; then
export QT_VER=5.9
elif [ "$PYTHON_VERSION" = "3.6" ]; then
if [ "$PYTHON_VERSION" = "3.6" ]; then
export QT_VER=5.12
else
export QT_VER=5.*
fi

else

if [ "$PYTHON_VERSION" = "2.7" ]; then
exit 0
elif [ "$PYTHON_VERSION" = "3.6" ]; then
if [ "$PYTHON_VERSION" = "3.6" ]; then
export QT_VER=5.9
else
export QT_VER=5.*
Expand All @@ -41,14 +35,9 @@ if [ "$USE_CONDA" = "Yes" ]; then
conda install coveralls mock pytest pytest-cov python="$PYTHON_VERSION" -c conda-forge -q
conda install -q qt=$QT_VER pyqt=$QT_VER -c conda-forge -q
else
if [ "$PYTHON_VERSION" = "2.7" ]; then
# There are no pyqt5 wheels for Python 2
exit 0
else
# We are getting segfaults in 5.10
conda install coveralls mock pytest pytest-cov python="$PYTHON_VERSION" -c anaconda -q
pip install -q pyqt5 PyQtWebEngine
fi
# We are getting segfaults in 5.10
conda install coveralls mock pytest pytest-cov python="$PYTHON_VERSION" -c anaconda -q
pip install -q pyqt5 PyQtWebEngine
fi

# Install package
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-pyside2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [ "$USE_CONDA" = "Yes" ]; then
# There are no conda packages for PySide2
exit 0
elif [ "$PYTHON_VERSION" != "3.6" ] && [ "$RUNNER_OS" = "Windows" ]; then
# There is no wheel for PySide 5.12 on Windows and Python 2.7 or 3.8
# There is no wheel for PySide 5.12 on Windows and Python 3.8
exit 0
else
# Simple solution to avoid failures with the Qt3D modules
Expand Down
12 changes: 8 additions & 4 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@ To release a new version of qtpy on PyPI:

* git clean -xfdi

* Update CHANGELOG.md
* Update CHANGELOG.md using `loghub` to generate the list of issues and PRs merged to add at the top of the file

loghub -m vX.X.X spyder-ide/qtpy

* Update `_version.py` (set release version, remove 'dev0')

* git add and git commit
* git add . && git commit -m 'Release X.X.X'

* python setup.py sdist

* python setup.py bdist_wheel

* twine check dist/*

* twine upload dist/*

* git tag -a vX.X.X -m 'comment'
* git tag -a vX.X.X -m 'Release X.X.X'

* Update `_version.py` (add 'dev0' and increment minor)

* git add and git commit
* git add . && git commit -m 'Back to work'

* git push

Expand Down
14 changes: 5 additions & 9 deletions qtpy/Qt3DAnimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@

# Local imports
from . import PYQT5, PYSIDE2, PythonQtError, PYSIDE_VERSION
from .py3compat import PY2

if PYQT5:
from PyQt5.Qt3DAnimation import *
elif PYSIDE2:
if not PY2 or (PY2 and PYSIDE_VERSION < '5.12.4'):
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026
import PySide2.Qt3DAnimation as __temp
import inspect
for __name in inspect.getmembers(__temp.Qt3DAnimation):
globals()[__name[0]] = __name[1]
else:
raise PythonQtError('A bug in Shiboken prevents this')
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026
import PySide2.Qt3DAnimation as __temp
import inspect
for __name in inspect.getmembers(__temp.Qt3DAnimation):
globals()[__name[0]] = __name[1]
else:
raise PythonQtError('No Qt bindings could be found')
16 changes: 6 additions & 10 deletions qtpy/Qt3DCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@
"""Provides Qt3DCore classes and functions."""

# Local imports
from . import PYQT5, PYSIDE2, PythonQtError, PYSIDE_VERSION
from .py3compat import PY2
from . import PYQT5, PYSIDE2, PythonQtError

if PYQT5:
from PyQt5.Qt3DCore import *
elif PYSIDE2:
if not PY2 or (PY2 and PYSIDE_VERSION < '5.12.4'):
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026
import PySide2.Qt3DCore as __temp
import inspect
for __name in inspect.getmembers(__temp.Qt3DCore):
globals()[__name[0]] = __name[1]
else:
raise PythonQtError('A bug in Shiboken prevents this')
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026
import PySide2.Qt3DCore as __temp
import inspect
for __name in inspect.getmembers(__temp.Qt3DCore):
globals()[__name[0]] = __name[1]
else:
raise PythonQtError('No Qt bindings could be found')
16 changes: 6 additions & 10 deletions qtpy/Qt3DExtras.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@
"""Provides Qt3DExtras classes and functions."""

# Local imports
from . import PYQT5, PYSIDE2, PythonQtError, PYSIDE_VERSION
from .py3compat import PY2
from . import PYQT5, PYSIDE2, PythonQtError

if PYQT5:
from PyQt5.Qt3DExtras import *
elif PYSIDE2:
if not PY2 or (PY2 and PYSIDE_VERSION < '5.12.4'):
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026
import PySide2.Qt3DExtras as __temp
import inspect
for __name in inspect.getmembers(__temp.Qt3DExtras):
globals()[__name[0]] = __name[1]
else:
raise PythonQtError('A bug in Shiboken prevents this')
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026
import PySide2.Qt3DExtras as __temp
import inspect
for __name in inspect.getmembers(__temp.Qt3DExtras):
globals()[__name[0]] = __name[1]
else:
raise PythonQtError('No Qt bindings could be found')
16 changes: 6 additions & 10 deletions qtpy/Qt3DInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@
"""Provides Qt3DInput classes and functions."""

# Local imports
from . import PYQT5, PYSIDE2, PythonQtError, PYSIDE_VERSION
from .py3compat import PY2
from . import PYQT5, PYSIDE2, PythonQtError

if PYQT5:
from PyQt5.Qt3DInput import *
elif PYSIDE2:
if not PY2 or (PY2 and PYSIDE_VERSION < '5.12.4'):
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026
import PySide2.Qt3DInput as __temp
import inspect
for __name in inspect.getmembers(__temp.Qt3DInput):
globals()[__name[0]] = __name[1]
else:
raise PythonQtError('A bug in Shiboken prevents this')
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026
import PySide2.Qt3DInput as __temp
import inspect
for __name in inspect.getmembers(__temp.Qt3DInput):
globals()[__name[0]] = __name[1]
else:
raise PythonQtError('No Qt bindings could be found')
16 changes: 6 additions & 10 deletions qtpy/Qt3DLogic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@
"""Provides Qt3DLogic classes and functions."""

# Local imports
from . import PYQT5, PYSIDE2, PythonQtError, PYSIDE_VERSION
from .py3compat import PY2
from . import PYQT5, PYSIDE2, PythonQtError

if PYQT5:
from PyQt5.Qt3DLogic import *
elif PYSIDE2:
if not PY2 or (PY2 and PYSIDE_VERSION < '5.12.4'):
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026
import PySide2.Qt3DLogic as __temp
import inspect
for __name in inspect.getmembers(__temp.Qt3DLogic):
globals()[__name[0]] = __name[1]
else:
raise PythonQtError('A bug in Shiboken prevents this')
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026
import PySide2.Qt3DLogic as __temp
import inspect
for __name in inspect.getmembers(__temp.Qt3DLogic):
globals()[__name[0]] = __name[1]
else:
raise PythonQtError('No Qt bindings could be found')
16 changes: 6 additions & 10 deletions qtpy/Qt3DRender.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@
"""Provides Qt3DRender classes and functions."""

# Local imports
from . import PYQT5, PYSIDE2, PythonQtError, PYSIDE_VERSION
from .py3compat import PY2
from . import PYQT5, PYSIDE2, PythonQtError

if PYQT5:
from PyQt5.Qt3DRender import *
elif PYSIDE2:
if not PY2 or (PY2 and PYSIDE_VERSION < '5.12.4'):
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026
import PySide2.Qt3DRender as __temp
import inspect
for __name in inspect.getmembers(__temp.Qt3DRender):
globals()[__name[0]] = __name[1]
else:
raise PythonQtError('A bug in Shiboken prevents this')
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1026
import PySide2.Qt3DRender as __temp
import inspect
for __name in inspect.getmembers(__temp.Qt3DRender):
globals()[__name[0]] = __name[1]
else:
raise PythonQtError('No Qt bindings could be found')
1 change: 0 additions & 1 deletion qtpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@

# Version of QtPy
from ._version import __version__
from .py3compat import PY2


class PythonQtError(RuntimeError):
Expand Down
23 changes: 21 additions & 2 deletions qtpy/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,30 @@
Compatibility functions
"""

from __future__ import print_function
from collections.abc import Callable
import sys

from .QtWidgets import QFileDialog
from .py3compat import Callable, is_text_string, to_text_string, TEXT_TYPES


TEXT_TYPES = (str,)


def is_text_string(obj):
"""Return True if `obj` is a text string, False if it is anything else,
like binary data."""
return isinstance(obj, str)


def to_text_string(obj, encoding=None):
"""Convert `obj` to (unicode) text string"""
if encoding is None:
return str(obj)
elif isinstance(obj, str):
# In case this function is not used properly, this could happen
return obj
else:
return str(obj, encoding)


# =============================================================================
Expand Down
Loading

0 comments on commit 17da075

Please sign in to comment.