Skip to content

Commit

Permalink
Merge pull request #9 from pimoroni/patch-packaging
Browse files Browse the repository at this point in the history
Update packaging.
  • Loading branch information
Gadgetoid authored Apr 5, 2023
2 parents e82246b + 0614fd8 commit 4f96e24
Show file tree
Hide file tree
Showing 31 changed files with 605 additions and 598 deletions.
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 dist
- name: Upload Packages
uses: actions/upload-artifact@v3
with:
name: ${{ env.RELEASE_FILE }}
path: dist/
32 changes: 32 additions & 0 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: QA

on:
pull_request:
push:
branches:
- main

jobs:
test:
name: linting & spelling
runs-on: ubuntu-latest
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
22 changes: 13 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Python Tests
name: Tests

on:
pull_request:
Expand All @@ -8,30 +8,34 @@ on:

jobs:
test:
name: Python ${{ matrix.python }}
runs-on: ubuntu-latest
strategy:
matrix:
python: [2.7, 3.5, 3.7, 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 --upgrade setuptools 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' }}
2 changes: 2 additions & 0 deletions library/CHANGELOG.txt → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Changelog

0.0.1
-----

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Pimoroni Ltd.
Copyright (c) 2023 Pimoroni Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
90 changes: 40 additions & 50 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,70 +1,60 @@
LIBRARY_VERSION=$(shell grep version library/setup.cfg | awk -F" = " '{print $$2}')
LIBRARY_NAME=$(shell grep name library/setup.cfg | 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.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"
@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 -IUrn --color "[[:blank:]]$$" --exclude-dir=sphinx --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO
@echo "Checking for DOS line-endings"
@! grep -lIUrn --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}"
dev-deps:
python3 -m pip install -r requirements-dev.txt
sudo apt install dos2unix

python-readme: library/README.md

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

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
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
cd library; python setup.py bdist_wheel
nopost:
@bash check.sh --nopost

python-sdist: python-readme python-license
cd library; python 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-url https://test.pypi.org/legacy/ dist/*

python-deploy: check python-dist
twine upload library/dist/*
deploy: nopost build
twine upload dist/*
5 changes: 5 additions & 0 deletions PROJECT_NAME/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__version__ = '0.0.1'


def test():
return "Hello World"
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# {{TITLE}}
# __TITLE__

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

Generated from [the Pimoroni Python Boilerplate](https://github.com/pimoroni/boilerplate-python).

# Pre-requisites

Expand All @@ -18,13 +20,13 @@ You can optionally run `sudo raspi-config` or the graphical Raspberry Pi Configu

Stable library from PyPi:

* Just run `pip3 install {{LIBNAME}}`
* Just run `pip3 install PROJECT_NAME`

In some cases you may need to use `sudo` or install pip with: `sudo apt install python3-pip`

Latest/development library from GitHub:

* `git clone https://github.com/pimoroni/{{LIBNAME}}-python`
* `cd {{LIBNAME}}-python`
* `git clone https://github.com/pimoroni/PROJECT_NAME-python`
* `cd PROJECT_NAME-python`
* `sudo ./install.sh`

77 changes: 0 additions & 77 deletions _bootstrap.md

This file was deleted.

5 changes: 0 additions & 5 deletions _bootstrap.sh

This file was deleted.

3 changes: 0 additions & 3 deletions _bootstrap_remotes.sh

This file was deleted.

Loading

0 comments on commit 4f96e24

Please sign in to comment.