@@ -34,22 +34,27 @@ def version_from_scm(root):
3434 return _version_from_entrypoint (config , "setuptools_scm.parse_scm" )
3535
3636
37- def _call_entrypoint_fn (config , fn ):
37+ def _call_entrypoint_fn (root , config , fn ):
3838 if function_has_arg (fn , "config" ):
39- return fn (config . absolute_root , config = config )
39+ return fn (root , config = config )
4040 else :
4141 warnings .warn (
4242 "parse functions are required to provide a named argument"
4343 " 'config' in the future." ,
4444 category = PendingDeprecationWarning ,
4545 stacklevel = 2 ,
4646 )
47- return fn (config . absolute_root )
47+ return fn (root )
4848
4949
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 ())
5358
5459 if version :
5560 return version
@@ -81,20 +86,20 @@ def _do_parse(config):
8186 return meta (tag = pretended , preformatted = True , config = config )
8287
8388 if config .parse :
84- parse_result = _call_entrypoint_fn (config , config .parse )
89+ parse_result = _call_entrypoint_fn (config . absolute_root , config , config .parse )
8590 if isinstance (parse_result , string_types ):
8691 raise TypeError (
8792 "version parse result was a string\n please return a parsed version"
8893 )
8994 version = parse_result or _version_from_entrypoint (
90- config , "setuptools_scm.parse_scm_fallback"
95+ config , "setuptools_scm.parse_scm" , fallback = True
9196 )
9297 else :
9398 # include fallbacks after dropping them from the main entrypoint
9499 version = _version_from_entrypoint (
95100 config , "setuptools_scm.parse_scm"
96101 ) or _version_from_entrypoint (
97- config , "setuptools_scm.parse_scm_fallback"
102+ config , "setuptools_scm.parse_scm" , fallback = True
98103 )
99104
100105 if version :
0 commit comments