diff --git a/.devcontainer/post_create.sh b/.devcontainer/post_create.sh index df73095285..6d9d51de2f 100644 --- a/.devcontainer/post_create.sh +++ b/.devcontainer/post_create.sh @@ -6,8 +6,6 @@ sudo apt-get install -y libaspell-dev pip install --upgrade \ aspell-python-py3 \ pip \ - setuptools \ - setuptools_scm \ wheel pip install -e . --group dev diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6515fa87ad..a9887ae828 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,11 +28,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install build twine + pip install build - name: Build package run: python -m build - - name: Check package - run: twine check --strict dist/* - name: Check env vars run: | echo "Triggered by: ${{ github.event_name }}" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d001141a82..dc33439042 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -57,7 +57,6 @@ jobs: run: | python --version # just to check python -m pip install --upgrade pip wheel - pip install --upgrade setuptools docutils setuptools_scm[toml] twine pip install -e . --group dev # install the codespell dev packages - run: pip install aspell-python-py3 if: startsWith(matrix.os, 'ubuntu') diff --git a/Makefile b/Makefile index d281d73921..c7560182b3 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,6 @@ trim-dictionaries: $(GENERATED) check-dist: $(eval TMP := $(shell mktemp -d)) python -m build -o $(TMP) - twine check --strict $(TMP)/* rm -rf $(TMP) ruff: diff --git a/README.rst b/README.rst index 61d179469b..ab8fe227cb 100644 --- a/README.rst +++ b/README.rst @@ -344,11 +344,11 @@ applied directly, but should instead be manually inspected. E.g.: Development setup ----------------- -As suggested in the `Python Packaging User Guide`_, ensure ``pip``, ``setuptools``, and ``wheel`` are up to date before installing from source. Specifically you will need recent versions of ``setuptools`` and ``setuptools_scm``: +As suggested in the `Python Packaging User Guide`_, ensure ``pip`` and ``wheel`` are up to date before installing from source: .. code-block:: sh - pip install --upgrade pip setuptools setuptools_scm wheel + pip install --upgrade pip wheel You can install required dependencies for development by running the following within a checkout of the codespell source: diff --git a/codespell_lib/__init__.py b/codespell_lib/__init__.py index 621e36d8de..75038ddd8d 100644 --- a/codespell_lib/__init__.py +++ b/codespell_lib/__init__.py @@ -1,4 +1,3 @@ -from ._codespell import _script_main, main -from ._version import __version__ # type: ignore[import-not-found] +from ._codespell import __version__, _script_main, main __all__ = ["__version__", "_script_main", "main"] diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py index 0290b92717..332895ea7b 100644 --- a/codespell_lib/_codespell.py +++ b/codespell_lib/_codespell.py @@ -29,6 +29,7 @@ import tempfile import textwrap from collections.abc import Callable, Iterable, Sequence +from importlib.metadata import version from re import Match, Pattern from typing import ( Any, @@ -45,10 +46,7 @@ from ._spellchecker import Misspelling, build_dict from ._text_util import fix_case -# autogenerated by setuptools_scm -from ._version import ( # type: ignore[import-not-found] - __version__ as VERSION, # noqa: N812 -) +__version__ = version("codespell") word_regex_def = r"[\w\-'’]+" # noqa: RUF001 # While we want to treat characters like ( or " as okay for a starting break, @@ -463,7 +461,7 @@ def convert_arg_line_to_args(self, arg_line: str) -> list[str]: ) parser.set_defaults(colors=_supports_ansi_colors()) - parser.add_argument("--version", action="version", version=VERSION) + parser.add_argument("--version", action="version", version=__version__) parser.add_argument( "-d", diff --git a/pyproject.toml b/pyproject.toml index 7cbdb717e5..e11854104f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,6 @@ -# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html +[build-system] +requires = ["flit_core>=3.11", "flit_scm"] +build-backend = "flit_scm:buildapi" [project] name = "codespell" @@ -47,8 +49,7 @@ dev = [ "pytest-dependency", "Pygments", "ruff", - "tomli", - "twine" + "tomli" ] types = [ "chardet>=5.1.0", @@ -65,32 +66,13 @@ codespell = "codespell_lib:_script_main" homepage = "https://github.com/codespell-project/codespell" repository = "https://github.com/codespell-project/codespell" -[build-system] -build-backend = "setuptools.build_meta" -requires = ["setuptools>=77", "setuptools_scm[toml]>=6.2, != 8.0.0"] - +# flit_scm uses setuptools_scm under the hood to write the version file at +# build time, so that flit can stamp the version into the package metadata. [tool.setuptools_scm] write_to = "codespell_lib/_version.py" -[tool.setuptools] -include-package-data = false - -[tool.setuptools.packages.find] -include = ["codespell_lib", "codespell_lib.*"] -exclude = [ - "dist", - "snap", - "tools", - "example", - "codespell_lib.tests*", -] - -[tool.setuptools.package-data] -codespell_lib = [ - "data/dictionary*.txt", - "data/linux-kernel.exclude", - "py.typed", -] +[tool.flit.module] +name = "codespell_lib" # TODO: reintegrate codespell configuration after updating test cases #[tool.codespell]