5
5
import os
6
6
import warnings
7
7
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
22
14
from .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
23
19
24
20
PRETEND_KEY = "SETUPTOOLS_SCM_PRETEND_VERSION"
25
21
PRETEND_KEY_NAMED = PRETEND_KEY + "_FOR_{name}"
@@ -40,9 +36,9 @@ def version_from_scm(root):
40
36
warnings .warn (
41
37
"version_from_scm is deprecated please use get_version" ,
42
38
category = DeprecationWarning ,
39
+ stacklevel = 2 ,
43
40
)
44
- config = Configuration ()
45
- config .root = root
41
+ config = Configuration (root = root )
46
42
# TODO: Is it API?
47
43
return _version_from_entrypoints (config )
48
44
@@ -52,15 +48,16 @@ def _call_entrypoint_fn(root, config, fn):
52
48
return fn (root , config = config )
53
49
else :
54
50
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 ,
58
55
stacklevel = 2 ,
59
56
)
60
57
return fn (root )
61
58
62
59
63
- def _version_from_entrypoints (config , fallback = False ):
60
+ def _version_from_entrypoints (config : Configuration , fallback = False ):
64
61
if fallback :
65
62
entrypoint = "setuptools_scm.parse_scm_fallback"
66
63
root = config .fallback_root
@@ -70,7 +67,7 @@ def _version_from_entrypoints(config, fallback=False):
70
67
71
68
for ep in iter_matching_entrypoints (root , entrypoint , config ):
72
69
version = _call_entrypoint_fn (root , config , ep .load ())
73
-
70
+ trace ( ep , version )
74
71
if version :
75
72
return version
76
73
@@ -90,7 +87,7 @@ def dump_version(root, version, write_to, template=None):
90
87
)
91
88
)
92
89
93
- parsed_version = parse (version )
90
+ parsed_version = Version (version )
94
91
version_fields = parsed_version .release
95
92
if parsed_version .dev is not None :
96
93
version_fields += (f"dev{ parsed_version .dev } " ,)
@@ -201,10 +198,11 @@ def _get_version(config):
201
198
"dump_version" ,
202
199
"version_from_scm" ,
203
200
"Configuration" ,
204
- "NonNormalizedVersion" ,
205
201
"DEFAULT_VERSION_SCHEME" ,
206
202
"DEFAULT_LOCAL_SCHEME" ,
207
203
"DEFAULT_TAG_REGEX" ,
204
+ "Version" ,
205
+ "NonNormalizedVersion" ,
208
206
# TODO: are the symbols below part of public API ?
209
207
"function_has_arg" ,
210
208
"trace" ,
0 commit comments