Skip to content

Commit 47a0c22

Browse files
committed
Repackage to hatch/pyproject. Port to gpiod.
1 parent 3e63dc3 commit 47a0c22

36 files changed

+1000
-382
lines changed

library/.coveragerc .coveragerc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[run]
2-
source = ST7789
2+
source = st7789
33
omit =
44
.tox/*

.github/workflows/build.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
test:
11+
name: Python ${{ matrix.python }}
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python: ['3.9', '3.10', '3.11']
16+
17+
env:
18+
RELEASE_FILE: ${{ github.event.repository.name }}-${{ github.event.release.tag_name || github.sha }}-py${{ matrix.python }}
19+
20+
steps:
21+
- name: Checkout Code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Python ${{ matrix.python }}
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python }}
28+
29+
- name: Install Dependencies
30+
run: |
31+
make dev-deps
32+
33+
- name: Build Packages
34+
run: |
35+
make build
36+
37+
- name: Upload Packages
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: ${{ env.RELEASE_FILE }}
41+
path: dist/

.github/workflows/qa.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: QA
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
test:
11+
name: linting & spelling
12+
runs-on: ubuntu-latest
13+
env:
14+
TERM: xterm-256color
15+
16+
steps:
17+
- name: Checkout Code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python '3,11'
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.11'
24+
25+
- name: Install Dependencies
26+
run: |
27+
make dev-deps
28+
29+
- name: Run Quality Assurance
30+
run: |
31+
make qa
32+
33+
- name: Run Code Checks
34+
run: |
35+
make check
36+
37+
- name: Run Bash Code Checks
38+
run: |
39+
make shellcheck

.github/workflows/test.yml

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,41 @@
1-
name: Python Tests
1+
name: Tests
22

33
on:
44
pull_request:
55
push:
66
branches:
7-
- master
7+
- main
88

99
jobs:
1010
test:
11+
name: Python ${{ matrix.python }}
1112
runs-on: ubuntu-latest
1213
strategy:
1314
matrix:
14-
python: [2.7, 3.7, 3.8, 3.9]
15+
python: ['3.9', '3.10', '3.11']
1516

1617
steps:
17-
- uses: actions/checkout@v2
18+
- name: Checkout Code
19+
uses: actions/checkout@v3
20+
1821
- name: Set up Python ${{ matrix.python }}
19-
uses: actions/setup-python@v2
22+
uses: actions/setup-python@v5
2023
with:
2124
python-version: ${{ matrix.python }}
25+
2226
- name: Install Dependencies
2327
run: |
24-
python -m pip install --upgrade setuptools tox
28+
make dev-deps
29+
2530
- name: Run Tests
26-
working-directory: library
2731
run: |
28-
tox -e py
32+
make pytest
33+
2934
- name: Coverage
35+
if: ${{ matrix.python == '3.9' }}
3036
env:
3137
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32-
working-directory: library
3338
run: |
3439
python -m pip install coveralls
3540
coveralls --service=github
36-
if: ${{ matrix.python == '3.9' }}
3741

library/CHANGELOG.txt CHANGELOG.md

File renamed without changes.

Makefile

+49-32
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,66 @@
1-
.PHONY: usage install uninstall
1+
LIBRARY_NAME := $(shell hatch project metadata name 2> /dev/null)
2+
LIBRARY_VERSION := $(shell hatch version 2> /dev/null)
3+
4+
.PHONY: usage install uninstall check pytest qa build-deps check tag wheel sdist clean dist testdeploy deploy
25
usage:
6+
ifdef LIBRARY_NAME
7+
@echo "Library: ${LIBRARY_NAME}"
8+
@echo "Version: ${LIBRARY_VERSION}\n"
9+
else
10+
@echo "WARNING: You should 'make dev-deps'\n"
11+
endif
312
@echo "Usage: make <target>, where target is one of:\n"
4-
@echo "install: install the library locally from source"
5-
@echo "uninstall: uninstall the local library"
6-
@echo "python-readme: generate library/README.md from README.md"
7-
@echo "python-wheels: build python .whl files for distribution"
8-
@echo "python-sdist: build python source distribution"
9-
@echo "python-clean: clean python build and dist directories"
10-
@echo "python-dist: build all python distribution files"
13+
@echo "install: install the library locally from source"
14+
@echo "uninstall: uninstall the local library"
15+
@echo "dev-deps: install Python dev dependencies"
16+
@echo "check: perform basic integrity checks on the codebase"
17+
@echo "qa: run linting and package QA"
18+
@echo "pytest: run Python test fixtures"
19+
@echo "clean: clean Python build and dist directories"
20+
@echo "build: build Python distribution files"
21+
@echo "testdeploy: build and upload to test PyPi"
22+
@echo "deploy: build and upload to PyPi"
23+
@echo "tag: tag the repository with the current version\n"
24+
25+
version:
26+
@hatch version
1127

1228
install:
13-
./install.sh
29+
./install.sh --unstable
1430

1531
uninstall:
1632
./uninstall.sh
1733

18-
python-readme: library/README.md
34+
dev-deps:
35+
python3 -m pip install -r requirements-dev.txt
36+
sudo apt install dos2unix shellcheck
37+
38+
check:
39+
@bash check.sh
1940

20-
python-license: library/LICENSE.txt
41+
shellcheck:
42+
shellcheck *.sh
2143

22-
library/README.md: README.md library/CHANGELOG.txt
23-
cp README.md library/README.md
24-
printf "\n# Changelog\n" >> library/README.md
25-
cat library/CHANGELOG.txt >> library/README.md
44+
qa:
45+
tox -e qa
2646

27-
library/LICENSE.txt: LICENSE
28-
cp LICENSE library/LICENSE.txt
47+
pytest:
48+
tox -e py
2949

30-
python-wheels: python-readme python-license
31-
cd library; python3 setup.py bdist_wheel
32-
cd library; python setup.py bdist_wheel
50+
nopost:
51+
@bash check.sh --nopost
3352

34-
python-sdist: python-readme python-license
35-
cd library; python setup.py sdist
53+
tag: version
54+
git tag -a "v${LIBRARY_VERSION}" -m "Version ${LIBRARY_VERSION}"
3655

37-
python-clean:
38-
-rm -r library/dist
39-
-rm -r library/build
40-
-rm -r library/*.egg-info
56+
build: check
57+
@hatch build
4158

42-
python-dist: python-clean python-wheels python-sdist
43-
ls library/dist
59+
clean:
60+
-rm -r dist
4461

45-
python-deploy: python-dist
46-
twine upload library/dist/*
62+
testdeploy: build
63+
twine upload --repository testpypi dist/*
4764

48-
python-testdeploy: python-dist
49-
twine upload --repository-url https://test.pypi.org/legacy/ library/dist/*
65+
deploy: nopost build
66+
twine upload dist/*

README.md

+10-34
Original file line numberDiff line numberDiff line change
@@ -6,53 +6,29 @@
66
[![Python Versions](https://img.shields.io/pypi/pyversions/st7789.svg)](https://pypi.python.org/pypi/st7789)
77

88

9-
Python library to control ST7789 TFT LCD displays.
9+
Python library to control an ST7789 TFT LCD display
1010

11-
Designed to work with the following Pimoroni ST7789 based SPI breakouts and Raspberry Pi HATs:
11+
Designed specifically to work with a ST7789 based 240x240 pixel TFT SPI display. (Specifically the [1.3" SPI LCD from Pimoroni](https://shop.pimoroni.com/products/1-3-spi-colour-lcd-240x240-breakout)).
1212

13-
- [1.54" SPI Colour Square LCD (240x240) Breakout](https://shop.pimoroni.com/products/1-54-spi-colour-square-lcd-240x240-breakout)
14-
- [1.3" SPI Colour Square LCD (240x240) Breakout](https://shop.pimoroni.com/products/1-3-spi-colour-lcd-240x240-breakout)
15-
- [1.3" SPI Colour Round LCD (240x240) Breakout](https://shop.pimoroni.com/products/1-3-spi-colour-round-lcd-240x240-breakout)
16-
- [Display HAT Mini](https://shop.pimoroni.com/products/display-hat-mini) (2.0" 320x240 LCD)
17-
18-
![Photo showing four different Pimoroni ST7789-based products](st7789-combined.jpg)
13+
![Animated GIF showing the ST7789 SPI LCD displaying Deploy/Rainbows in alternating frames](https://raw.githubusercontent.com/pimoroni/st7789-python/master/square-lcd-breakout-1.gif)
1914

2015
# Installation
2116

22-
First, make sure you have the following dependencies:
17+
Make sure you have the following dependencies:
2318

24-
````bash
25-
sudo apt update
26-
sudo apt install python3-rpi.gpio python3-spidev python3-pip python3-pil python3-numpy
19+
````
20+
sudo apt-get update
21+
sudo apt-get install python-rpi.gpio python-spidev python-pip python-pil python-numpy
2722
````
2823

2924
Install this library by running:
3025

31-
````bash
32-
sudo pip3 install st7789
26+
````
27+
sudo pip install st7789
3328
````
3429

35-
You will also need to make sure I2C and SPI are enabled in raspi-config (`sudo raspi-config`) - you can find them under Interface Options.
36-
37-
# Examples
38-
39-
You can find some examples of use in the examples folder. Clone this repo with:
40-
41-
```bash
42-
git clone https://github.com/pimoroni/st7789-python
43-
```
44-
45-
and navigate into the examples folder with:
46-
47-
```bash
48-
cd ~/st7789-python/examples/
49-
```
50-
51-
You can pass most of them a parameter (`square`, `rect`, `round`, or `dhmini`) to specify the size/shape/rotation of screen, like this:
30+
You might also need to enable I2C and SPI in raspi-config. See example of usage in the examples folder.
5231

53-
```bash
54-
python3 shapes.py dhmini
55-
```
5632

5733
# Licensing & History
5834

ST7789.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from warnings import warn
2+
3+
from st7789 import * # noqa F403
4+
5+
warn("Using \"import ST7789\" is deprecated. Please \"import st7789\" (all lowercase)!", DeprecationWarning, stacklevel=2)

check.sh

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
3+
# This script handles some basic QA checks on the source
4+
5+
NOPOST=$1
6+
LIBRARY_NAME=$(hatch project metadata name)
7+
LIBRARY_VERSION=$(hatch version | awk -F "." '{print $1"."$2"."$3}')
8+
POST_VERSION=$(hatch version | awk -F "." '{print substr($4,0,length($4))}')
9+
TERM=${TERM:="xterm-256color"}
10+
11+
success() {
12+
echo -e "$(tput setaf 2)$1$(tput sgr0)"
13+
}
14+
15+
inform() {
16+
echo -e "$(tput setaf 6)$1$(tput sgr0)"
17+
}
18+
19+
warning() {
20+
echo -e "$(tput setaf 1)$1$(tput sgr0)"
21+
}
22+
23+
while [[ $# -gt 0 ]]; do
24+
K="$1"
25+
case $K in
26+
-p|--nopost)
27+
NOPOST=true
28+
shift
29+
;;
30+
*)
31+
if [[ $1 == -* ]]; then
32+
printf "Unrecognised option: %s\n" "$1";
33+
exit 1
34+
fi
35+
POSITIONAL_ARGS+=("$1")
36+
shift
37+
esac
38+
done
39+
40+
inform "Checking $LIBRARY_NAME $LIBRARY_VERSION\n"
41+
42+
inform "Checking for trailing whitespace..."
43+
if grep -IUrn --color "[[:blank:]]$" --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO; then
44+
warning "Trailing whitespace found!"
45+
exit 1
46+
else
47+
success "No trailing whitespace found."
48+
fi
49+
printf "\n"
50+
51+
inform "Checking for DOS line-endings..."
52+
if grep -lIUrn --color $'\r' --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=Makefile; then
53+
warning "DOS line-endings found!"
54+
exit 1
55+
else
56+
success "No DOS line-endings found."
57+
fi
58+
printf "\n"
59+
60+
inform "Checking CHANGELOG.md..."
61+
if ! grep "^${LIBRARY_VERSION}" CHANGELOG.md > /dev/null 2>&1; then
62+
warning "Changes missing for version ${LIBRARY_VERSION}! Please update CHANGELOG.md."
63+
exit 1
64+
else
65+
success "Changes found for version ${LIBRARY_VERSION}."
66+
fi
67+
printf "\n"
68+
69+
inform "Checking for git tag ${LIBRARY_VERSION}..."
70+
if ! git tag -l | grep -E "${LIBRARY_VERSION}$"; then
71+
warning "Missing git tag for version ${LIBRARY_VERSION}"
72+
fi
73+
printf "\n"
74+
75+
if [[ $NOPOST ]]; then
76+
inform "Checking for .postN on library version..."
77+
if [[ "$POST_VERSION" != "" ]]; then
78+
warning "Found .$POST_VERSION on library version."
79+
inform "Please only use these for testpypi releases."
80+
exit 1
81+
else
82+
success "OK"
83+
fi
84+
fi

0 commit comments

Comments
 (0)