Skip to content
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

Update package metadata #551

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

ofek
Copy link

@ofek ofek commented Aug 26, 2022

cc @graingert as requested!

Background

Hello there! The Python packaging ecosystem has standardized on the interface for build backends (PEP 517/PEP 660) and the format for metadata declaration (PEP 621/PEP 631). As a result, the execution of setup.py files is now deprecated.

So, I'm spending my free time updating important projects so that they are modernized and set an example for others 😄

Summary of changes

This implements PEP 621, obviating the need for setup.py and MANIFEST.in. The build backend hatchling (of which I am a maintainer in the PyPA) is now used as that is the default in the official Python packaging tutorial. Hatchling is available on all the major distribution channels such as Debian, Fedora, Arch Linux, conda-forge, Nixpkgs, Alpine Linux, FreeBSD/OpenBSD, Gentoo Linux, MacPorts, OpenEmbedded, Spack, MSYS2, etc.

Python support

The earliest supported Python 3 version of Hatchling is 3.7, therefore I've also set that as the minimum here. Python 3.6 is EOL and other build backends like flit-core and setuptools also dropped support. Python 3.6 accounted for 6-8% of downloads in the last month: https://pypistats.org/packages/pytest-cov

Notes

  • The source distributions on PyPI are erroneously shipping a build artifact *.egg-info from python setup.py develop; this is now fixed
  • The CHANGELOG.rst regex substitution was doing nothing so the PyPI landing page continues to be simply README.rst + CHANGELOG.rst
  • The generated pytest-cov.pth was being checked into the repo but is not necessary now so I've removed it

Future

  • Move config for tools like pytest out of setup.cfg and into pyproject.toml

@ionelmc
Copy link
Member

ionelmc commented Aug 26, 2022

What exactly is hatch-autorun? How does it work? I don't get how this replaces the pth file we use.

@ofek ofek force-pushed the modernize-metadata branch from f7d916e to da3db18 Compare August 26, 2022 16:45
@ofek
Copy link
Author

ofek commented Aug 26, 2022

It essentially does the current logic of executing the src/pytest-cov.embed in a PTH file.

@ofek ofek force-pushed the modernize-metadata branch from da3db18 to 804b337 Compare August 26, 2022 16:58
]

[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!

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

@ofek
Copy link
Author

ofek commented Sep 4, 2022

CI passing btw

@ofek
Copy link
Author

ofek commented Sep 10, 2022

Just let me know if I can help!

@ionelmc
Copy link
Member

ionelmc commented Sep 28, 2022

I'll be honest here I'm not a fan of redoing something that works. But I am also curious how well this could work so how about this: release it as pytest-cov 5.0.0a (or beta) and we keep this in a special "alpha" branch till people try it out enough? This can only work if you pledge yourself to maintain pytest-cov's packaging from here on out :-)

@RonnyPfannschmidt
Copy link
Member

I'm also in on this, starting with pluggy, then going for other pytest projects

I like hatch enough that i decided to let my own tool die in favour of it.

@ofek ofek force-pushed the modernize-metadata branch from fd71fa5 to 9c11353 Compare October 5, 2022 04:30
@ofek
Copy link
Author

ofek commented Oct 5, 2022

I rebased to fix conflicts. Would you mind triggering the CI with that button below?

@ofek ofek force-pushed the modernize-metadata branch from 9c11353 to c860920 Compare October 20, 2022 04:38
@ofek
Copy link
Author

ofek commented Oct 20, 2022

I rebased again, accounting for #553 (comment)

@ofek
Copy link
Author

ofek commented Oct 20, 2022

flake?

@ofek ofek force-pushed the modernize-metadata branch from c860920 to 7f0fe2e Compare October 22, 2022 20:24
@ofek
Copy link
Author

ofek commented Oct 22, 2022

I rebased again, accounting for #556

@ofek
Copy link
Author

ofek commented Oct 25, 2022

Would you mind triggering the CI with that button below?

@ofek
Copy link
Author

ofek commented Oct 29, 2022

Passing 🙂

@cclauss
Copy link
Contributor

cclauss commented Feb 28, 2023

Please rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants