Skip to content

Commit

Permalink
Drops Python 2 support (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMiras authored Apr 10, 2020
1 parent 7f9b3d6 commit 5fb013c
Show file tree
Hide file tree
Showing 18 changed files with 27 additions and 248 deletions.
43 changes: 0 additions & 43 deletions ci/docker/Dockerfile.archlinux.py2

This file was deleted.

40 changes: 0 additions & 40 deletions ci/docker/Dockerfile.bionic.py2

This file was deleted.

39 changes: 0 additions & 39 deletions ci/docker/Dockerfile.fedora28.py2

This file was deleted.

29 changes: 8 additions & 21 deletions ci/docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,17 @@
# build docker images from Travis matrix
if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$DOCK" = "1" ]
then
docker build \
--tag plyer:py3 \
--file ci/docker/Dockerfile.$IMAGE.py3 \
"$(pwd)"

# separate images for Python 2
if [ "$PY" = "2" ]
# style image that inherits layers from Python 3 image
if [ "$RUN" = "style" ]
then
docker build \
--tag plyer:py2 \
--file ci/docker/Dockerfile.$IMAGE.py2 \
--tag plyer:style \
--file ci/docker/Dockerfile.$IMAGE.style \
"$(pwd)"

# separate images for Python 3
elif [ "$PY" = "3" ]
then
docker build \
--tag plyer:py3 \
--file ci/docker/Dockerfile.$IMAGE.py3 \
"$(pwd)"

# style image that inherits layers from Python 3 image
if [ "$RUN" = "style" ]
then
docker build \
--tag plyer:style \
--file ci/docker/Dockerfile.$IMAGE.style \
"$(pwd)"
fi
fi
fi
13 changes: 2 additions & 11 deletions ci/docker_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@
if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$DOCK" = "1" ]
then

# run tests for Plyer in Python 2
if [ "$PY" = "2" ] && [ "$RUN" = "unit" ]
then
docker run \
--interactive \
--tty \
plyer:py2

# run tests for Plyer in Python 3
elif [ "$PY" = "3" ] && [ "$RUN" = "unit" ]
if [ "$RUN" = "unit" ]
then

# running coverage report (COVERALLS=1)
Expand Down Expand Up @@ -41,7 +32,7 @@ then
plyer:py3
fi

elif [ "$PY" = "3" ] && [ "$RUN" = "style" ]
elif [ "$RUN" = "style" ]
then
docker run \
--interactive \
Expand Down
7 changes: 2 additions & 5 deletions ci/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#!/bin/sh
set -vex

if [ "$1" = "py2" ]
then
PYTHON=$(which python)
elif [ "$1" = "py3" ] || [ "$1" = "pep8" ]
if [ "$1" = "py3" ] || [ "$1" = "pep8" ]
then
PYTHON=$(which python3.6)
elif [ "$1" = "env" ]
Expand All @@ -20,7 +17,7 @@ $PYTHON -V
if [ "$2" = "style" ]
then
$PYTHON -m pycodestyle "$(pwd)" \
--exclude=pep8.py,compat.py,utils.py \
--exclude=pep8.py,utils.py \
--ignore=E402,W503
touch "$(pwd)/__init__.py"
$PYTHON -m pylint \
Expand Down
8 changes: 1 addition & 7 deletions ci/win_set_python.bat
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
@echo off
:: choose between Python 2 or 3 from matrix
if "%PY%"=="27" (
set PYTHON=C:\Python27\python.exe
) else (
set PYTHON=C:\Python36\python.exe
)

set PYTHON=C:\Python36\python.exe
:: cd to Plyer folder and set PYTHONPATH
cd C:\projects\app
set PYTHONPATH=%PYTHONPATH%;%cd%
2 changes: 1 addition & 1 deletion ci/win_style.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@echo off
if "%STYLE%"=="1" (
%PYTHON% -m pycodestyle "%cd%" ^
--exclude=pep8.py,compat.py,utils.py ^
--exclude=pep8.py,utils.py ^
--ignore=E402,W503 ^
&& echo off > "%cd%\__init__.py" && echo on ^
&& %PYTHON% -m pylint ^
Expand Down
2 changes: 1 addition & 1 deletion examples/compass/buildozer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ version = 0.1

# (list) Application requirements
# comma seperated e.g. requirements = sqlite3,kivy
requirements = kivy,hostpython2
requirements = kivy,hostpython3

# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
Expand Down
4 changes: 0 additions & 4 deletions examples/notification/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from plyer import notification
from plyer.utils import platform
from plyer.compat import PY2

kivy.require('1.8.0')

Expand All @@ -17,9 +16,6 @@ def do_notify(self, mode='normal'):
title = self.ids.notification_title.text
message = self.ids.notification_text.text
ticker = self.ids.ticker_text.text
if PY2:
title = title.decode('utf8')
message = message.decode('utf8')
kwargs = {'title': title, 'message': message, 'ticker': ticker}

if mode == 'fancy':
Expand Down
37 changes: 0 additions & 37 deletions plyer/compat.py

This file was deleted.

5 changes: 1 addition & 4 deletions plyer/facades/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
'''

from plyer.compat import string_types, text_type


class Audio(object):
'''
Expand Down Expand Up @@ -90,8 +88,7 @@ def file_path(self, location):
'''
Location of the recording.
'''
assert isinstance(location, (string_types, text_type)), \
'Location must be string or unicode'
assert isinstance(location, str), 'Location must be string or unicode'
self._file_path = location

# private
Expand Down
3 changes: 0 additions & 3 deletions plyer/platforms/win/libs/balloontip.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import ctypes
from threading import RLock

from plyer.compat import PY2
from plyer.platforms.win.libs import win_api_defs


Expand Down Expand Up @@ -88,8 +87,6 @@ def __init__(self, title, message, app_name, app_icon='',
wnd_class_ex = win_api_defs.get_WNDCLASSEXW()
class_name = 'PlyerTaskbar' + str(WindowsBalloonTip._get_unique_id())

if PY2:
class_name = class_name.decode('utf8')
wnd_class_ex.lpszClassName = class_name

# keep ref to it as long as window is alive
Expand Down
13 changes: 4 additions & 9 deletions plyer/platforms/win/libs/wifi_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
)
from ctypes.wintypes import DWORD, HANDLE, LPCWSTR, ULONG
from sys import exit as sys_exit
from plyer.compat import PY2, xrange


def customresize(array, new_size):
Expand Down Expand Up @@ -57,7 +56,7 @@ class GUID(Structure):
wlan_interface_state_associating,
wlan_interface_state_discovering,
wlan_interface_state_authenticating) = map(WLAN_INTERFACE_STATE,
xrange(0, 8))
range(0, 8))


