Skip to content

Commit 2ba4010

Browse files
authored
chore: replace setuptools with hatchling, remove 'build' extra (#2446)
This PR does the following: - Changes the build backend from setuptools to hatch's hatchling. Why? - While both are PyPA projects, setuptools has some odd legacy concepts like MANIFEST.in and egg-info directories, that are not used with modern builds. It's an old system that is primarily maintained to maintain legacy behaviour and not to embrace modern enhancements. - Hatchling is a common and modern build backend, e.g. demonstrated as a default in guidelines. New features and plugins are actively developed for hatch and hatchling by Python core developers. - Use the hatch-fancy-pypi-readme plug-in to stitch content for the documentation in PyPI. (There is more potential to this plug-in, such as amending changelog info from each release). See preview via uvx hatch project metadata readme. - Remove the 'build' optional dependency (or extra), as this a prerequisite only for packaging builds, not an optional dependency. Builds can happen using several methods, e.g. python3 -m build or uv build or uvx hatch build etc. I've done some comparisons of the sdist (.tar.gz) and bdist (.whl) outputs, and the contents are nearly identical.
1 parent fcc566a commit 2ba4010

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

MANIFEST.in

Lines changed: 0 additions & 5 deletions
This file was deleted.

pyproject.toml

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
[build-system]
2-
requires = [
3-
"setuptools >=61",
4-
]
5-
build-backend = "setuptools.build_meta"
2+
requires = ["hatchling", "hatch-fancy-pypi-readme"]
3+
build-backend = "hatchling.build"
64

75
[project]
86
name = "flopy"
@@ -36,9 +34,8 @@ dependencies = [
3634
dynamic = ["version", "readme"]
3735

3836
[project.optional-dependencies]
39-
dev = ["flopy[build,lint,test,optional,doc]", "tach"]
40-
build = ["build", "twine"]
41-
lint = ["cffconvert", "codespell[toml] >=2.2.2", "ruff"]
37+
dev = ["flopy[lint,test,optional,doc]", "tach"]
38+
lint = ["ruff"]
4239
test = [
4340
"flopy[lint]",
4441
"coverage !=7.6.5",
@@ -100,20 +97,28 @@ Documentation = "https://flopy.readthedocs.io"
10097
"Bug Tracker" = "https://github.com/modflowpy/flopy/issues"
10198
"Source Code" = "https://github.com/modflowpy/flopy"
10299

103-
[tool.setuptools]
104-
include-package-data = true
105-
zip-safe = false
100+
[tool.hatch.build.targets.sdist]
101+
only-include = [
102+
"CITATION.cff",
103+
"README.md",
104+
"docs",
105+
"flopy",
106+
]
107+
108+
[tool.hatch.build.targets.wheel]
109+
packages = ["flopy"]
110+
111+
[tool.hatch.metadata.hooks.fancy-pypi-readme]
112+
content-type = "text/markdown"
106113

107-
[tool.setuptools.dynamic]
108-
version = {attr = "flopy.version.__version__"}
109-
readme = {file = ["docs/PyPI_release.md", "LICENSE.md"], content-type = "text/markdown"}
114+
[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
115+
path = "docs/PyPI_release.md"
110116

111-
[tool.setuptools.packages.find]
112-
include = ["flopy", "flopy.*"]
117+
[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
118+
path = "LICENSE.md"
113119

114-
[tool.setuptools.package-data]
115-
"flopy.mf6.data" = ["dfn/*.dfn"]
116-
"flopy.plot" = ["mplstyle/*.mplstyle"]
120+
[tool.hatch.version]
121+
path = "flopy/version.py"
117122

118123
[tool.ruff]
119124
line-length = 88

0 commit comments

Comments
 (0)