Skip to content

Commit

Permalink
chore: replace setuptools with hatchling, remove 'build' extra (#2446)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mwtoews authored Feb 11, 2025
1 parent fcc566a commit 2ba4010
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

41 changes: 23 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[build-system]
requires = [
"setuptools >=61",
]
build-backend = "setuptools.build_meta"
requires = ["hatchling", "hatch-fancy-pypi-readme"]
build-backend = "hatchling.build"

[project]
name = "flopy"
Expand Down Expand Up @@ -36,9 +34,8 @@ dependencies = [
dynamic = ["version", "readme"]

[project.optional-dependencies]
dev = ["flopy[build,lint,test,optional,doc]", "tach"]
build = ["build", "twine"]
lint = ["cffconvert", "codespell[toml] >=2.2.2", "ruff"]
dev = ["flopy[lint,test,optional,doc]", "tach"]
lint = ["ruff"]
test = [
"flopy[lint]",
"coverage !=7.6.5",
Expand Down Expand Up @@ -100,20 +97,28 @@ Documentation = "https://flopy.readthedocs.io"
"Bug Tracker" = "https://github.com/modflowpy/flopy/issues"
"Source Code" = "https://github.com/modflowpy/flopy"

[tool.setuptools]
include-package-data = true
zip-safe = false
[tool.hatch.build.targets.sdist]
only-include = [
"CITATION.cff",
"README.md",
"docs",
"flopy",
]

[tool.hatch.build.targets.wheel]
packages = ["flopy"]

[tool.hatch.metadata.hooks.fancy-pypi-readme]
content-type = "text/markdown"

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

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

[tool.setuptools.package-data]
"flopy.mf6.data" = ["dfn/*.dfn"]
"flopy.plot" = ["mplstyle/*.mplstyle"]
[tool.hatch.version]
path = "flopy/version.py"

[tool.ruff]
line-length = 88
Expand Down

0 comments on commit 2ba4010

Please sign in to comment.