Skip to content

Commit

Permalink
packaging: restore Python 3.7 support
Browse files Browse the repository at this point in the history
version_file support is only available in setuptools_scm 8.0,
and older versions throw errors when pyproject.toml contains
configuration that the older versions do not understand.

This means that we cannot use version_file just yet if
we want to retain support for Python 3.7.

Restore the importlib.metadata version lookups alongside
the setuptools_scm version file support so that we can
swap over later once we are okay dropping support for 3.7.

Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information
davvid committed May 2, 2024
1 parent cd8de7a commit 0fe43d5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions cola/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
"""Provide git-cola's version number"""
import sys

try:
if sys.version_info < (3, 8):
import importlib_metadata as metadata
else:
from importlib import metadata
except (ImportError, OSError):
metadata = None

from .git import STDOUT
from .decorators import memoize
from ._version import VERSION
Expand Down Expand Up @@ -56,6 +66,11 @@ def version():
pkg_version = SCM_VERSION
else:
pkg_version = VERSION
if metadata is not None:
try:
pkg_version = metadata.version('git-cola')
except (ImportError, OSError):
pass
return pkg_version


Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ addopts = "--ruff"

[tool.setuptools_scm]
fallback_version = "4.7.0"
version_file = "cola/_scm_version.py"
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ packages =
cola.widgets
include_package_data = true
install_requires =
importlib_metadata; python_version<"3.8"
polib >= 1.0.0
qtpy >= 1.1.0
zip_safe = false
Expand Down

0 comments on commit 0fe43d5

Please sign in to comment.