From 52d6e1f83612f6f83b7a3df849edc49ca3822acf Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 21 Sep 2023 10:17:50 +0200 Subject: [PATCH] fix #918: use packaging from setuptools for self-build --- CHANGELOG.rst | 1 + pyproject.toml | 1 - src/setuptools_scm/_version_cls.py | 8 ++++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 36587632..994aefe5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,7 @@ v8.0.2 bugfix ------ +* fix #918: use packaging from setuptools for self-build * fix #914: ignore the deprecated git archival plugin as its integrated now * fix #912: ensure mypy safety of the version template + regression test * fix #913: use 240s timeout instead of 20 for git unshallow diff --git a/pyproject.toml b/pyproject.toml index dc5475ce..983789f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,6 @@ build-backend = "_own_version_helper" requires = [ 'importlib-metadata>=4.6; python_version < "3.10"', - "packaging>=20", "rich", "setuptools>=61", 'tomli; python_version < "3.11"', diff --git a/src/setuptools_scm/_version_cls.py b/src/setuptools_scm/_version_cls.py index e62c9fad..55c00c60 100644 --- a/src/setuptools_scm/_version_cls.py +++ b/src/setuptools_scm/_version_cls.py @@ -5,8 +5,12 @@ from typing import Type from typing import Union -from packaging.version import InvalidVersion -from packaging.version import Version as Version +try: + from packaging.version import InvalidVersion + from packaging.version import Version as Version +except ImportError: + from setuptools.extern.packaging.version import InvalidVersion # type: ignore + from setuptools.extern.packaging.version import Version as Version # type: ignore class NonNormalizedVersion(Version):