Skip to content

Commit 9d06be3

Browse files
authored
Replace setup.py with pyproject.toml (#244)
1 parent 3fec1c7 commit 9d06be3

File tree

8 files changed

+102
-106
lines changed

8 files changed

+102
-106
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,25 @@ jobs:
2525
with:
2626
python-version: ${{ matrix.python-version }}
2727

28+
- name: Install Python dependencies
29+
run: pip install build
30+
2831
- name: Install wpiformat
2932
run: |
3033
cd wpiformat
31-
pip install -e .
34+
python -m build --wheel
35+
pip install dist/*.whl
36+
shell: bash
3237

3338
- name: Install test dependencies
34-
shell: bash
35-
run: |
36-
if [ "$RUNNER_OS" == "Windows" ]; then
37-
# This pytest dependency is installed manually with bash because the
38-
# installation prints to stderr. Prints to stderr cause Powershell to
39-
# report a nonzero return code and cause the tests to fail.
40-
pip install wheel iniconfig
41-
fi
39+
run: pip install tox
4240

4341
- name: Run unit tests
4442
run: |
4543
git config --global user.email "[email protected]"
4644
git config --global user.name "Your Name"
4745
cd wpiformat
48-
python setup.py test
46+
tox
4947
5048
- name: wpiformat - whole repo
5149
run: |
@@ -127,10 +125,10 @@ jobs:
127125
python-version: '3.10'
128126

129127
- name: Install Python dependencies
130-
run: pip install wheel
128+
run: pip install build
131129

132130
- name: Build package
133-
run: python setup.py bdist_wheel
131+
run: python -m build
134132
working-directory: wpiformat
135133

136134
- name: Upload package to PyPi

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ local.properties
137137
.loadpath
138138

139139
### Python ###
140+
*.egg-info/
140141
.eggs/
141142
.pytest_cache/
143+
.tox/
144+
__pycache__/
142145
build/
143146
dist/
144-
__pycache__
145-
*.egg-info/
146-
version.py
147147

148148
# External tool builders
149149
.externalToolBuilders/
File renamed without changes.

wpiformat/pyproject.toml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[project]
2+
name = "wpiformat"
3+
description = "Linters and formatters for ensuring WPILib's source code conforms to its style guide"
4+
dynamic = [ "version" ]
5+
readme = "README.rst"
6+
dependencies = [
7+
"regex==2022.9.13",
8+
"black==23.3.0",
9+
"clang-format==16.0.4",
10+
"clang-tidy==15.0.2.1"
11+
]
12+
classifiers = [
13+
"Development Status :: 5 - Production/Stable",
14+
"Intended Audience :: Developers",
15+
"Intended Audience :: Education",
16+
"License :: OSI Approved :: BSD License",
17+
"Operating System :: OS Independent",
18+
"Topic :: Scientific/Engineering",
19+
"Programming Language :: Python :: 3"
20+
]
21+
22+
[project.license]
23+
text = "BSD-3-Clause"
24+
25+
[[project.maintainers]]
26+
name = "Tyler Veness"
27+
28+
29+
[project.urls]
30+
Homepage = "https://github.com/wpilibsuite/styleguide"
31+
32+
[project.scripts]
33+
wpiformat = "wpiformat:main"
34+
35+
[build-system]
36+
requires = [
37+
"clang-format==16.0.4",
38+
"clang-tidy==15.0.2.1",
39+
"regex==2022.9.13",
40+
"setuptools>=61.0",
41+
"setuptools-git-versioning"
42+
]
43+
build-backend = "setuptools.build_meta"
44+
45+
[tool.setuptools-git-versioning]
46+
enabled = true
47+
version_callback = "wpiformat.version:get_version"
48+
49+
[tool.pytest.ini_options]
50+
minversion = "6.0"
51+
testpaths = [ "wpiformat/test" ]

wpiformat/setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

wpiformat/setup.py

Lines changed: 0 additions & 89 deletions
This file was deleted.

wpiformat/tox.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[tox]
2+
min_version = 4.0
3+
env_list =
4+
py38
5+
py39
6+
py310
7+
py311
8+
9+
[testenv]
10+
deps = pytest
11+
commands = pytest

wpiformat/wpiformat/version.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from datetime import date
2+
import subprocess
3+
4+
5+
def get_version():
6+
proc = subprocess.run(
7+
[
8+
"git",
9+
"rev-list",
10+
"--count",
11+
# Includes previous year's commits in case one was merged after the
12+
# year incremented. Otherwise, the version wouldn't increment.
13+
'--after="main@{' + str(date.today().year - 1) + '-01-01}"',
14+
"main",
15+
],
16+
check=True,
17+
encoding="utf-8",
18+
stdout=subprocess.PIPE,
19+
)
20+
# If there is no main branch, the commit count defaults to 0
21+
if proc.returncode:
22+
commit_count = "0"
23+
else:
24+
commit_count = proc.stdout.rstrip()
25+
26+
# Version number: <year>.<# commits on main>
27+
return f"{date.today().year}.{commit_count}"

0 commit comments

Comments
 (0)