6262
6363
6464def _exec (cmd : str , root : str | os .PathLike | None = None ) -> list [str ]:
65- log .debug ( "Executing '%s' at '%s'" , cmd , root or os .getcwd ())
65+ log .log ( DEBUG , "Executing '%s' at '%s'" , cmd , root or os .getcwd ())
6666 try :
6767 stdout = subprocess .check_output (cmd , shell = True , text = True , cwd = root ) # nosec
6868 except subprocess .CalledProcessError as e :
@@ -159,7 +159,7 @@ def read_toml(name_or_path: str | os.PathLike = "pyproject.toml", root: str | os
159159 parsed_file = toml .load (file_path )
160160 result = parsed_file .get ("tool" , {}).get ("setuptools-git-versioning" , None )
161161 if result :
162- log .debug ( "'tool.setuptools-git-versioning' section content:\n %s" , pformat (result ))
162+ log .log ( DEBUG , "'tool.setuptools-git-versioning' section content:\n %s" , pformat (result ))
163163 return result
164164
165165
@@ -262,45 +262,45 @@ def read_version_from_file(name_or_path: str | os.PathLike, root: str | os.PathL
262262
263263
264264def substitute_env_variables (template : str ) -> str :
265- log .debug ( "Substitute environment variables in template '%s'" , template )
265+ log .log ( DEBUG , "Substitute environment variables in template '%s'" , template )
266266 for var , default in ENV_VARS_REGEXP .findall (template ):
267- log .debug ( "Variable: '%s'" , var )
267+ log .log ( DEBUG , "Variable: '%s'" , var )
268268
269269 if default .upper () == "IGNORE" :
270270 default = ""
271271 elif not default :
272272 default = "UNKNOWN"
273- log .debug ( "Default: '%s'" , default )
273+ log .log ( DEBUG , "Default: '%s'" , default )
274274
275275 value = os .environ .get (var , default )
276- log .debug ( "Value: '%s'" , value )
276+ log .log ( DEBUG , "Value: '%s'" , value )
277277
278278 template , _ = ENV_VARS_REGEXP .subn (value , template , count = 1 )
279279
280- log .debug ( "Result: '%s'" , template )
280+ log .log ( DEBUG , "Result: '%s'" , template )
281281 return template
282282
283283
284284def substitute_timestamp (template : str ) -> str :
285- log .debug ( "Substitute timestampts in template '%s'" , template )
285+ log .log ( DEBUG , "Substitute timestampts in template '%s'" , template )
286286
287287 now = datetime .now ()
288288 for fmt in TIMESTAMP_REGEXP .findall (template ):
289289 format_string = fmt or "%s"
290- log .debug ( "Format: '%s'" , format_string )
290+ log .log ( DEBUG , "Format: '%s'" , format_string )
291291
292292 result = now .strftime (fmt or "%s" )
293- log .debug ( "Value: '%s'" , result )
293+ log .log ( DEBUG , "Value: '%s'" , result )
294294
295295 template , _ = TIMESTAMP_REGEXP .subn (result , template , count = 1 )
296296
297- log .debug ( "Result: '%s'" , template )
297+ log .log ( DEBUG , "Result: '%s'" , template )
298298 return template
299299
300300
301301def resolve_substitutions (template : str , * args , ** kwargs ) -> str :
302- log .debug ( "Template: '%s'" , template )
303- log .debug ( "Args:%s" , pformat (args ))
302+ log .log ( DEBUG , "Template: '%s'" , template )
303+ log .log ( DEBUG , "Args:%s" , pformat (args ))
304304
305305 while True :
306306 if "{env" in template :
@@ -321,7 +321,7 @@ def resolve_substitutions(template: str, *args, **kwargs) -> str:
321321def add_to_sys_path (root : str | os .PathLike | None ) -> None :
322322 root_path = os .fspath (Path (root or os .getcwd ()))
323323 if root_path not in sys .path :
324- log .debug ( "Adding '%s' folder to sys.path" , root_path )
324+ log .log ( DEBUG , "Adding '%s' folder to sys.path" , root_path )
325325 sys .path .insert (0 , root_path )
326326
327327
@@ -336,7 +336,7 @@ def import_reference(
336336 add_to_sys_path (root )
337337
338338 module_name , attr = ref .split (":" )
339- log .debug ( "Executing 'from %s.%s import %s'" , package_name or "" , module_name , attr )
339+ log .log ( DEBUG , "Executing 'from %s.%s import %s'" , package_name or "" , module_name , attr )
340340 module = importlib .import_module (module_name , package_name )
341341
342342 return getattr (module , attr )
@@ -362,7 +362,7 @@ def load_tag_formatter(
362362 log .log (INFO , "Parsing tag_formatter '%s' of type '%s'" , tag_formatter , type (tag_formatter ).__name__ )
363363
364364 if callable (tag_formatter ):
365- log .debug ( "Value is callable with signature %s" , inspect .Signature .from_callable (tag_formatter ))
365+ log .log ( DEBUG , "Value is callable with signature %s" , inspect .Signature .from_callable (tag_formatter ))
366366 return tag_formatter
367367
368368 try :
@@ -395,7 +395,7 @@ def load_branch_formatter(
395395 log .log (INFO , "Parsing branch_formatter '%s' of type '%s'" , branch_formatter , type (branch_formatter ).__name__ )
396396
397397 if callable (branch_formatter ):
398- log .debug ( "Value is callable with signature %s" , inspect .Signature .from_callable (branch_formatter ))
398+ log .log ( DEBUG , "Value is callable with signature %s" , inspect .Signature .from_callable (branch_formatter ))
399399 return branch_formatter
400400
401401 try :
@@ -429,7 +429,7 @@ def get_version_from_callback(
429429 log .log (INFO , "Parsing version_callback %s of type %s" , version_callback , type (version_callback ))
430430
431431 if callable (version_callback ):
432- log .debug ( "Value is callable with signature %s" , inspect .Signature .from_callable (version_callback ))
432+ log .log ( DEBUG , "Value is callable with signature %s" , inspect .Signature .from_callable (version_callback ))
433433 result = version_callback ()
434434 else :
435435
@@ -441,7 +441,7 @@ def get_version_from_callback(
441441 result = callback ()
442442 except ValueError as e :
443443 log .log (INFO , "Is not a callable" )
444- log .debug ( str (e ))
444+ log .log ( DEBUG , str (e ))
445445 log .log (INFO , "Assuming it is a string attribute" )
446446 result = import_reference (version_callback , package_name , root = root )
447447 except (ImportError , NameError ) as e :
@@ -488,7 +488,7 @@ def version_from_git(
488488
489489 from_file = False
490490 log .log (INFO , "Getting latest tag" )
491- log .debug ( "Sorting tags by '%s'" , sort_by )
491+ log .log ( DEBUG , "Sorting tags by '%s'" , sort_by )
492492 tag = get_tag (sort_by = sort_by , root = root )
493493
494494 if tag is None :
@@ -514,14 +514,14 @@ def version_from_git(
514514 log .log (INFO , "File is empty, return starting_version '%s'" , version_file , starting_version )
515515 return starting_version
516516
517- log .debug ( "File content: '%s'" , tag )
517+ log .log ( DEBUG , "File content: '%s'" , tag )
518518 if not count_commits_from_version_file :
519519 result = VERSION_PREFIX_REGEXP .sub ("" , tag ) # for tag "v1.0.0" drop leading "v" symbol
520520 log .log (INFO , "Return '%s'" , result )
521521 return result
522522
523523 tag_sha = get_latest_file_commit (version_file , root = root )
524- log .debug ( "File content: '%s'" , tag )
524+ log .log ( DEBUG , "File content: '%s'" , tag )
525525 else :
526526 log .log (INFO , "Latest tag: '%s'" , tag )
527527 tag_sha = get_sha (tag , root = root )
@@ -530,7 +530,7 @@ def version_from_git(
530530 if tag_formatter is not None :
531531 tag_fmt = load_tag_formatter (tag_formatter , package_name , root = root )
532532 tag = tag_fmt (tag )
533- log .debug ( "Tag after formatting: '%s'" , tag )
533+ log .log ( DEBUG , "Tag after formatting: '%s'" , tag )
534534
535535 dirty = is_dirty (root = root )
536536 log .log (INFO , "Is dirty: %s" , dirty )
0 commit comments