Skip to content

Commit 5751a56

Browse files
authored
Rework simplefractions packaging (#28)
This PR reworks the packaging of simplefractions. In detail: - Eliminate `setup.cfg` - Move all project configuration into `pyproject.toml` - Update the `on-commit` workflow to use more recent action versions and to cache packages - Add a few missing entries to `.gitignore` - Move flake8 config to `.flake8`, and config of all other tools to `pyproject.toml` - Move package source under `src/`, so that we can benefit from setuptools automated package detection - Use `setuptools_scm` to compute get version metadata
1 parent 3ede067 commit 5751a56

File tree

13 files changed

+95
-53
lines changed

13 files changed

+95
-53
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 88

.github/workflows/on-commit.yml

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,45 @@
22

33
name: on-commit
44

5-
on: pull_request
5+
on: [pull_request, workflow_dispatch]
66

77
jobs:
88
test:
99
runs-on: ubuntu-latest
1010

1111
strategy:
1212
matrix:
13-
python-version: ['3.6', '3.9', '3.10', 'pypy-3.7']
13+
python-version: ['3.6', '3.8', '3.10', '3.11-dev', 'pypy3.9']
1414

1515
steps:
16-
- name: Check out the code
17-
uses: actions/checkout@v2
16+
- uses: actions/checkout@v3
1817
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v2
18+
uses: actions/setup-python@v4
2019
with:
2120
python-version: ${{ matrix.python-version }}
22-
- name: Test with unittest
23-
run: |
24-
python -m unittest
21+
cache: 'pip'
22+
cache-dependency-path: 'requirements/test.txt'
23+
- name: Install dependencies
24+
run: python -m pip install -r requirements/test.txt
25+
- name: Test with pytest
26+
run: python -m pytest
2527

2628
style:
2729
runs-on: ubuntu-latest
2830

29-
strategy:
30-
matrix:
31-
python-version: ['3.10']
32-
3331
steps:
34-
- name: Check out the code
35-
uses: actions/checkout@v2
36-
- name: Set up Python ${{ matrix.python-version }}
37-
uses: actions/setup-python@v2
32+
- uses: actions/checkout@v3
33+
- name: Set up Python 3.10
34+
uses: actions/setup-python@v4
3835
with:
39-
python-version: ${{ matrix.python-version }}
36+
python-version: '3.10'
37+
cache: 'pip'
38+
cache-dependency-path: 'requirements/style.txt'
4039
- name: Install dependencies
41-
run: |
42-
python -m pip install --upgrade pip setuptools wheel
43-
python -m pip install black flake8 isort mypy
40+
run: python -m pip install -r requirements/style.txt
4441
- name: Run style checks
4542
run: |
4643
python -m flake8 .
47-
python -m isort --check .
48-
python -m black --check .
44+
python -m isort --check --diff .
45+
python -m black --check --diff .
4946
python -m mypy --strict .

.github/workflows/on-release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: on-release
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
build-and-upload:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up Python 3.10
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: '3.10'
18+
cache: 'pip'
19+
cache-dependency-path: 'requirements/publish.txt'
20+
- name: Install dependencies
21+
run: python -m pip install -r requirements/publish.txt
22+
- name: Build sdist and wheel
23+
run: python -m build
24+
- name: Publish to PyPI
25+
env:
26+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
27+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
28+
run: |
29+
python -m twine check --strict dist/*
30+
python -m twine upload dist/*

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1+
# Python bytecode
12
*.pyc
3+
4+
# Build and distribution
5+
/dist/
6+
/src/*.egg-info/

pyproject.toml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
11
[build-system]
2-
requires = ['setuptools', 'wheel']
2+
requires = ['setuptools>=61', 'setuptools-scm[toml]>=6.2', 'wheel']
33
build-backend = 'setuptools.build_meta'
4+
5+
[project]
6+
name = 'simplefractions'
7+
description = 'Find the simplest fraction for a given float or interval'
8+
readme = 'README.md'
9+
requires-python = '>=3.6'
10+
license = {file = 'LICENSE'}
11+
authors = [
12+
{name = 'Mark Dickinson', email = '[email protected]'}
13+
]
14+
keywords = ['fractions', 'continued fractions', 'approximation']
15+
classifiers = [
16+
'License :: OSI Approved :: Apache Software License',
17+
'Operating System :: OS Independent',
18+
'Programming Language :: Python :: 3',
19+
'Topic :: Scientific/Engineering :: Mathematics',
20+
]
21+
dynamic = ['version']
22+
23+
[project.urls]
24+
source = 'https://github.com/mdickinson/simplefractions'
25+
26+
[tool.black]
27+
target-version = ['py36']
28+
29+
[tool.isort]
30+
profile = 'black'
31+
order_by_type = 'False'
32+
33+
[tool.setuptools_scm]
34+
version_scheme = 'release-branch-semver'

requirements/publish.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build
2+
twine

requirements/style.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
black
2+
flake8
3+
isort
4+
mypy

requirements/test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest

setup.cfg

Lines changed: 0 additions & 30 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)