Skip to content

Commit

Permalink
Manage project with pyproject.toml and poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
clssn committed Aug 30, 2023
1 parent 86218b4 commit e6fbe68
Show file tree
Hide file tree
Showing 9 changed files with 777 additions and 69 deletions.
35 changes: 17 additions & 18 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,26 @@ name: Upload Python Package

on:
release:
types: [created]
types: [published]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
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@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install Poetry
run: >
pip install --upgrade pip &&
pip install pipx &&
python3 -m pipx ensurepath &&
pipx install poetry
- name: Install venv
run: poetry install
- run: poetry config pypi-token.pypi "${{ secrets.PYPI_API_KEY }}"
- name: Publish package
run: poetry publish --build
32 changes: 16 additions & 16 deletions .github/workflows/python-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9"]
python-version: ["3.8", "3.9", "3.10"]

steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Install package editable
run: |
pip install -e .
python-version: "${{ matrix.python-version }}"
- name: Install Poetry
run: >
pip install --upgrade pip &&
pip install pipx &&
python3 -m pipx ensurepath &&
pipx install poetry
- name: Install venv
run: poetry install
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 src tests --count --select=E9,F63,F7,F82 --show-source --statistics
poetry run flake8 src tests --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 src tests --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest tests
poetry run flake8 src tests --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test
run: poetry run pytest tests
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true
}
}
706 changes: 706 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[virtualenvs]
in-project = true
35 changes: 35 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[tool.poetry]
name = "numato-gpio"
version = "0.11.0"
description = "Python API for Numato GPIO Expanders"
authors = ["Henning Claßen <code@clssn.de>"]
license = "MIT License"
readme = "README.md"

classifiers=[
"Programming Language :: Python :: 3.8",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX :: Linux",
]

[project.urls]
Homepage = "https://github.com/clssn/numato-gpio"
Repository = "https://github.com/clssn/numato-gpio.git"

[tool.poetry.dependencies]
python = "^3.8.1"
pyserial = "^3.1"

[tool.poetry.group.dev.dependencies]
black = "^23.7.0"
pytest = "^7.4.0"
flake8 = "^6.1.0"
pyline = "^0.3.20"
bandit = "^1.7.5"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
numato-discover = "numato_gpio.__main__:main"
8 changes: 0 additions & 8 deletions requirements-dev.txt

This file was deleted.

1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

25 changes: 0 additions & 25 deletions setup.py

This file was deleted.

0 comments on commit e6fbe68

Please sign in to comment.