Skip to content

Commit 6ae4fe4

Browse files
committed
Update build system to use pyproject.toml
1 parent bc75204 commit 6ae4fe4

File tree

9 files changed

+88
-76
lines changed

9 files changed

+88
-76
lines changed

.github/workflows/check.yaml

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ jobs:
2222
with:
2323
python-version: '3.x'
2424
- name: Install dependencies
25-
run: |
26-
python -m pip install --upgrade pip
27-
pip install setuptools
25+
run: pip install tox
2826
- name: Run Tests
29-
run: python setup.py pytest
27+
run: tox -e py3
3028

3129
code-ql:
3230
strategy:

.github/workflows/codecov.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
python-version: '3.x'
1515
- name: Generate Coverage Report
1616
run: |
17-
python -m pip install --upgrade pip
18-
pip install coverage setuptools
19-
coverage run --include=src/* setup.py pytest
17+
pip install tox
18+
tox
2019
- name: Upload Coverage to Codecov
2120
uses: codecov/codecov-action@v5
2221
with:
2322
token: ${{ secrets.CODECOV_TOKEN }}
23+
file: .tox/coverage.xml

.github/workflows/publish.yaml

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ jobs:
1818
with:
1919
python-version: '3.x'
2020
- name: Install dependencies
21-
run: |
22-
python -m pip install --upgrade pip
23-
pip install setuptools wheel twine
21+
run: pip install build
2422
- name: Build
25-
run: python setup.py bdist_wheel
23+
run: python -m build
2624
- name: Publish to PyPI
2725
uses: pypa/gh-action-pypi-publish@release/v1

pyproject.toml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0", "wheel", "build"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "flake8-requirements"
7+
# NOTE: Keep in sync with src/flake8_requirements/checker.py file.
8+
version = "2.2.1"
9+
description = "Package requirements checker, plugin for flake8"
10+
readme = "README.rst"
11+
authors = [ { name = "Arkadiusz Bokowy", email = "[email protected]" } ]
12+
requires-python = ">=3.6"
13+
classifiers = [
14+
"Framework :: Flake8",
15+
"Intended Audience :: Developers",
16+
"License :: OSI Approved :: MIT License",
17+
"Programming Language :: Python",
18+
"Programming Language :: Python :: 3",
19+
"Programming Language :: Python :: 3 :: Only",
20+
"Topic :: Software Development :: Libraries :: Python Modules",
21+
"Topic :: Software Development :: Quality Assurance",
22+
]
23+
dependencies = [
24+
"flake8 >= 4.0.0",
25+
"setuptools >= 10.0.0",
26+
"tomli>=1.2.1; python_version < '3.11'",
27+
]
28+
29+
[project.optional-dependencies]
30+
pyproject = ["Flake8-pyproject"]
31+
32+
[project.urls]
33+
Homepage = "https://github.com/arkq/flake8-requirements"
34+
35+
[project.entry-points."flake8.extension"]
36+
I90 = "flake8_requirements:Flake8Checker"
37+
38+
[tool.doc8]
39+
max-line-length = 99
40+
41+
[tool.isort]
42+
force_single_line = true

setup.cfg

-11
This file was deleted.

setup.py

-50
This file was deleted.

src/flake8_requirements/checker.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from .modules import KNOWN_3RD_PARTIES
2020
from .modules import STDLIB_PY3
2121

22-
# NOTE: Changing this number will alter package version as well.
22+
# NOTE: Keep in sync with pyproject.toml file.
2323
__version__ = "2.2.1"
2424
__license__ = "MIT"
2525

test/test_checker.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ class Flake8Checker(checker.Flake8Checker):
2828
def get_setup_py(cls):
2929
return SetupVisitorMock()
3030

31-
@property
32-
def processing_setup_py(self):
33-
return self.filename == "setup.py"
31+
@staticmethod
32+
def is_project_setup_py(project_root_dir, filename):
33+
return filename == "setup.py"
3434

3535

3636
class Flake8OptionManagerMock(dict):

tox.ini

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[tox]
2+
envlist =
3+
coverage
4+
py3
5+
isolated_build = true
6+
7+
[testenv]
8+
description = Run the tests with pytest under {basepython}.
9+
setenv =
10+
COVERAGE_FILE = {toxworkdir}/.coverage.{envname}
11+
commands =
12+
pytest \
13+
--cov="{envsitepackagesdir}/flake8_requirements" \
14+
--cov-config="{toxinidir}/tox.ini" \
15+
test
16+
deps =
17+
pytest
18+
pytest-cov
19+
20+
[testenv:coverage]
21+
description = Combine coverage data and create final XML report.
22+
setenv =
23+
COVERAGE_FILE = {toxworkdir}/.coverage
24+
commands =
25+
coverage combine
26+
coverage report
27+
coverage xml -o "{toxworkdir}/coverage.xml"
28+
skip_install = true
29+
deps = coverage
30+
depends = py3
31+
32+
[coverage:paths]
33+
source = src/flake8_requirements
34+
*/.tox/*/lib/python*/site-packages/flake8_requirements
35+
*/src/flake8_requirements

0 commit comments

Comments
 (0)