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

Modernize packaging a bit #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bluetech
Copy link
Contributor

@bluetech bluetech commented Jul 7, 2023

Adding pyproject.toml allows the package to be installed using PEP517 instead of legacy setup.py install method. At least pip says so in a warning when installing without the wheel package available.

Change setup.py to setup.cfg (using a script[0]) because setup.py is out of fashion these days.

Remove MANIFEST.ini since LICENSE is implied[1].

[0] https://github.com/gvalkov/setuptools-py2cfg
[1] https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-license-files

setup.cfg Outdated
@@ -1,2 +1,32 @@
[bdist_wheel]
universal=0
[metadata]
Copy link
Member

Choose a reason for hiding this comment

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

Might as well put this config in pyproject.toml?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't have python 3.5 installed, but I suspect it won't work with it. I'll try getting py3.5 and check it though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can drop 3.5, 3.6 and 3.7 support

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hauntsaninja great, that might help. I'll send a PR to do this first.

Adding pyproject.toml allows the package to be installed using PEP517
instead of legacy `setup.py install` method. At least pip says so in a
warning when installing without the `wheel` package available.

Change setup.py to setup.cfg (using a script[0]) because setup.py is out
of fashion these days.

Remove MANIFEST.ini since LICENSE is implied[1].

[0] https://github.com/gvalkov/setuptools-py2cfg
[1] https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-license-files
@bluetech bluetech force-pushed the modernize-packaging branch from fb504bf to 780aa14 Compare July 7, 2023 20:20
Supported since setuptools 61.0.0, more standard.
@bluetech bluetech force-pushed the modernize-packaging branch from 0601a1f to aad9410 Compare July 7, 2023 20:38
@bluetech
Copy link
Contributor Author

bluetech commented Jul 7, 2023

Changed from setup.cfg to pyproject.toml, seems to work. Added it in a separate commit just in case.

One final change can be done to eliminate the tool.setuptools py-modules section by moving from a single module mypy_extensions.py to a package, then setuptools can auto-discover it. Actually seems to work with the module as well, so just removed it.

Copy link

@nbraud nbraud left a comment

Choose a reason for hiding this comment

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

I'm absolutely not a mypy dev, but I noticed this PR while reporting an issue so have a drive-by review ❤️

This all seems good to me, and I only found a minor issue that (I believe) is present in the current version as well.

Thanks a bunch for tidying up the packaging :)

name = "mypy_extensions"
version = "1.0.0-dev"
description = "Type system extensions for programs checked with the mypy type checker."
readme = "README.md"
Copy link

Choose a reason for hiding this comment

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

This should specify the content type, as setuptools otherwise assumes it's ReStructured Text:

Suggested change
readme = "README.md"
readme = { file = "README.md", content-type = "text/markdown; charset=UTF-8" }

Copy link

Choose a reason for hiding this comment

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

That's not necessary. Setuptools can detect that it's a markdown file and adds Description-Content-Type: text/markdown to the core metadata.

Copy link

@cdce8p cdce8p left a comment

Choose a reason for hiding this comment

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

One final change can be done to eliminate the tool.setuptools py-modules section by moving from a single module mypy_extensions.py to a package, then setuptools can auto-discover it. Actually seems to work with the module as well, so just removed it.

I'd keep it. Explicit is often better than implicit. I.e. add

[tool.setuptools]
py-modules = ["mypy_extensions"]

--
There are also some conflicts which need to be resolved.

name = "mypy_extensions"
version = "1.0.0-dev"
description = "Type system extensions for programs checked with the mypy type checker."
readme = "README.md"
Copy link

Choose a reason for hiding this comment

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

That's not necessary. Setuptools can detect that it's a markdown file and adds Description-Content-Type: text/markdown to the core metadata.

version = "1.0.0-dev"
description = "Type system extensions for programs checked with the mypy type checker."
readme = "README.md"
license = {file = "LICENSE"}
Copy link

Choose a reason for hiding this comment

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

Suggested change
license = {file = "LICENSE"}
license = {text = "MIT"}

I'd suggest to use the SPDX license string here instead. The license file is already included by setuptools.

Comment on lines +25 to +26
"Programming Language :: Python :: 3.11",
"Topic :: Software Development",
Copy link

Choose a reason for hiding this comment

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

Suggested change
"Programming Language :: Python :: 3.11",
"Topic :: Software Development",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development",

Support for 3.12 was declared in 9dd6d98

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

Successfully merging this pull request may close these issues.

5 participants