@@ -34,22 +34,27 @@ def version_from_scm(root):
34
34
return _version_from_entrypoint (config , "setuptools_scm.parse_scm" )
35
35
36
36
37
- def _call_entrypoint_fn (config , fn ):
37
+ def _call_entrypoint_fn (root , config , fn ):
38
38
if function_has_arg (fn , "config" ):
39
- return fn (config . absolute_root , config = config )
39
+ return fn (root , config = config )
40
40
else :
41
41
warnings .warn (
42
42
"parse functions are required to provide a named argument"
43
43
" 'config' in the future." ,
44
44
category = PendingDeprecationWarning ,
45
45
stacklevel = 2 ,
46
46
)
47
- return fn (config . absolute_root )
47
+ return fn (root )
48
48
49
49
50
- def _version_from_entrypoint (config , entrypoint ):
51
- for ep in iter_matching_entrypoints (config .absolute_root , entrypoint ):
52
- version = _call_entrypoint_fn (config , ep .load ())
50
+ def _version_from_entrypoint (config , entrypoint , fallback = False ):
51
+ if fallback :
52
+ entrypoint += "_fallback"
53
+ root = config .fallback_root
54
+ else :
55
+ root = config .absolute_root
56
+ for ep in iter_matching_entrypoints (root , entrypoint ):
57
+ version = _call_entrypoint_fn (root , config , ep .load ())
53
58
54
59
if version :
55
60
return version
@@ -81,20 +86,20 @@ def _do_parse(config):
81
86
return meta (tag = pretended , preformatted = True , config = config )
82
87
83
88
if config .parse :
84
- parse_result = _call_entrypoint_fn (config , config .parse )
89
+ parse_result = _call_entrypoint_fn (config . absolute_root , config , config .parse )
85
90
if isinstance (parse_result , string_types ):
86
91
raise TypeError (
87
92
"version parse result was a string\n please return a parsed version"
88
93
)
89
94
version = parse_result or _version_from_entrypoint (
90
- config , "setuptools_scm.parse_scm_fallback"
95
+ config , "setuptools_scm.parse_scm" , fallback = True
91
96
)
92
97
else :
93
98
# include fallbacks after dropping them from the main entrypoint
94
99
version = _version_from_entrypoint (
95
100
config , "setuptools_scm.parse_scm"
96
101
) or _version_from_entrypoint (
97
- config , "setuptools_scm.parse_scm_fallback"
102
+ config , "setuptools_scm.parse_scm" , fallback = True
98
103
)
99
104
100
105
if version :
0 commit comments