Skip to content

Commit 6daf914

Browse files
Drop support for Python 2.7 (#21)
* drop python 2.7 support * ci: move to github actions * update metadata Co-authored-by: Richard Hull <[email protected]>
1 parent 8204641 commit 6daf914

10 files changed

+123
-61
lines changed

.github/workflows/main.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: RPi.bme280
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest]
15+
python-minor-version: [6, 7, 8, 9, 10-dev]
16+
name: Python 3.${{ matrix.python-minor-version }}
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Setup pip cache
20+
uses: actions/cache@v2
21+
id: pipcache
22+
with:
23+
path: ~/.cache/pip
24+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
25+
restore-keys: |
26+
${{ runner.os }}-pip-
27+
- name: Set up Python
28+
uses: actions/setup-python@v2
29+
with:
30+
python-version: 3.${{ matrix.python-minor-version }}
31+
- name: Display Python version
32+
run: python -c "import sys; print(sys.version)"
33+
- name: Install Python packages
34+
run: pip install --upgrade setuptools pip wheel tox coveralls
35+
- name: Run tests
36+
env:
37+
TOX_ENV: py3${{ matrix.python-minor-version }}
38+
run: |
39+
python_env=$(echo $TOX_ENV | sed -e s/-dev$//)
40+
python -m tox -e ${python_env}
41+
- name: QA
42+
env:
43+
TOX_ENV: qa,doc
44+
run: python -m tox -e $TOX_ENV
45+
- name: Coveralls
46+
run: coveralls --service=github
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
COVERALLS_FLAG_NAME: ${{ matrix.test-name }}
50+
COVERALLS_PARALLEL: true
51+
52+
coveralls:
53+
name: Coveralls
54+
needs: build
55+
runs-on: ubuntu-latest
56+
container: python:3-slim
57+
steps:
58+
- name: Finished
59+
run: |
60+
pip3 install --upgrade coveralls
61+
coveralls --finish
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/publish-to-pypi.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build-and-publish:
10+
name: Build and publish Python package
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Set up Python 3.9
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: 3.9
18+
- name: Install pypa/build
19+
run: |
20+
python -m pip install --upgrade setuptools pip wheel
21+
python -m pip install build --user
22+
- name: Build a binary wheel and a source tarball
23+
run: python -m build --sdist --wheel --outdir dist/ .
24+
- name: Publish package to test PyPI
25+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
26+
uses: pypa/gh-action-pypi-publish@master
27+
with:
28+
user: __token__
29+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
30+
repository_url: https://test.pypi.org/legacy/
31+
- name: Publish package to PyPI
32+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
33+
uses: pypa/gh-action-pypi-publish@master
34+
with:
35+
user: __token__
36+
password: ${{ secrets.PYPI_API_TOKEN }}
37+
38+

.travis.yml

-22
This file was deleted.

LICENSE.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MIT License
22
===========
33

4-
Copyright (c) 2016 Richard Hull
4+
Copyright (c) 2016-2021 Richard Hull
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy
77
of this software and associated documentation files (the "Software"), to deal

README.rst

+8-15
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ BME280 Sensor Driver
1212
.. image:: https://img.shields.io/pypi/v/rpi-bme280.svg
1313
:target: https://pypi.python.org/pypi/rpi-bme280
1414

15-
.. image:: https://img.shields.io/maintenance/yes/2020.svg?maxAge=2592000
15+
.. image:: https://img.shields.io/maintenance/yes/2021.svg?maxAge=2592000
1616

1717

1818
Interfacing a Bosch BME280 digital sensor module (capable of sensing
19-
temperature, humidity and pressure) in Python 2 or 3 using I2C on the Raspberry
19+
temperature, humidity and pressure) in Python 3 using I2C on the Raspberry
2020
Pi. The particular kit I bought can be acquired for a few pounds from `eBay
2121
<http://www.ebay.co.uk/itm/311728184519>`_. Further technical details for the
2222
BME280 sensor can be found in the `datasheet
@@ -103,22 +103,15 @@ use 0 for the bus not 1)::
103103

104104
Installing the Python Package
105105
-----------------------------
106-
For python2, from the bash prompt, enter::
106+
From the bash prompt, enter::
107107

108-
$ sudo python setup.py install
108+
$ sudo python3 setup.py install
109109

110-
This will install the Python files in ``/usr/local/lib/python2.7``
111-
making them ready for use in other programs.
112-
113-
Alternatively for python3, type::
114-
115-
$ sudo python3 setup.py install
116-
117-
Cheeseshop install
118-
^^^^^^^^^^^^^^^^^^
110+
PyPi install
111+
^^^^^^^^^^^^
119112
Alternatively, a version on PyPi is available, just do::
120113

121-
$ sudo pip install RPi.bme280
114+
$ sudo pip3 install RPi.bme280
122115

123116
Software Driver - Example Usage
124117
-------------------------------
@@ -177,7 +170,7 @@ License
177170
-------
178171
The MIT License (MIT)
179172

180-
Copyright (c) 2016-2020 Richard Hull
173+
Copyright (c) 2016-2021 Richard Hull
181174

182175
Permission is hereby granted, free of charge, to any person obtaining a copy
183176
of this software and associated documentation files (the "Software"), to deal

setup.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def _read_version():
2020
needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
2121
pytest_runner = ['pytest-runner'] if needs_pytest else []
2222
test_deps = [
23-
'mock;python_version<"3.3"',
2423
'pytest>=3.1',
2524
'pytest-cov'
2625
]
@@ -42,6 +41,7 @@ def _read_version():
4241
install_requires=["pytz", "smbus2"],
4342
setup_requires=pytest_runner,
4443
tests_require=test_deps,
44+
python_requires=">=3.6, <4",
4545
extras_require={
4646
'qa': [
4747
'rstcheck',
@@ -56,11 +56,11 @@ def _read_version():
5656
"Intended Audience :: Developers",
5757
"Topic :: Education",
5858
"Topic :: System :: Hardware",
59-
"Programming Language :: Python :: 2",
60-
"Programming Language :: Python :: 2.7",
6159
"Programming Language :: Python :: 3",
62-
"Programming Language :: Python :: 3.4",
63-
"Programming Language :: Python :: 3.5",
64-
"Programming Language :: Python :: 3.6"
60+
"Programming Language :: Python :: 3.6",
61+
"Programming Language :: Python :: 3.7",
62+
"Programming Language :: Python :: 3.8",
63+
"Programming Language :: Python :: 3.9",
64+
"Programming Language :: Python :: 3.10"
6565
]
6666
)

tests/test_bme280.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (c) 2018 Richard Hull
2+
# Copyright (c) 2018-2021 Richard Hull
33
# See LICENSE.rst for details.
44

5-
6-
try:
7-
from unittest.mock import Mock, MagicMock
8-
except ImportError:
9-
from mock import Mock, MagicMock # noqa: F401
10-
5+
from unittest.mock import Mock, MagicMock
116
from datetime import datetime
127
import bme280
138
import pytz

tests/test_const.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (c) 2018 Richard Hull
2+
# Copyright (c) 2018-2021 Richard Hull
33
# See LICENSE.rst for details.
44

55
import bme280.const as c

tests/test_reader.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (c) 2018 Richard Hull
2+
# Copyright (c) 2018-2021 Richard Hull
33
# See LICENSE.rst for details.
44

5-
6-
try:
7-
from unittest.mock import Mock, MagicMock
8-
except ImportError:
9-
from mock import Mock, MagicMock # noqa: F401
10-
5+
from unittest.mock import Mock, MagicMock
116
from bme280.reader import reader
127

138
smbus = Mock(unsafe=True)

tox.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Copyright (c) 2018 Richard Hull
1+
# Copyright (c) 2018-2021 Richard Hull
22
# See LICENSE.rst for details.
33

44
[tox]
5-
envlist = py{27,34,35,36,37},qa
5+
envlist = py{36,37,38,39},qa
66
skip_missing_interpreters = True
77

88
[testenv]

0 commit comments

Comments
 (0)