From 779804dcc3aed93e543ec0909900bf53c5586fb7 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Thu, 5 Mar 2026 15:04:03 +0100 Subject: [PATCH] Get rid of file `_version.py` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was useful for running `__init__.py` as as script, but since AppVeyor has been removed, it is certainly not used any more. In any case, it shouldn't be used. Whatever your need, try editable installs: pip install -e . Because `flit_scm:buildapi` delegates to `setuptools-scm` for version discovery, we need to enable it with: [tool.setuptools_scm] More importantly, this fixes the build backend, which was wrong! flit → flit_core --- .gitignore | 2 -- HOWTOPUBLISH | 2 -- pyproject.toml | 15 ++++++--------- tabulate/__init__.py | 5 +---- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 0495ac79..460933ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -/tabulate/version.py - build dist .tox diff --git a/HOWTOPUBLISH b/HOWTOPUBLISH index 24203ded..4e5292cb 100644 --- a/HOWTOPUBLISH +++ b/HOWTOPUBLISH @@ -3,12 +3,10 @@ python -m pre_commit run -a # and then commit changes tox -e py310-extra,py311-extra,py312-extra,py313-extra,py314-extra # tag version release (vX.Y.Z) python -m pip install build twine -python -m build -s # this will update tabulate/_version.py python -m pip install . # install tabulate in the current venv python -m pip install -r benchmark/requirements.txt python benchmark/benchmark.py # then update README # move tag to the last commit -python -m build -s # update tabulate/_version.py python -m build -nswx . git push # wait for all CI builds to succeed git push --tags # if CI builds succeed diff --git a/pyproject.toml b/pyproject.toml index 2a80daa5..c9821981 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["flit>=3.12", "flit_scm"] +requires = ["flit_core>=3.12", "flit_scm"] build-backend = "flit_scm:buildapi" [project] @@ -32,13 +32,6 @@ widechars = ["wcwidth>=0.6.0"] [project.scripts] tabulate = "tabulate:_main" -[tool.flit.sdist] -include = ["CHANGELOG", "test/", "tox.ini"] -exclude = ["tabulate/_version.py"] - -[tool.setuptools_scm] -write_to = "tabulate/_version.py" - [dependency-groups] dev = [ "build>=1.4.0", @@ -48,9 +41,13 @@ dev = [ "twine>=6.2.0", ] +[tool.setuptools_scm] + +[tool.flit.sdist] +include = ["CHANGELOG", "test/", "tox.ini"] + [tool.ruff] line-length = 99 -exclude = ["tabulate/_version.py"] [tool.ruff.lint] extend-select = ["W", "ISC", "I", "C90"] diff --git a/tabulate/__init__.py b/tabulate/__init__.py index b0810a95..4154e5f6 100644 --- a/tabulate/__init__.py +++ b/tabulate/__init__.py @@ -8,10 +8,7 @@ try: __version__ = _version("tabulate") except _PackageNotFoundError: - try: - from .version import version as __version__ # noqa: F401 - except ImportError: - __version__ = "unknown" + __version__ = "unknown" from collections import namedtuple from collections.abc import Iterable, Sized