Skip to content

Commit

Permalink
Fix #75 -- Update packaging and CI to PEP518
Browse files Browse the repository at this point in the history
Close #74
  • Loading branch information
codingjoe committed Jan 10, 2023
1 parent f7160a6 commit d9ee05f
Show file tree
Hide file tree
Showing 11 changed files with 250 additions and 51 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# http://editorconfig.org

root = true

[*]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
end_of_line = lf
max_line_length = 88

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

[LICENSE]
insert_final_newline = false
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
77 changes: 77 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: CI
on:
push:
branches:
- master
- 3.x
pull_request:

jobs:

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/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/checkout@v2
- 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 html docs docs/_build

dist:
runs-on: ubuntu-latest
steps:
- 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 check dist/*
- uses: actions/upload-artifact@v3
with:
path: dist/*

pytest:
needs:
- lint
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
python-version:
- 3.7
- 3.8
- 3.9
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install .[test]
- run: python -m pytest
- uses: codecov/codecov-action@v3
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release

on:
release:
types: [published]

jobs:

PyPi:
runs-on: ubuntu-latest
steps:
- 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 }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ dist/
include/
lib/
docs/_build/
.coverage

# 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
83 changes: 83 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
[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 = []

This comment has been minimized.

Copy link
@syphar

syphar Jan 10, 2023

@codingjoe it looks like you forgot to add sympy as dependency here.

3.2.x needs it, 4.0 doesn't


[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",
]

[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"
50 changes: 4 additions & 46 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,46 +1,4 @@
[metadata]
name = measurement
author = Adam Coddington
author_email = [email protected]
description = Easily use and manipulate unit-aware measurements in Python
long_description = file: README.rst
url = http://github.com/coddingtonbear/python-measurement
license = MIT
license_file = LICENSE
classifier =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 3
Topic :: Utilities
keywords =
measurement

[options]
packages = find:
include_package_data = True
install_requires =
sympy>=0.7.3
setup_requires =
setuptools_scm
sphinx
pytest-runner
tests_require =
pytest

[options.packages.find]
exclude =
tests

[bdist_wheel]
universal = 1

[aliases]
test = pytest

[build_sphinx]
source-dir = docs
build-dir = docs/_build
[flake8]
max-line-length=88
select = C,E,F,W,B,B950
ignore = E203, E501, W503, E731
5 changes: 0 additions & 5 deletions setup.py

This file was deleted.

0 comments on commit d9ee05f

Please sign in to comment.