Skip to content

Commit 4a73e30

Browse files
setuptools → flit_core
Flit is a simple build system for pure Python packages, focusing on making easy things easy. Unlike setuptools, it doesn't have to stay compatible with projects published many years ago. https://flit.pypa.io/en/stable/rationale.html While flit_scm is able to Write the version to a Python file at build time, using setuptools_scm under the hood, it's probably best to follow the trend and retrieve the version at run time using `importlib.metadata.version`. Flit automatically checks metadata when building, so we don’t need to run `twine check` any more.
1 parent c31c61e commit 4a73e30

File tree

4 files changed

+13
-29
lines changed

4 files changed

+13
-29
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,8 @@ jobs:
2525
uses: actions/setup-python@v5
2626
with:
2727
python-version: "3.10"
28-
- name: Install dependencies
29-
run: |
30-
python -m pip install --upgrade pip
31-
pip install build twine
3228
- name: Build package
3329
run: python -m build
34-
- name: Check package
35-
run: twine check --strict dist/*
3630
- name: Check env vars
3731
run: |
3832
echo "Triggered by: ${{ github.event_name }}"

codespell_lib/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from ._codespell import _script_main, main
2-
from ._version import __version__ # type: ignore[import-not-found]
1+
from ._codespell import __version__, _script_main, main
32

43
__all__ = ["__version__", "_script_main", "main"]

codespell_lib/_codespell.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,17 @@
2626
import sys
2727
import textwrap
2828
from collections.abc import Iterable, Sequence
29+
from importlib.metadata import version
2930
from re import Match, Pattern
3031
from typing import (
3132
Any,
3233
Optional,
3334
TextIO,
3435
)
3536

37+
__version__ = version("codespell")
38+
39+
3640
if sys.platform == "win32":
3741
from ctypes import wintypes
3842

@@ -42,11 +46,6 @@
4246
from ._spellchecker import Misspelling, build_dict
4347
from ._text_util import fix_case
4448

45-
# autogenerated by setuptools_scm
46-
from ._version import ( # type: ignore[import-not-found]
47-
__version__ as VERSION, # noqa: N812
48-
)
49-
5049
word_regex_def = r"[\w\-'’]+" # noqa: RUF001
5150
# While we want to treat characters like ( or " as okay for a starting break,
5251
# these may occur unescaped in URIs, and so we are more restrictive on the
@@ -371,7 +370,7 @@ def parse_options(
371370
parser = argparse.ArgumentParser(formatter_class=NewlineHelpFormatter)
372371

373372
parser.set_defaults(colors=_supports_ansi_colors())
374-
parser.add_argument("--version", action="version", version=VERSION)
373+
parser.add_argument("--version", action="version", version=__version__)
375374

376375
parser.add_argument(
377376
"-d",

pyproject.toml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
1+
[build-system]
2+
requires = ["flit_core>=3.11", "flit_scm"]
3+
build-backend = "flit_scm:buildapi"
24

35
[project]
46
name = "codespell"
@@ -63,21 +65,11 @@ codespell = "codespell_lib:_script_main"
6365
homepage = "https://github.com/codespell-project/codespell"
6466
repository = "https://github.com/codespell-project/codespell"
6567

66-
[build-system]
67-
build-backend = "setuptools.build_meta"
68-
requires = ["setuptools>=77", "setuptools_scm[toml]>=6.2, != 8.0.0"]
69-
70-
[tool.setuptools_scm]
71-
write_to = "codespell_lib/_version.py"
72-
73-
[tool.setuptools.packages.find]
74-
exclude = [
75-
"dist",
76-
"snap",
77-
]
68+
[tool.flit.module]
69+
name = "codespell_lib"
7870

79-
[tool.setuptools.package-data]
80-
codespell_lib = [
71+
[tool.flit.sdist]
72+
include = [
8173
"data/dictionary*.txt",
8274
"data/linux-kernel.exclude",
8375
"py.typed",

0 commit comments

Comments
 (0)