Skip to content

Replace setuptools build backend with hatchling #551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ current_version = 4.0.0
commit = True
tag = True

[bumpversion:file:setup.py]
search = version='{current_version}'
replace = version='{new_version}'
[bumpversion:file:pyproject.toml]
search = version = "{current_version}"
replace = version = "{new_version}"

[bumpversion:file (badge):README.rst]
search = /v{current_version}.svg
Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,6 @@ jobs:
toxpython: 'python3.9'
tox_env: 'docs'
os: 'ubuntu-latest'
- name: 'py36-pytest70-xdist250-coverage62 (ubuntu)'
python: '3.6'
toxpython: 'python3.6'
python_arch: 'x64'
tox_env: 'py36-pytest70-xdist250-coverage62'
os: 'ubuntu-latest'
- name: 'py36-pytest70-xdist250-coverage62 (windows)'
python: '3.6'
toxpython: 'python3.6'
python_arch: 'x64'
tox_env: 'py36-pytest70-xdist250-coverage62'
os: 'windows-latest'
- name: 'py36-pytest70-xdist250-coverage62 (macos)'
python: '3.6'
toxpython: 'python3.6'
python_arch: 'x64'
tox_env: 'py36-pytest70-xdist250-coverage62'
os: 'macos-latest'
- name: 'py37-pytest71-xdist250-coverage64 (ubuntu)'
python: '3.7'
toxpython: 'python3.7'
Expand Down
28 changes: 0 additions & 28 deletions MANIFEST.in

This file was deleted.

4 changes: 2 additions & 2 deletions docs/releasing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ The process for releasing should follow these steps:
#. Make sure you have a clean checkout, run ``git status`` to verify.
#. Manually clean temporary files (that are ignored and won't show up in ``git status``)::

rm -rf dist build src/*.egg-info
rm -rf dist
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, this could be replaced by a git clean which is cross-platform.


These files need to be removed to force distutils/setuptools to rebuild everything and recreate the egg-info metadata.
#. Build the dists::

python3 setup.py clean --all sdist bdist_wheel
python -m build

#. Verify that the resulting archives (found in ``dist/``) are good.
#. Upload the sdist and wheel with twine::
Expand Down
76 changes: 76 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[build-system]
requires = ["hatchling", "hatch-fancy-pypi-readme"]
build-backend = "hatchling.build"

[project]
name = "pytest-cov"
dynamic = ["readme"]
version = "3.0.0"
description = "Pytest plugin for measuring coverage."
license = "MIT"
requires-python = ">=3.7"
authors = [
{ name = "Marc Schlaich", email = "[email protected]" },
]
Comment on lines +12 to +14
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly related to the conversion but perhaps, a maintainers entry should be added at some point too.

keywords = [
"cover",
"coverage",
"distributed",
"parallel",
"py.test",
"pytest",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Framework :: Pytest",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: Unix",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Testing",
"Topic :: Utilities",
]
dependencies = [
"coverage[toml]>=5.2.1",
"pytest>=4.6",
]

[project.optional-dependencies]
testing = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works as the "testing" extra right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if nowadays this could be turned into a dependency group finally..

"fields",
"hunter",
"process-tests",
"pytest-xdist",
"six",
"virtualenv",
]

[project.entry-points.pytest11]
pytest_cov = "pytest_cov.plugin"

[project.urls]
Changelog = "https://pytest-cov.readthedocs.io/en/latest/changelog.html"
Documentation = "https://pytest-cov.readthedocs.io/"
Homepage = "https://github.com/pytest-dev/pytest-cov"
"Issue Tracker" = "https://github.com/pytest-dev/pytest-cov/issues"

[tool.hatch.metadata.hooks.fancy-pypi-readme]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the fancy pypi readme do the ref tag stripping automatically? The ol setup.py had a re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', ...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but as I mentioned in the OP it was doing nothing:

Python 3.11.0b3 (main, Jun  1 2022, 13:29:14) [MSC v.1932 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pathlib, re
>>>
>>> before = pathlib.Path('CHANGELOG.rst').read_text(encoding='utf-8')
>>> after = re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', before)
>>>
>>> before == after
True

content-type = "text/x-rst"
fragments = [
{ path = "README.rst" },
{ path = "CHANGELOG.rst" },
]

[tool.hatch.build.targets.wheel.hooks.autorun]
dependencies = ["hatch-autorun"]
file = "src/pytest-cov.embed"
159 changes: 0 additions & 159 deletions setup.py

This file was deleted.

1 change: 0 additions & 1 deletion src/pytest-cov.pth
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: Looks like this is replaced by [tool.hatch.build.targets.wheel.hooks.autorun].

This file was deleted.

4 changes: 2 additions & 2 deletions tests/test_pytest_cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -1777,8 +1777,8 @@ def test_append_coverage_subprocess(testdir):


def test_pth_failure(monkeypatch):
with open('src/pytest-cov.pth') as fh:
payload = fh.read()
with open('src/pytest-cov.embed') as fh:
payload = f'import os, sys;exec({fh.read()!r})'

class SpecificError(Exception):
pass
Expand Down
13 changes: 7 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ passenv =
; a generative tox configuration, see: https://tox.readthedocs.io/en/latest/config.html#generative-envlist

[tox]
isolated_build = true
envlist =
check
py{36}-pytest{70}-xdist250-coverage{62}
py{37,38,39,310,py37,py38}-pytest{71}-xdist250-coverage{64}
docs

Expand Down Expand Up @@ -87,16 +87,17 @@ commands =

[testenv:check]
deps =
build
twine
docutils
check-manifest
flake8
readme-renderer
pygments
isort
skip_install = true
usedevelop = false
commands =
python setup.py check --strict --metadata --restructuredtext
check-manifest {toxinidir}
flake8 src tests setup.py
isort --check-only --diff src tests setup.py
python -m build
twine check dist/*
Copy link
Member

@webknjaz webknjaz Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably include --strict too

Suggested change
twine check dist/*
twine check --strict dist/*

flake8 src tests
isort --check-only --diff src tests