class WLAN_INTERFACE_INFO(Structure):
Expand Down Expand Up @@ -92,7 +91,7 @@ class WLAN_INTERFACE_INFO_LIST(Structure):
DOT11_BSS_TYPE = c_uint
(dot11_BSS_type_infrastructure,
dot11_BSS_type_independent,
dot11_BSS_type_any) = map(DOT11_BSS_TYPE, xrange(1, 4))
dot11_BSS_type_any) = map(DOT11_BSS_TYPE, range(1, 4))

# The DOT11_PHY_TYPE enumeration defines an 802.11 PHY and media type.
DOT11_PHY_TYPE = c_uint
Expand Down Expand Up @@ -153,7 +152,7 @@ class DOT11_SSID(Structure):
wlan_connection_mode_discovery_secure,
wlan_connection_mode_discovery_unsecure,
wlan_connection_mode_auto,
wlan_connection_mode_invalid) = map(WLAN_CONNECTION_MODE, xrange(0, 6))
wlan_connection_mode_invalid) = map(WLAN_CONNECTION_MODE, range(0, 6))


class NDIS_OBJECT_HEADER(Structure):
Expand Down Expand Up @@ -510,11 +509,7 @@ def _make_dict():
global _dict
_dict = {}
for network in available:
# if bytes, dict['name'] throws an error on py3 if not b'name'
if PY2:
_dict[unicode(network.dot11Ssid.SSID)] = network # noqa F821 undefined name 'unicode'
else:
_dict[network.dot11Ssid.SSID.decode('utf-8')] = network
_dict[network.dot11Ssid.SSID.decode('utf-8')] = network


def _get_available_wifi():
Expand Down
Loading

0 comments on commit 5fb013c

Please sign in to comment.