Skip to content

Commit

Permalink
Merge pull request #10 from pimoroni/patch-refactor
Browse files Browse the repository at this point in the history
Refactor to setup.cfg, lint and cleanup
  • Loading branch information
Gadgetoid committed Mar 3, 2022
2 parents 7d83e24 + 511d8c1 commit 5eced36
Show file tree
Hide file tree
Showing 19 changed files with 640 additions and 68 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,37 @@
name: Python Tests

on:
pull_request:
push:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python: [2.7, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install Dependencies
run: |
python -m pip install --upgrade setuptools tox
- name: Run Tests
working-directory: library
run: |
tox -e py
- name: Coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: library
run: |
python -m pip install coveralls
coveralls --service=github
if: ${{ matrix.python == '3.9' }}

3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -16,3 +16,6 @@ __pycache__
packaging/*tar.xz
library/debian/
sphinx.virtualenv/
.coverage
.pytest_cache
.tox
70 changes: 70 additions & 0 deletions Makefile
@@ -0,0 +1,70 @@
LIBRARY_VERSION=$(shell grep version library/setup.cfg | awk -F" = " '{print $$2}')
LIBRARY_NAME=$(shell grep name library/setup.cfg | awk -F" = " '{print $$2}')

.PHONY: usage install uninstall
usage:
@echo "Library: ${LIBRARY_NAME}"
@echo "Version: ${LIBRARY_VERSION}\n"
@echo "Usage: make <target>, where target is one of:\n"
@echo "install: install the library locally from source"
@echo "uninstall: uninstall the local library"
@echo "check: peform basic integrity checks on the codebase"
@echo "python-readme: generate library/README.md from README.md + library/CHANGELOG.txt"
@echo "python-wheels: build python .whl files for distribution"
@echo "python-sdist: build python source distribution"
@echo "python-clean: clean python build and dist directories"
@echo "python-dist: build all python distribution files"
@echo "python-testdeploy: build all and deploy to test PyPi"
@echo "tag: tag the repository with the current version"

install:
./install.sh

uninstall:
./uninstall.sh

check:
@echo "Checking for trailing whitespace"
@! grep -IUrn --color "[[:blank:]]$$" --exclude-dir=sphinx --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO
@echo "Checking for DOS line-endings"
@! grep -IUrn --color "" --exclude-dir=sphinx --exclude-dir=.tox --exclude-dir=.git --exclude=Makefile
@echo "Checking library/CHANGELOG.txt"
@cat library/CHANGELOG.txt | grep ^${LIBRARY_VERSION}
@echo "Checking library/${LIBRARY_NAME}/__init__.py"
@cat library/${LIBRARY_NAME}/__init__.py | grep "^__version__ = '${LIBRARY_VERSION}'"

tag:
git tag -a "v${LIBRARY_VERSION}" -m "Version ${LIBRARY_VERSION}"

python-readme: library/README.md

python-license: library/LICENSE.txt

library/README.md: README.md library/CHANGELOG.txt
cp README.md library/README.md
printf "\n# Changelog\n" >> library/README.md
cat library/CHANGELOG.txt >> library/README.md

library/LICENSE.txt: LICENSE
cp LICENSE library/LICENSE.txt

python-wheels: python-readme python-license
cd library; python3 setup.py bdist_wheel
-cd library; python setup.py bdist_wheel

python-sdist: python-readme python-license
cd library; python3 setup.py sdist

python-clean:
-rm -r library/dist
-rm -r library/build
-rm -r library/*.egg-info

python-dist: python-clean python-wheels python-sdist
ls library/dist

python-testdeploy: python-dist
twine upload --repository-url https://test.pypi.org/legacy/ library/dist/*

python-deploy: check python-dist
twine upload library/dist/*
Expand Down
22 changes: 3 additions & 19 deletions README.md
Expand Up @@ -38,30 +38,14 @@ sudo raspi-config nonint do_i2c 0

#### Library install for Python 3:

on Raspbian:

```bash
sudo apt-get install python3-touchphat
```

other environments:

```bash
sudo pip3 install touchphat
sudo python3 -m pip install touchphat
```

#### Library install for Python 2:

on Raspbian:

```bash
sudo apt-get install python-touchphat
```

other environments:

```bash
sudo pip2 install touchphat
sudo python2 -m pip install touchphat
```

### Development:
Expand All @@ -71,7 +55,7 @@ If you want to contribute, or like living on the edge of your seat by having the
```bash
sudo python3 setup.py install
```
(or `sudo python setup.py install` whichever your primary Python environment may be)
(or `sudo python3 setup.py install` whichever your primary Python environment may be)

In all cases you will have to enable the i2c bus.

Expand Down
2 changes: 1 addition & 1 deletion examples/launcher.py
Expand Up @@ -17,7 +17,7 @@
A: Terminal
B: Browser
C: Idle
D: Dashboard
D: Dashboard
Back: Logout
Enter: Shutdown
Expand Down

0 comments on commit 5eced36

Please sign in to comment.