Skip to content

Commit

Permalink
Fix #75 -- Update packaging and CI to PEP518
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe committed Jan 10, 2023
1 parent 2fb3b95 commit a392068
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 162 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ charset = utf-8
end_of_line = lf
max_line_length = 88

[*.{json,yml,yaml}]
[*.{json,yml,yaml,toml}]
indent_size = 2

[LICENSE]
Expand Down
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: weekly
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
89 changes: 31 additions & 58 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,73 +7,49 @@ on:

jobs:

bandit:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v1
- uses: actions/checkout@v2
- run: python -m pip install bandit==1.6.2
- run: bandit -r .

isort:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v1
- uses: actions/checkout@v2
- run: python -m pip install isort
- run: isort --check-only --diff --recursive .

flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v1
- uses: actions/checkout@v2
- run: python -m pip install flake8
- run: flake8 .

pydocstyle:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v1
- uses: actions/checkout@v2
- run: python -m pip install pydocstyle
- run: pydocstyle .

black:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
lint-command:
- bandit -r . -x ./tests
- black --check --diff .
- flake8 .
- isort --check-only --diff .
- pydocstyle .
steps:
- uses: actions/setup-python@v1
- uses: actions/checkout@v2
- run: python -m pip install black
- run: black --check --diff .
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
cache: 'pip'
cache-dependency-path: 'linter-requirements.txt'
- run: python -m pip install -r linter-requirements.txt
- run: ${{ matrix.lint-command }}

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v1
- run: sudo apt-get install -y graphviz
- uses: actions/checkout@v2
- run: git fetch --prune --unshallow
- run: python -m pip install pip setuptools wheel
- run: python setup.py develop
- run: python setup.py build_sphinx -W
- uses: actions/setup-python@v3
with:
python-version: 3.11
- run: sudo apt-get install -y graphviz
- run: python -m pip install -e '.[docs]'
- run: python -m sphinx -W -b spelling docs docs/_build

dist:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v1
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- run: python -m pip install --upgrade pip setuptools wheel twine readme-renderer
- uses: actions/checkout@v2
- run: python setup.py sdist bdist_wheel
- run: python -m twine check dist/*

pytest:
needs:
- bandit
- black
- flake8
- isort
- pydocstyle
- lint
strategy:
matrix:
os:
Expand All @@ -86,13 +62,10 @@ jobs:
- 3.9
runs-on: ${{ matrix.os }}
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v2
- run: python -m pip install --upgrade setuptools wheel codecov
- run: python setup.py test
- run: codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- run: python -m pip install .[test]
- run: python -m pytest
- uses: codecov/codecov-action@v3
21 changes: 10 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ jobs:
PyPi:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v1
- uses: actions/checkout@v2
- name: Install dependencies
run: python -m pip install --upgrade pip setuptools wheel twine
- name: Build dist packages
run: python setup.py sdist bdist_wheel
- name: Upload packages
run: python -m twine upload dist/*
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- run: python -m pip install --upgrade pip build wheel twine
- run: python -m build --sdist --wheel
- run: python -m twine upload dist/*
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ lib/
docs/_build/
.coverage
htmlcov/

# packaging
measurement/_version.py
22 changes: 22 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

version: 2

build:
os: ubuntu-20.04
tools:
python: "3.11"
apt_packages:
- graphviz

sphinx:
configuration: docs/conf.py

python:
install:
- method: pip
path: .
extra_requirements:
- docs
5 changes: 5 additions & 0 deletions linter-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bandit==1.7.4
black==22.10.0
flake8==5.0.4
isort==5.10.1
pydocstyle[toml]==6.1.1
6 changes: 6 additions & 0 deletions measurement/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Easily use and manipulate unit-aware measurements in Python."""

from . import _version

__version__ = _version.version
VERSION = _version.version_tuple
84 changes: 84 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
[build-system]
requires = ["flit_core>=3.2", "flit_scm", "wheel"]
build-backend = "flit_scm:buildapi"

[project]
name = "measurement"
authors = [
{ name = "Adam Coddington", email = "[email protected]" },
{ name = "Johannes Maron", email = "[email protected]" }
]
readme = "README.rst"
license = { file = "LICENSE" }
dynamic = ["version", "description"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: JavaScript",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Software Development",
"Topic :: Utilities",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Astronomy",
"Topic :: Scientific/Engineering :: Atmospheric Science",
"Topic :: Scientific/Engineering :: Chemistry",
"Topic :: Scientific/Engineering :: GIS",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Software Development :: Localization",
]
keywords = [
"measurement",
]
requires-python = ">=3.7"
dependencies = []

[project.optional-dependencies]
test = [
"pytest",
"pytest-cov",
]
docs = [
"sphinx",
"python-docs-theme",
]

[project.urls]
Project-URL = "http://github.com/coddingtonbear/python-measurement"

[tool.flit.module]
name = "measurement"

[tool.setuptools_scm]
write_to = "measurement/_version.py"

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "--doctest-glob='*.rst --doctest-modules --cov=measurement"
testpaths = [
"tests",
]
env = "D:DRAMATIQ_BROKER = dramatiq.brokers.stub.StubBroker"

[tool.coverage.report]
show_missing = true

[tool.isort]
atomic = true
line_length = 88
known_first_party = "measurement, tests"
include_trailing_comma = true
default_section = "THIRDPARTY"
combine_as_imports = true

[tool.pydocstyle]
add_ignore = "D1"
match_dir = "(?!tests|env|docs|\\.).*"
match = "(?!setup).*.py"
88 changes: 0 additions & 88 deletions setup.cfg

This file was deleted.

4 changes: 0 additions & 4 deletions setup.py

This file was deleted.

0 comments on commit a392068

Please sign in to comment.