Skip to content

Commit

Permalink
Repackage to hatch/pyproject.toml.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Nov 20, 2023
1 parent 776addf commit 1a599df
Show file tree
Hide file tree
Showing 51 changed files with 769 additions and 870 deletions.
2 changes: 1 addition & 1 deletion library/.coveragerc → .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ source = inky
omit =
.tox/*
relative_files = True
data_file = ../.coverage
data_file = .coverage
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build

on:
pull_request:
push:
branches:
- main

jobs:
test:
name: Python ${{ matrix.python }}
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.9', '3.10', '3.11']

env:
RELEASE_FILE: ${{ github.event.repository.name }}-${{ github.event.release.tag_name || github.sha }}-py${{ matrix.python }}

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}

- name: Install Dependencies
run: |
make dev-deps
- name: Build Packages
run: |
make build
- name: Upload Packages
uses: actions/upload-artifact@v3
with:
name: ${{ env.RELEASE_FILE }}
path: dist/
36 changes: 36 additions & 0 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: QA

on:
pull_request:
push:
branches:
- main

jobs:
test:
name: linting & spelling
runs-on: ubuntu-latest

env:
TERM: xterm-256color

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set up Python '3,11'
uses: actions/setup-python@v3
with:
python-version: '3.11'

- name: Install Dependencies
run: |
make dev-deps
- name: Run Quality Assurance
run: |
make qa
- name: Run Code Checks
run: |
make check
25 changes: 14 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
name: Python Tests
name: Tests

on:
pull_request:
push:
branches:
- master
- main

jobs:
test:
name: Python ${{ matrix.python }}
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.9]
python: ['3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v2
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}

- name: Install Dependencies
run: |
python -m pip install tox
make dev-deps
- name: Run Tests
working-directory: library
run: |
tox -e py
make pytest
- name: Coverage
if: ${{ matrix.python == '3.9' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: library
run: |
python -m pip install coveralls
coveralls --service=github
if: ${{ matrix.python == '3.9' }}

5 changes: 0 additions & 5 deletions .stickler.yml

This file was deleted.

File renamed without changes.
File renamed without changes.
85 changes: 42 additions & 43 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,61 +1,60 @@
LIBRARY_VERSION=`cat library/setup.py | grep version | awk -F"'" '{print $$2}'`
LIBRARY_NAME=`cat library/setup.py | grep name | awk -F"'" '{print $$2}'`
LIBRARY_NAME := $(shell hatch project metadata name 2> /dev/null)
LIBRARY_VERSION := $(shell hatch version 2> /dev/null)

.PHONY: usage install uninstall
.PHONY: usage install uninstall check pytest qa build-deps check tag wheel sdist clean dist testdeploy deploy
usage:
ifdef LIBRARY_NAME
@echo "Library: ${LIBRARY_NAME}"
@echo "Version: ${LIBRARY_VERSION}\n"
else
@echo "WARNING: You should 'make dev-deps'\n"
endif
@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.rst from README.md"
@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 "install: install the library locally from source"
@echo "uninstall: uninstall the local library"
@echo "dev-deps: install Python dev dependencies"
@echo "check: perform basic integrity checks on the codebase"
@echo "qa: run linting and package QA"
@echo "pytest: run Python test fixtures"
@echo "clean: clean Python build and dist directories"
@echo "build: build Python distribution files"
@echo "testdeploy: build and upload to test PyPi"
@echo "deploy: build and upload to PyPi"
@echo "tag: tag the repository with the current version\n"

install:
./install.sh
./install.sh --unstable

uninstall:
./uninstall.sh

check:
@echo "Checking for trailing whitespace"
@! grep -IlUrn --color "[[:blank:]]$$" --exclude-dir=sphinx --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO
@echo "Checking for DOS line-endings"
@! grep -IlUrn --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}'"

python-readme: library/README.md
dev-deps:
python3 -m pip install -r requirements-dev.txt
sudo apt install dos2unix

python-license: library/LICENSE.txt
check:
@bash check.sh

library/README.md: README.md
cp README.md library/README.md
qa:
tox -e qa

library/LICENSE.txt: LICENSE
cp LICENSE library/LICENSE.txt
pytest:
tox -e py

python-wheels: python-readme python-license
cd library; python3 setup.py bdist_wheel
nopost:
@bash check.sh --nopost

python-sdist: python-readme python-license
cd library; python3 setup.py sdist
tag:
git tag -a "v${LIBRARY_VERSION}" -m "Version ${LIBRARY_VERSION}"

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

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

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

python-deploy: check python-dist
twine upload library/dist/*
deploy: nopost build
twine upload dist/*
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Inky

[![Build Status](https://travis-ci.com/pimoroni/inky.svg?branch=master)](https://travis-ci.com/pimoroni/inky)
[![Build Status](https://img.shields.io/github/actions/workflow/status/pimoroni/inky/test.yml?branch=main)](https://github.com/pimoroni/inky/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/pimoroni/inky/badge.svg?branch=master)](https://coveralls.io/github/pimoroni/inky?branch=master)
[![PyPi Package](https://img.shields.io/pypi/v/inky.svg)](https://pypi.python.org/pypi/inky)
[![Python Versions](https://img.shields.io/pypi/pyversions/inky.svg)](https://pypi.python.org/pypi/inky)


Python library for [Inky pHAT](https://shop.pimoroni.com/products/inky-phat), [Inky wHAT](https://shop.pimoroni.com/products/inky-what) and [Inky Impression](https://shop.pimoroni.com/?q=inky+impression) e-paper displays for Raspberry Pi.

## Inky pHAT

[Inky pHAT](https://shop.pimoroni.com/products/inky-phat) is a 250x122 pixel e-paper display, available in red/black/white, yellow/black/white and black/white. It's great for nametags and displaying very low frequency information such as a daily calendar or weather overview.


## Inky wHAT

[Inky wHAT](https://shop.pimoroni.com/products/inky-what) is a 400x300 pixel e-paper display available in red/black/white, yellow/black/white and black/white. It's got tons of resolution for detailed daily to-do lists, multi-day weather forecasts, bus timetables and more.
Expand All @@ -27,19 +27,11 @@ First, make sure you have I2C and SPI enabled in `sudo raspi-config`.
The Python pip package is named inky, on the Raspberry Pi install with:

```
pip3 install inky[rpi,example-depends]
python3 -m pip install inky
```

This will install Inky along with dependencies for the Raspberry Pi, plus fonts used by the examples.

If you want to simulate Inky on your desktop, use:

```
pip3 install inky
```

You may need to use `sudo pip3` or `sudo pip` depending on your environment and Python version.

# Usage

The library should be run with Python 3.
Expand Down
88 changes: 88 additions & 0 deletions check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/bash

# This script handles some basic QA checks on the source

NOPOST=$1
LIBRARY_NAME=`hatch project metadata name`
LIBRARY_VERSION=`hatch version | awk -F "." '{print $1"."$2"."$3}'`
POST_VERSION=`hatch version | awk -F "." '{print substr($4,0,length($4))}'`
TERM=${TERM:="xterm-256color"}

success() {
echo -e "$(tput setaf 2)$1$(tput sgr0)"
}

inform() {
echo -e "$(tput setaf 6)$1$(tput sgr0)"
}

warning() {
echo -e "$(tput setaf 1)$1$(tput sgr0)"
}

while [[ $# -gt 0 ]]; do
K="$1"
case $K in
-p|--nopost)
NOPOST=true
shift
;;
*)
if [[ $1 == -* ]]; then
printf "Unrecognised option: $1\n";
exit 1
fi
POSITIONAL_ARGS+=("$1")
shift
esac
done

inform "Checking $LIBRARY_NAME $LIBRARY_VERSION\n"

inform "Checking for trailing whitespace..."
grep -IUrn --color "[[:blank:]]$" --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO
if [[ $? -eq 0 ]]; then
warning "Trailing whitespace found!"
exit 1
else
success "No trailing whitespace found."
fi
printf "\n"

inform "Checking for DOS line-endings..."
grep -lIUrn --color $'\r' --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=Makefile
if [[ $? -eq 0 ]]; then
warning "DOS line-endings found!"
exit 1
else
success "No DOS line-endings found."
fi
printf "\n"

inform "Checking CHANGELOG.md..."
cat CHANGELOG.md | grep ^${LIBRARY_VERSION} > /dev/null 2>&1
if [[ $? -eq 1 ]]; then
warning "Changes missing for version ${LIBRARY_VERSION}! Please update CHANGELOG.md."
exit 1
else
success "Changes found for version ${LIBRARY_VERSION}."
fi
printf "\n"

inform "Checking for git tag ${LIBRARY_VERSION}..."
git tag -l | grep -E "${LIBRARY_VERSION}$"
if [[ $? -eq 1 ]]; then
warning "Missing git tag for version ${LIBRARY_VERSION}"
fi
printf "\n"

if [[ $NOPOST ]]; then
inform "Checking for .postN on library version..."
if [[ "$POST_VERSION" != "" ]]; then
warning "Found .$POST_VERSION on library version."
inform "Please only use these for testpypi releases."
exit 1
else
success "OK"
fi
fi
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions library/inky/inky.py → inky/inky.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
except ImportError:
raise ImportError('This library requires the numpy module\nInstall with: sudo apt install python-numpy')

__version__ = "1.5.0"

# Display colour codes
WHITE = 0
BLACK = 1
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 1a599df

Please sign in to comment.