Skip to content

Commit

Permalink
Switch to newer build and publish format
Browse files Browse the repository at this point in the history
  • Loading branch information
tinue committed Jan 26, 2024
1 parent 15d7842 commit c7a1a5f
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 80 deletions.
57 changes: 37 additions & 20 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,45 @@
name: Upload Python Package to PyPi
name: Build and publish apa102-pi

on:
release:
types: [released]

jobs:
deploy:
build:
name: Build the library
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install build
run: >-
python3 -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: Publish apa102-pi to PyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/apa102-pi
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish apa102-pi to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
59 changes: 39 additions & 20 deletions .github/workflows/pythonpublishprerelease.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,47 @@
name: Upload Python Package to Test PyPi
name: Build and publish apa102-pi

on:
release:
types: [prereleased]

jobs:
deploy-test:
build:
name: Build the library
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: develop
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install build
run: >-
python3 -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-testpypi:
name: Publish apa102-pi to TestPyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/apa102-pi
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish apa102-pi to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
2 changes: 1 addition & 1 deletion AnsiblePlaybook/hosts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[pi]
ledpi.local
ledpi.local
9 changes: 7 additions & 2 deletions AnsiblePlaybook/roles/apa102_install/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@
dest: "~/{{ apa102_install_dev_dir }}/apa102-pi"
update: false
version: develop # Use 'main' for the stable version.
- name: Install the Python dependencies into a virtual env
- name: Install the library and its dependencies into a virtual env
ansible.builtin.pip:
requirements: "~/{{ apa102_install_dev_dir }}/apa102-pi/requirements.txt"
name: apa102-pi
virtualenv: "~/{{ apa102_install_dev_dir }}/apa102-pi/venv"
virtualenv_command: python3 -m venv
virtualenv_site_packages: true
- name: Remove the library, but keep the dependencies
ansible.builtin.pip:
name: apa102-pi
state: absent
virtualenv: "~/{{ apa102_install_dev_dir }}/apa102-pi/venv"
- name: Activate SPI
become: true
ansible.builtin.command:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ To retrieve the full library including source code, and use a virtual env in the
- Get the APA102 Library and sample light programs: `git clone https://github.com/tinue/apa102-pi.git && cd apa102-pi`
- Create the virtual environment: `python3 -m venv --system-site-packages ./venv`
- Activate the virtual env: `source venv/bin/activate`
- Install the dependencies: `pip install -r requirements.txt`
- Install the dependencies: `python -m pip install .` (this will also install the library itself from the checked out source)
- To remove the just installed library, and use the source code instead, do this: `python -m pip uninstall apa102-pi`
- You might want to set the number of LEDs to match your strip: `nano runcolorcycle.py`; Update the number, Ctrl-X and "Yes" to save.
- Run the sample lightshow: `./runcolorcycle.py`.

Expand Down
33 changes: 33 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "apa102-pi"
version = "2.5.2"
authors = [
{ name="Martin Erzberger", email="martin@erzberger.ch" },
]
description = "Driver for APA102 LEDs on a Raspberry Pi"
readme = "README.md"
requires-python = ">3"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Intended Audience :: Education",
"Operating System :: POSIX :: Linux",
"Topic :: Education",
"Topic :: System :: Hardware :: Hardware Drivers",
"Topic :: Software Development :: Libraries :: Python Modules",
]
keywords = ["apa102", "led", "SK9822", "superled", "dotstar", "raspberry pi"]
dependencies = [
"adafruit-circuitpython-bitbangio",
"adafruit-circuitpython-busdevice",
]
[tool.setuptools]
packages = ["apa102_pi", "apa102_pi.colorschemes", "apa102_pi.driver"]

[project.urls]
Homepage = "https://github.com/tinue/apa102-pi"
Issues = "https://github.com/tinue/apa102-pi/issues"
36 changes: 0 additions & 36 deletions setup.py

This file was deleted.

0 comments on commit c7a1a5f

Please sign in to comment.