From 582c7757a38492eb1e4d0932490422d936f90eb9 Mon Sep 17 00:00:00 2001 From: Philip Howard Date: Tue, 2 Nov 2021 10:17:46 +0000 Subject: [PATCH 1/2] Drop Python2 support. --- .github/workflows/test.yml | 4 ++-- README.md | 2 +- install.sh | 11 +++-------- library/CHANGELOG.txt | 5 +++++ library/README.md | 8 +++++++- library/enviroplus/__init__.py | 2 +- library/setup.cfg | 12 ++---------- library/tox.ini | 2 +- 8 files changed, 22 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 89154d5..5fac95b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: [2.7, 3.5, 3.6, 3.7, 3.8] + python: [3.6, 3.7, 3.9] steps: - uses: actions/checkout@v2 @@ -33,5 +33,5 @@ jobs: run: | python -m pip install coveralls coveralls --service=github - if: ${{ matrix.python == '3.8' }} + if: ${{ matrix.python == '3.9' }} diff --git a/README.md b/README.md index 4bce5f5..ad90197 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ curl -sSL https://get.pimoroni.com/enviroplus | bash ## Or... Install from PyPi and configure manually: -* Run `sudo pip install enviroplus` +* Run `sudo python3 -m pip install enviroplus` **Note** this wont perform any of the required configuration changes on your Pi, you may additionally need to: diff --git a/install.sh b/install.sh index 6837697..a8513b6 100755 --- a/install.sh +++ b/install.sh @@ -139,14 +139,6 @@ printf "$LIBRARY_NAME $LIBRARY_VERSION Python Library: Installer\n\n" cd library -printf "Installing for Python 2..\n" -apt_pkg_install "${PY2_DEPS[@]}" -python setup.py install > /dev/null -if [ $? -eq 0 ]; then - success "Done!\n" - echo "pip uninstall $LIBRARY_NAME" >> $UNINSTALLER -fi - if [ -f "/usr/bin/python3" ]; then printf "Installing for Python 3..\n" apt_pkg_install "${PY3_DEPS[@]}" @@ -155,6 +147,9 @@ if [ -f "/usr/bin/python3" ]; then success "Done!\n" echo "pip3 uninstall $LIBRARY_NAME" >> $UNINSTALLER fi +else + printf "/usr/bin/python3 not found. Unable to install!\n" + exit 1 fi cd $WD diff --git a/library/CHANGELOG.txt b/library/CHANGELOG.txt index 4e59b22..4dd54d5 100644 --- a/library/CHANGELOG.txt +++ b/library/CHANGELOG.txt @@ -1,3 +1,8 @@ +0.0.5 +----- + +* Drop Python 2.x support + 0.0.4 ----- diff --git a/library/README.md b/library/README.md index 43572bf..a1136e8 100644 --- a/library/README.md +++ b/library/README.md @@ -35,7 +35,7 @@ curl -sSL https://get.pimoroni.com/enviroplus | bash ## Or... Install from PyPi and configure manually: -* Run `sudo pip install enviroplus` +* Run `sudo python3 -m pip install enviroplus` **Note** this wont perform any of the required configuration changes on your Pi, you may additionally need to: @@ -70,6 +70,12 @@ sudo apt install python-numpy python-smbus python-pil python-setuptools * Discord - https://discord.gg/hr93ByC # Changelog + +0.0.5 +----- + +* Drop Python 2.x support + 0.0.4 ----- diff --git a/library/enviroplus/__init__.py b/library/enviroplus/__init__.py index 156d6f9..eead319 100644 --- a/library/enviroplus/__init__.py +++ b/library/enviroplus/__init__.py @@ -1 +1 @@ -__version__ = '0.0.4' +__version__ = '0.0.5' diff --git a/library/setup.cfg b/library/setup.cfg index a6ba0ba..591de90 100644 --- a/library/setup.cfg +++ b/library/setup.cfg @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- [metadata] name = enviroplus -version = 0.0.4 +version = 0.0.5 author = Philip Howard author_email = phil@pimoroni.com description = Enviro pHAT Plus environmental monitoring add-on for Raspberry Pi @@ -20,13 +20,13 @@ classifiers = Operating System :: POSIX :: Linux License :: OSI Approved :: MIT License Intended Audience :: Developers - Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 Topic :: Software Development Topic :: Software Development :: Libraries Topic :: System :: Hardware [options] +python_requires = >= 3.6 packages = enviroplus install_requires = pimoroni-bme280 @@ -54,14 +54,6 @@ ignore = [pimoroni] py2deps = - python-pip - python-numpy - python-smbus - python-pil - python-cffi - python-spidev - python-rpi.gpio - libportaudio2 py3deps = python3-pip python3-numpy diff --git a/library/tox.ini b/library/tox.ini index aa96216..fcee079 100644 --- a/library/tox.ini +++ b/library/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{27,35},qa +envlist = py{36, 37, 38, 39},qa skip_missing_interpreters = True [testenv] From 47089ae867ac6aa9b4a3f23a02f10631fcd10aa5 Mon Sep 17 00:00:00 2001 From: Philip Howard Date: Tue, 2 Nov 2021 10:40:37 +0000 Subject: [PATCH 2/2] Linting fixes --- examples/luftdaten.py | 4 ++-- examples/mqtt-all.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/luftdaten.py b/examples/luftdaten.py index 0c13771..d0bee37 100755 --- a/examples/luftdaten.py +++ b/examples/luftdaten.py @@ -127,7 +127,7 @@ def send_to_luftdaten(values, id): resp_pm = None resp_bmp = None - + try: resp_pm = requests.post( "https://api.luftdaten.info/v1/push-sensor-data/", @@ -150,7 +150,7 @@ def send_to_luftdaten(values, id): except requests.exceptions.RequestException as e: logging.warning('Luftdaten PM Request Error: {}'.format(e)) - try: + try: resp_bmp = requests.post( "https://api.luftdaten.info/v1/push-sensor-data/", json={ diff --git a/examples/mqtt-all.py b/examples/mqtt-all.py index b725a6c..8220c67 100755 --- a/examples/mqtt-all.py +++ b/examples/mqtt-all.py @@ -1,9 +1,9 @@ +#!/usr/bin/env python3 """ Run mqtt broker on localhost: sudo apt-get install mosquitto mosquitto-clients Example run: python3 mqtt-all.py --broker 192.168.1.164 --topic enviro --username xxx --password xxxx """ -#!/usr/bin/env python3 import argparse import ST7735 @@ -43,6 +43,7 @@ DEFAULT_USERNAME = None DEFAULT_PASSWORD = None + # mqtt callbacks def on_connect(client, userdata, flags, rc): if rc == 0: @@ -99,7 +100,7 @@ def get_cpu_temperature(): ["vcgencmd", "measure_temp"], stdout=PIPE, universal_newlines=True ) output, _error = process.communicate() - return float(output[output.index("=") + 1 : output.rindex("'")]) + return float(output[output.index("=") + 1:output.rindex("'")]) # Get Raspberry Pi serial number to use as ID @@ -240,7 +241,7 @@ def main(): HAS_PMS = False try: pms5003 = PMS5003() - pm_values = pms5003.read() + _ = pms5003.read() HAS_PMS = True print("PMS5003 sensor is connected") except SerialTimeoutError: