55import os
66import warnings
77
8- try :
9- from packaging .version import parse
10- except ImportError :
11- from pkg_resources import parse_version as parse
12-
13- from .config import (
14- Configuration ,
15- DEFAULT_VERSION_SCHEME ,
16- DEFAULT_LOCAL_SCHEME ,
17- DEFAULT_TAG_REGEX ,
18- NonNormalizedVersion ,
19- )
20- from .utils import function_has_arg , trace
21- from .version import format_version , meta
8+ from ._version_cls import NonNormalizedVersion
9+ from ._version_cls import Version
10+ from .config import Configuration
11+ from .config import DEFAULT_LOCAL_SCHEME
12+ from .config import DEFAULT_TAG_REGEX
13+ from .config import DEFAULT_VERSION_SCHEME
2214from .discover import iter_matching_entrypoints
15+ from .utils import function_has_arg
16+ from .utils import trace
17+ from .version import format_version
18+ from .version import meta
2319
2420PRETEND_KEY = "SETUPTOOLS_SCM_PRETEND_VERSION"
2521PRETEND_KEY_NAMED = PRETEND_KEY + "_FOR_{name}"
@@ -40,9 +36,9 @@ def version_from_scm(root):
4036 warnings .warn (
4137 "version_from_scm is deprecated please use get_version" ,
4238 category = DeprecationWarning ,
39+ stacklevel = 2 ,
4340 )
44- config = Configuration ()
45- config .root = root
41+ config = Configuration (root = root )
4642 # TODO: Is it API?
4743 return _version_from_entrypoints (config )
4844
@@ -52,15 +48,16 @@ def _call_entrypoint_fn(root, config, fn):
5248 return fn (root , config = config )
5349 else :
5450 warnings .warn (
55- "parse functions are required to provide a named argument"
56- " 'config' in the future." ,
57- category = PendingDeprecationWarning ,
51+ f"parse function { fn .__module__ } .{ fn .__name__ } "
52+ " are required to provide a named argument"
53+ " 'config', setuptools_scm>=8.0 will remove support." ,
54+ category = DeprecationWarning ,
5855 stacklevel = 2 ,
5956 )
6057 return fn (root )
6158
6259
63- def _version_from_entrypoints (config , fallback = False ):
60+ def _version_from_entrypoints (config : Configuration , fallback = False ):
6461 if fallback :
6562 entrypoint = "setuptools_scm.parse_scm_fallback"
6663 root = config .fallback_root
@@ -70,7 +67,7 @@ def _version_from_entrypoints(config, fallback=False):
7067
7168 for ep in iter_matching_entrypoints (root , entrypoint , config ):
7269 version = _call_entrypoint_fn (root , config , ep .load ())
73-
70+ trace ( ep , version )
7471 if version :
7572 return version
7673
@@ -90,7 +87,7 @@ def dump_version(root, version, write_to, template=None):
9087 )
9188 )
9289
93- parsed_version = parse (version )
90+ parsed_version = Version (version )
9491 version_fields = parsed_version .release
9592 if parsed_version .dev is not None :
9693 version_fields += (f"dev{ parsed_version .dev } " ,)
@@ -201,10 +198,11 @@ def _get_version(config):
201198 "dump_version" ,
202199 "version_from_scm" ,
203200 "Configuration" ,
204- "NonNormalizedVersion" ,
205201 "DEFAULT_VERSION_SCHEME" ,
206202 "DEFAULT_LOCAL_SCHEME" ,
207203 "DEFAULT_TAG_REGEX" ,
204+ "Version" ,
205+ "NonNormalizedVersion" ,
208206 # TODO: are the symbols below part of public API ?
209207 "function_has_arg" ,
210208 "trace" ,
0 commit comments