Skip to content

Commit

Permalink
Update build system to use pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed Jan 14, 2025
1 parent bc75204 commit 7efd7c3
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 76 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ jobs:
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools
run: pip install tox
- name: Run Tests
run: python setup.py pytest
run: tox -e py3

code-ql:
strategy:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ jobs:
python-version: '3.x'
- name: Generate Coverage Report
run: |
python -m pip install --upgrade pip
pip install coverage setuptools
coverage run --include=src/* setup.py pytest
pip install tox
tox
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v5
with:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ jobs:
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
run: pip install build
- name: Build
run: python setup.py bdist_wheel
run: python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
42 changes: 42 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[build-system]
requires = ["setuptools>=61.0", "wheel", "build"]
build-backend = "setuptools.build_meta"

[project]
name = "flake8-requirements"
# NOTE: Keep in sync with src/flake8_requirements/checker.py file.
version = "2.2.1"
description = "Package requirements checker, plugin for flake8"
readme = "README.rst"
authors = [ { name = "Arkadiusz Bokowy", email = "[email protected]" } ]
requires-python = ">=3.6"
classifiers = [
"Framework :: Flake8",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Quality Assurance",
]
dependencies = [
"flake8 >= 4.0.0",
"setuptools >= 10.0.0",
"tomli>=1.2.1; python_version < '3.11'",
]

[project.optional-dependencies]
pyproject = ["Flake8-pyproject"]

[project.urls]
Homepage = "https://github.com/arkq/flake8-requirements"

[project.entry-points."flake8.extension"]
I90 = "flake8_requirements:Flake8Checker"

[tool.doc8]
max-line-length = 99

[tool.isort]
force_single_line = true
11 changes: 0 additions & 11 deletions setup.cfg

This file was deleted.

50 changes: 0 additions & 50 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/flake8_requirements/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from .modules import KNOWN_3RD_PARTIES
from .modules import STDLIB_PY3

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

Expand Down
6 changes: 3 additions & 3 deletions test/test_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class Flake8Checker(checker.Flake8Checker):
def get_setup_py(cls):
return SetupVisitorMock()

@property
def processing_setup_py(self):
return self.filename == "setup.py"
@staticmethod
def is_project_setup_py(project_root_dir, filename):
return filename == "setup.py"


class Flake8OptionManagerMock(dict):
Expand Down
35 changes: 35 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[tox]
envlist =
coverage
py3
isolated_build = true

[testenv]
description = Run the tests with pytest under {basepython}.
setenv =
COVERAGE_FILE = {toxworkdir}/.coverage.{envname}
commands =
pytest \
--cov="{envsitepackagesdir}/flake8_requirements" \
--cov-config="{toxinidir}/tox.ini" \
test
deps =
pytest
pytest-cov

[testenv:coverage]
description = Combine coverage data and create final XML report.
setenv =
COVERAGE_FILE = {toxworkdir}/.coverage
commands =
coverage combine
coverage report
coverage xml -o "{toxworkdir}/coverage.xml"
skip_install = true
deps = coverage
depends = py3

[coverage:paths]
source = src/flake8_requirements
*/.tox/*/lib/python*/site-packages/flake8_requirements
*/src/flake8_requirements

0 comments on commit 7efd7c3

Please sign in to comment.