Skip to content

Commit

Permalink
Replace setup.py with pyproject.toml (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul authored Jul 6, 2023
1 parent 3fec1c7 commit 9d06be3
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 106 deletions.
22 changes: 10 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,25 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install Python dependencies
run: pip install build

- name: Install wpiformat
run: |
cd wpiformat
pip install -e .
python -m build --wheel
pip install dist/*.whl
shell: bash

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

- name: Run unit tests
run: |
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
cd wpiformat
python setup.py test
tox
- name: wpiformat - whole repo
run: |
Expand Down Expand Up @@ -127,10 +125,10 @@ jobs:
python-version: '3.10'

- name: Install Python dependencies
run: pip install wheel
run: pip install build

- name: Build package
run: python setup.py bdist_wheel
run: python -m build
working-directory: wpiformat

- name: Upload package to PyPi
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ local.properties
.loadpath

### Python ###
*.egg-info/
.eggs/
.pytest_cache/
.tox/
__pycache__/
build/
dist/
__pycache__
*.egg-info/
version.py

# External tool builders
.externalToolBuilders/
Expand Down
File renamed without changes.
51 changes: 51 additions & 0 deletions wpiformat/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[project]
name = "wpiformat"
description = "Linters and formatters for ensuring WPILib's source code conforms to its style guide"
dynamic = [ "version" ]
readme = "README.rst"
dependencies = [
"regex==2022.9.13",
"black==23.3.0",
"clang-format==16.0.4",
"clang-tidy==15.0.2.1"
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering",
"Programming Language :: Python :: 3"
]

[project.license]
text = "BSD-3-Clause"

[[project.maintainers]]
name = "Tyler Veness"
email = "[email protected]"

[project.urls]
Homepage = "https://github.com/wpilibsuite/styleguide"

[project.scripts]
wpiformat = "wpiformat:main"

[build-system]
requires = [
"clang-format==16.0.4",
"clang-tidy==15.0.2.1",
"regex==2022.9.13",
"setuptools>=61.0",
"setuptools-git-versioning"
]
build-backend = "setuptools.build_meta"

[tool.setuptools-git-versioning]
enabled = true
version_callback = "wpiformat.version:get_version"

[tool.pytest.ini_options]
minversion = "6.0"
testpaths = [ "wpiformat/test" ]
2 changes: 0 additions & 2 deletions wpiformat/setup.cfg

This file was deleted.

89 changes: 0 additions & 89 deletions wpiformat/setup.py

This file was deleted.

11 changes: 11 additions & 0 deletions wpiformat/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[tox]
min_version = 4.0
env_list =
py38
py39
py310
py311

[testenv]
deps = pytest
commands = pytest
27 changes: 27 additions & 0 deletions wpiformat/wpiformat/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from datetime import date
import subprocess


def get_version():
proc = subprocess.run(
[
"git",
"rev-list",
"--count",
# Includes previous year's commits in case one was merged after the
# year incremented. Otherwise, the version wouldn't increment.
'--after="main@{' + str(date.today().year - 1) + '-01-01}"',
"main",
],
check=True,
encoding="utf-8",
stdout=subprocess.PIPE,
)
# If there is no main branch, the commit count defaults to 0
if proc.returncode:
commit_count = "0"
else:
commit_count = proc.stdout.rstrip()

# Version number: <year>.<# commits on main>
return f"{date.today().year}.{commit_count}"

0 comments on commit 9d06be3

Please sign in to comment.