summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/setuptools_scm/__init__.py23
-rw-r--r--src/setuptools_scm/config.py25
2 files changed, 29 insertions, 19 deletions
diff --git a/src/setuptools_scm/__init__.py b/src/setuptools_scm/__init__.py
index 58be234..49c0c4b 100644
--- a/src/setuptools_scm/__init__.py
+++ b/src/setuptools_scm/__init__.py
@@ -29,10 +29,14 @@ def version_from_scm(root):
def _call_entrypoint_fn(config, fn):
- if function_has_arg(fn, 'config'):
+ if function_has_arg(fn, "config"):
return fn(config.absolute_root, config=config)
else:
- warnings.warn("parse functions are required to provide a named argument 'config' in the future.", PendingDeprecationWarning)
+ warnings.warn(
+ "parse functions are required to provide a named argument"
+ " 'config' in the future.",
+ PendingDeprecationWarning,
+ )
return fn(config.absolute_root)
@@ -75,13 +79,16 @@ def _do_parse(config):
raise TypeError(
"version parse result was a string\nplease return a parsed version"
)
- version = parse_result or \
- _version_from_entrypoint(config, "setuptools_scm.parse_scm_fallback")
-
+ version = parse_result or _version_from_entrypoint(
+ config, "setuptools_scm.parse_scm_fallback"
+ )
else:
# include fallbacks after dropping them from the main entrypoint
- version = _version_from_entrypoint(config, "setuptools_scm.parse_scm") or \
- _version_from_entrypoint(config, "setuptools_scm.parse_scm_fallback")
+ version = _version_from_entrypoint(
+ config, "setuptools_scm.parse_scm"
+ ) or _version_from_entrypoint(
+ config, "setuptools_scm.parse_scm_fallback"
+ )
if version:
return version
@@ -114,7 +121,7 @@ def get_version(
in the root of the repository to direct setuptools_scm to the
root of the repository by supplying ``__file__``.
"""
-
+
config = Configuration()
config.root = root
config.version_scheme = version_scheme
diff --git a/src/setuptools_scm/config.py b/src/setuptools_scm/config.py
index dbd3768..b1c07f8 100644
--- a/src/setuptools_scm/config.py
+++ b/src/setuptools_scm/config.py
@@ -6,8 +6,8 @@ import warnings
from .utils import trace
-DEFAULT_TAG_REGEX = r'^(?:\w+-)?(?P<version>v?\d+(?:\.\d+){0,2}[^\+]+)(?:\+.*)?$'
-DEFAULT_VERSION_SCHEME = 'version_scheme'
+DEFAULT_TAG_REGEX = r"^(?:[\w-]+-)?(?P<version>v?\d+(?:\.\d+){0,2}[^\+]+)(?:\+.*)?$"
+DEFAULT_VERSION_SCHEME = "version_scheme"
def _check_tag_regex(value):
@@ -16,9 +16,11 @@ def _check_tag_regex(value):
regex = re.compile(value)
group_names = regex.groupindex.keys()
- if regex.groups == 0 or (regex.groups > 1 and 'version' not in group_names):
- warnings.warn("Expected tag_regex to contain a single match group or a group named 'version' " +
- "to identify the version part of any tag.")
+ if regex.groups == 0 or (regex.groups > 1 and "version" not in group_names):
+ warnings.warn(
+ "Expected tag_regex to contain a single match group or a group named"
+ " 'version' to identify the version part of any tag."
+ )
return regex
@@ -26,7 +28,10 @@ def _check_tag_regex(value):
def _check_absolute_root(root, relative_to):
if relative_to:
if os.path.isabs(root) and not root.startswith(relative_to):
- warnings.warn("absolute root path '%s' overrides relative_to '%s'" % (root, relative_to))
+ warnings.warn(
+ "absolute root path '%s' overrides relative_to '%s'"
+ % (root, relative_to)
+ )
root = os.path.join(os.path.dirname(relative_to), root)
return os.path.abspath(root)
@@ -44,17 +49,15 @@ class Configuration(object):
_tag_regex = None
_absolute_root = None
- def __init__(self,
- relative_to=None,
- root='.'):
+ def __init__(self, relative_to=None, root="."):
# TODO:
self._relative_to = relative_to
- self._root = '.'
+ self._root = "."
self.root = root
self.version_scheme = DEFAULT_VERSION_SCHEME
self.local_scheme = "node-and-date"
- self.write_to = ''
+ self.write_to = ""
self.write_to_template = None
self.parse = None
self.tag_regex = DEFAULT_TAG_REGEX