diff --git a/src/actinet/_version.py b/src/actinet/_version.py index 0e06a6a..b5bc938 100644 --- a/src/actinet/_version.py +++ b/src/actinet/_version.py @@ -6,7 +6,7 @@ # that just contains the computed version number. # This file is released into the public domain. -# Generated by versioneer-0.29 +# Generated by versioneer-0.28 # https://github.com/python-versioneer/python-versioneer """Git implementation of _version.py.""" @@ -16,11 +16,11 @@ import re import subprocess import sys -from typing import Any, Callable, Dict, List, Optional, Tuple +from typing import Callable, Dict import functools -def get_keywords() -> Dict[str, str]: +def get_keywords(): """Get the keywords needed to look up the version information.""" # these strings will be replaced by git during git-archive. # setup.py/versioneer.py will grep for the variable names, so they must @@ -36,15 +36,8 @@ def get_keywords() -> Dict[str, str]: class VersioneerConfig: """Container for Versioneer configuration parameters.""" - VCS: str - style: str - tag_prefix: str - parentdir_prefix: str - versionfile_source: str - verbose: bool - -def get_config() -> VersioneerConfig: +def get_config(): """Create, populate and return the VersioneerConfig() object.""" # these strings are filled in when 'setup.py versioneer' creates # _version.py @@ -66,9 +59,9 @@ class NotThisMethod(Exception): HANDLERS: Dict[str, Dict[str, Callable]] = {} -def register_vcs_handler(vcs: str, method: str) -> Callable: # decorator +def register_vcs_handler(vcs, method): # decorator """Create decorator to mark a method as the handler of a VCS.""" - def decorate(f: Callable) -> Callable: + def decorate(f): """Store f in HANDLERS[vcs][method].""" if vcs not in HANDLERS: HANDLERS[vcs] = {} @@ -77,19 +70,13 @@ def decorate(f: Callable) -> Callable: return decorate -def run_command( - commands: List[str], - args: List[str], - cwd: Optional[str] = None, - verbose: bool = False, - hide_stderr: bool = False, - env: Optional[Dict[str, str]] = None, -) -> Tuple[Optional[str], Optional[int]]: +def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, + env=None): """Call the given command(s).""" assert isinstance(commands, list) process = None - popen_kwargs: Dict[str, Any] = {} + popen_kwargs = {} if sys.platform == "win32": # This hides the console window if pythonw.exe is used startupinfo = subprocess.STARTUPINFO() @@ -105,7 +92,8 @@ def run_command( stderr=(subprocess.PIPE if hide_stderr else None), **popen_kwargs) break - except OSError as e: + except OSError: + e = sys.exc_info()[1] if e.errno == errno.ENOENT: continue if verbose: @@ -125,11 +113,7 @@ def run_command( return stdout, process.returncode -def versions_from_parentdir( - parentdir_prefix: str, - root: str, - verbose: bool, -) -> Dict[str, Any]: +def versions_from_parentdir(parentdir_prefix, root, verbose): """Try to determine the version from the parent directory name. Source tarballs conventionally unpack into a directory that includes both @@ -154,13 +138,13 @@ def versions_from_parentdir( @register_vcs_handler("git", "get_keywords") -def git_get_keywords(versionfile_abs: str) -> Dict[str, str]: +def git_get_keywords(versionfile_abs): """Extract version information from the given file.""" # the code embedded in _version.py can just fetch the value of these # keywords. When used from setup.py, we don't want to import _version.py, # so we do it with a regexp instead. This function is not used from # _version.py. - keywords: Dict[str, str] = {} + keywords = {} try: with open(versionfile_abs, "r") as fobj: for line in fobj: @@ -182,11 +166,7 @@ def git_get_keywords(versionfile_abs: str) -> Dict[str, str]: @register_vcs_handler("git", "keywords") -def git_versions_from_keywords( - keywords: Dict[str, str], - tag_prefix: str, - verbose: bool, -) -> Dict[str, Any]: +def git_versions_from_keywords(keywords, tag_prefix, verbose): """Get version information from git keywords.""" if "refnames" not in keywords: raise NotThisMethod("Short version file found") @@ -250,12 +230,7 @@ def git_versions_from_keywords( @register_vcs_handler("git", "pieces_from_vcs") -def git_pieces_from_vcs( - tag_prefix: str, - root: str, - verbose: bool, - runner: Callable = run_command -) -> Dict[str, Any]: +def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): """Get version from 'git describe' in the root of the source tree. This only gets called if the git-archive 'subst' keywords were *not* @@ -295,7 +270,7 @@ def git_pieces_from_vcs( raise NotThisMethod("'git rev-parse' failed") full_out = full_out.strip() - pieces: Dict[str, Any] = {} + pieces = {} pieces["long"] = full_out pieces["short"] = full_out[:7] # maybe improved later pieces["error"] = None @@ -387,14 +362,14 @@ def git_pieces_from_vcs( return pieces -def plus_or_dot(pieces: Dict[str, Any]) -> str: +def plus_or_dot(pieces): """Return a + if we don't already have one, else return a .""" if "+" in pieces.get("closest-tag", ""): return "." return "+" -def render_pep440(pieces: Dict[str, Any]) -> str: +def render_pep440(pieces): """Build up version string, with post-release "local version identifier". Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you @@ -419,7 +394,7 @@ def render_pep440(pieces: Dict[str, Any]) -> str: return rendered -def render_pep440_branch(pieces: Dict[str, Any]) -> str: +def render_pep440_branch(pieces): """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] . The ".dev0" means not master branch. Note that .dev0 sorts backwards @@ -449,7 +424,7 @@ def render_pep440_branch(pieces: Dict[str, Any]) -> str: return rendered -def pep440_split_post(ver: str) -> Tuple[str, Optional[int]]: +def pep440_split_post(ver): """Split pep440 version string at the post-release segment. Returns the release segments before the post-release and the @@ -459,7 +434,7 @@ def pep440_split_post(ver: str) -> Tuple[str, Optional[int]]: return vc[0], int(vc[1] or 0) if len(vc) == 2 else None -def render_pep440_pre(pieces: Dict[str, Any]) -> str: +def render_pep440_pre(pieces): """TAG[.postN.devDISTANCE] -- No -dirty. Exceptions: @@ -483,7 +458,7 @@ def render_pep440_pre(pieces: Dict[str, Any]) -> str: return rendered -def render_pep440_post(pieces: Dict[str, Any]) -> str: +def render_pep440_post(pieces): """TAG[.postDISTANCE[.dev0]+gHEX] . The ".dev0" means dirty. Note that .dev0 sorts backwards @@ -510,7 +485,7 @@ def render_pep440_post(pieces: Dict[str, Any]) -> str: return rendered -def render_pep440_post_branch(pieces: Dict[str, Any]) -> str: +def render_pep440_post_branch(pieces): """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . The ".dev0" means not master branch. @@ -539,7 +514,7 @@ def render_pep440_post_branch(pieces: Dict[str, Any]) -> str: return rendered -def render_pep440_old(pieces: Dict[str, Any]) -> str: +def render_pep440_old(pieces): """TAG[.postDISTANCE[.dev0]] . The ".dev0" means dirty. @@ -561,7 +536,7 @@ def render_pep440_old(pieces: Dict[str, Any]) -> str: return rendered -def render_git_describe(pieces: Dict[str, Any]) -> str: +def render_git_describe(pieces): """TAG[-DISTANCE-gHEX][-dirty]. Like 'git describe --tags --dirty --always'. @@ -581,7 +556,7 @@ def render_git_describe(pieces: Dict[str, Any]) -> str: return rendered -def render_git_describe_long(pieces: Dict[str, Any]) -> str: +def render_git_describe_long(pieces): """TAG-DISTANCE-gHEX[-dirty]. Like 'git describe --tags --dirty --always -long'. @@ -601,7 +576,7 @@ def render_git_describe_long(pieces: Dict[str, Any]) -> str: return rendered -def render(pieces: Dict[str, Any], style: str) -> Dict[str, Any]: +def render(pieces, style): """Render the given version pieces into the requested style.""" if pieces["error"]: return {"version": "unknown", @@ -637,7 +612,7 @@ def render(pieces: Dict[str, Any], style: str) -> Dict[str, Any]: "date": pieces.get("date")} -def get_versions() -> Dict[str, Any]: +def get_versions(): """Get version information or return default if unable to do so.""" # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have # __file__, we can work backwards from there to the root. Some diff --git a/versioneer.py b/versioneer.py index 1e3753e..18e34c2 100644 --- a/versioneer.py +++ b/versioneer.py @@ -1,5 +1,5 @@ -# Version: 0.29 +# Version: 0.28 """The Versioneer - like a rocketeer, but for versions. @@ -10,7 +10,7 @@ * https://github.com/python-versioneer/python-versioneer * Brian Warner * License: Public Domain (Unlicense) -* Compatible with: Python 3.7, 3.8, 3.9, 3.10, 3.11 and pypy3 +* Compatible with: Python 3.7, 3.8, 3.9, 3.10 and pypy3 * [![Latest Version][pypi-image]][pypi-url] * [![Build Status][travis-image]][travis-url] @@ -316,8 +316,7 @@ import subprocess import sys from pathlib import Path -from typing import Any, Callable, cast, Dict, List, Optional, Tuple, Union -from typing import NoReturn +from typing import Callable, Dict import functools have_tomllib = True @@ -333,16 +332,8 @@ class VersioneerConfig: """Container for Versioneer configuration parameters.""" - VCS: str - style: str - tag_prefix: str - versionfile_source: str - versionfile_build: Optional[str] - parentdir_prefix: Optional[str] - verbose: Optional[bool] - -def get_root() -> str: +def get_root(): """Get the project root directory. We require that all commands are run from the project root, i.e. the @@ -350,23 +341,13 @@ def get_root() -> str: """ root = os.path.realpath(os.path.abspath(os.getcwd())) setup_py = os.path.join(root, "setup.py") - pyproject_toml = os.path.join(root, "pyproject.toml") versioneer_py = os.path.join(root, "versioneer.py") - if not ( - os.path.exists(setup_py) - or os.path.exists(pyproject_toml) - or os.path.exists(versioneer_py) - ): + if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)): # allow 'python path/to/setup.py COMMAND' root = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0]))) setup_py = os.path.join(root, "setup.py") - pyproject_toml = os.path.join(root, "pyproject.toml") versioneer_py = os.path.join(root, "versioneer.py") - if not ( - os.path.exists(setup_py) - or os.path.exists(pyproject_toml) - or os.path.exists(versioneer_py) - ): + if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)): err = ("Versioneer was unable to run the project root directory. " "Versioneer requires setup.py to be executed from " "its immediate directory (like 'python setup.py COMMAND'), " @@ -391,24 +372,23 @@ def get_root() -> str: return root -def get_config_from_root(root: str) -> VersioneerConfig: +def get_config_from_root(root): """Read the project setup.cfg file to determine Versioneer config.""" # This might raise OSError (if setup.cfg is missing), or # configparser.NoSectionError (if it lacks a [versioneer] section), or # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . - root_pth = Path(root) - pyproject_toml = root_pth / "pyproject.toml" - setup_cfg = root_pth / "setup.cfg" - section: Union[Dict[str, Any], configparser.SectionProxy, None] = None + root = Path(root) + pyproject_toml = root / "pyproject.toml" + setup_cfg = root / "setup.cfg" + section = None if pyproject_toml.exists() and have_tomllib: try: with open(pyproject_toml, 'rb') as fobj: pp = tomllib.load(fobj) section = pp['tool']['versioneer'] - except (tomllib.TOMLDecodeError, KeyError) as e: - print(f"Failed to load config from {pyproject_toml}: {e}") - print("Try to load it from setup.cfg") + except (tomllib.TOMLDecodeError, KeyError): + pass if not section: parser = configparser.ConfigParser() with open(setup_cfg) as cfg_file: @@ -417,25 +397,16 @@ def get_config_from_root(root: str) -> VersioneerConfig: section = parser["versioneer"] - # `cast`` really shouldn't be used, but its simplest for the - # common VersioneerConfig users at the moment. We verify against - # `None` values elsewhere where it matters - cfg = VersioneerConfig() cfg.VCS = section['VCS'] cfg.style = section.get("style", "") - cfg.versionfile_source = cast(str, section.get("versionfile_source")) + cfg.versionfile_source = section.get("versionfile_source") cfg.versionfile_build = section.get("versionfile_build") - cfg.tag_prefix = cast(str, section.get("tag_prefix")) + cfg.tag_prefix = section.get("tag_prefix") if cfg.tag_prefix in ("''", '""', None): cfg.tag_prefix = "" cfg.parentdir_prefix = section.get("parentdir_prefix") - if isinstance(section, configparser.SectionProxy): - # Make sure configparser translates to bool - cfg.verbose = section.getboolean("verbose") - else: - cfg.verbose = section.get("verbose") - + cfg.verbose = section.get("verbose") return cfg @@ -448,28 +419,22 @@ class NotThisMethod(Exception): HANDLERS: Dict[str, Dict[str, Callable]] = {} -def register_vcs_handler(vcs: str, method: str) -> Callable: # decorator +def register_vcs_handler(vcs, method): # decorator """Create decorator to mark a method as the handler of a VCS.""" - def decorate(f: Callable) -> Callable: + def decorate(f): """Store f in HANDLERS[vcs][method].""" HANDLERS.setdefault(vcs, {})[method] = f return f return decorate -def run_command( - commands: List[str], - args: List[str], - cwd: Optional[str] = None, - verbose: bool = False, - hide_stderr: bool = False, - env: Optional[Dict[str, str]] = None, -) -> Tuple[Optional[str], Optional[int]]: +def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, + env=None): """Call the given command(s).""" assert isinstance(commands, list) process = None - popen_kwargs: Dict[str, Any] = {} + popen_kwargs = {} if sys.platform == "win32": # This hides the console window if pythonw.exe is used startupinfo = subprocess.STARTUPINFO() @@ -485,7 +450,8 @@ def run_command( stderr=(subprocess.PIPE if hide_stderr else None), **popen_kwargs) break - except OSError as e: + except OSError: + e = sys.exc_info()[1] if e.errno == errno.ENOENT: continue if verbose: @@ -513,7 +479,7 @@ def run_command( # that just contains the computed version number. # This file is released into the public domain. -# Generated by versioneer-0.29 +# Generated by versioneer-0.28 # https://github.com/python-versioneer/python-versioneer """Git implementation of _version.py.""" @@ -523,11 +489,11 @@ def run_command( import re import subprocess import sys -from typing import Any, Callable, Dict, List, Optional, Tuple +from typing import Callable, Dict import functools -def get_keywords() -> Dict[str, str]: +def get_keywords(): """Get the keywords needed to look up the version information.""" # these strings will be replaced by git during git-archive. # setup.py/versioneer.py will grep for the variable names, so they must @@ -543,15 +509,8 @@ def get_keywords() -> Dict[str, str]: class VersioneerConfig: """Container for Versioneer configuration parameters.""" - VCS: str - style: str - tag_prefix: str - parentdir_prefix: str - versionfile_source: str - verbose: bool - -def get_config() -> VersioneerConfig: +def get_config(): """Create, populate and return the VersioneerConfig() object.""" # these strings are filled in when 'setup.py versioneer' creates # _version.py @@ -573,9 +532,9 @@ class NotThisMethod(Exception): HANDLERS: Dict[str, Dict[str, Callable]] = {} -def register_vcs_handler(vcs: str, method: str) -> Callable: # decorator +def register_vcs_handler(vcs, method): # decorator """Create decorator to mark a method as the handler of a VCS.""" - def decorate(f: Callable) -> Callable: + def decorate(f): """Store f in HANDLERS[vcs][method].""" if vcs not in HANDLERS: HANDLERS[vcs] = {} @@ -584,19 +543,13 @@ def decorate(f: Callable) -> Callable: return decorate -def run_command( - commands: List[str], - args: List[str], - cwd: Optional[str] = None, - verbose: bool = False, - hide_stderr: bool = False, - env: Optional[Dict[str, str]] = None, -) -> Tuple[Optional[str], Optional[int]]: +def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, + env=None): """Call the given command(s).""" assert isinstance(commands, list) process = None - popen_kwargs: Dict[str, Any] = {} + popen_kwargs = {} if sys.platform == "win32": # This hides the console window if pythonw.exe is used startupinfo = subprocess.STARTUPINFO() @@ -612,7 +565,8 @@ def run_command( stderr=(subprocess.PIPE if hide_stderr else None), **popen_kwargs) break - except OSError as e: + except OSError: + e = sys.exc_info()[1] if e.errno == errno.ENOENT: continue if verbose: @@ -632,11 +586,7 @@ def run_command( return stdout, process.returncode -def versions_from_parentdir( - parentdir_prefix: str, - root: str, - verbose: bool, -) -> Dict[str, Any]: +def versions_from_parentdir(parentdir_prefix, root, verbose): """Try to determine the version from the parent directory name. Source tarballs conventionally unpack into a directory that includes both @@ -661,13 +611,13 @@ def versions_from_parentdir( @register_vcs_handler("git", "get_keywords") -def git_get_keywords(versionfile_abs: str) -> Dict[str, str]: +def git_get_keywords(versionfile_abs): """Extract version information from the given file.""" # the code embedded in _version.py can just fetch the value of these # keywords. When used from setup.py, we don't want to import _version.py, # so we do it with a regexp instead. This function is not used from # _version.py. - keywords: Dict[str, str] = {} + keywords = {} try: with open(versionfile_abs, "r") as fobj: for line in fobj: @@ -689,11 +639,7 @@ def git_get_keywords(versionfile_abs: str) -> Dict[str, str]: @register_vcs_handler("git", "keywords") -def git_versions_from_keywords( - keywords: Dict[str, str], - tag_prefix: str, - verbose: bool, -) -> Dict[str, Any]: +def git_versions_from_keywords(keywords, tag_prefix, verbose): """Get version information from git keywords.""" if "refnames" not in keywords: raise NotThisMethod("Short version file found") @@ -757,12 +703,7 @@ def git_versions_from_keywords( @register_vcs_handler("git", "pieces_from_vcs") -def git_pieces_from_vcs( - tag_prefix: str, - root: str, - verbose: bool, - runner: Callable = run_command -) -> Dict[str, Any]: +def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): """Get version from 'git describe' in the root of the source tree. This only gets called if the git-archive 'subst' keywords were *not* @@ -802,7 +743,7 @@ def git_pieces_from_vcs( raise NotThisMethod("'git rev-parse' failed") full_out = full_out.strip() - pieces: Dict[str, Any] = {} + pieces = {} pieces["long"] = full_out pieces["short"] = full_out[:7] # maybe improved later pieces["error"] = None @@ -894,14 +835,14 @@ def git_pieces_from_vcs( return pieces -def plus_or_dot(pieces: Dict[str, Any]) -> str: +def plus_or_dot(pieces): """Return a + if we don't already have one, else return a .""" if "+" in pieces.get("closest-tag", ""): return "." return "+" -def render_pep440(pieces: Dict[str, Any]) -> str: +def render_pep440(pieces): """Build up version string, with post-release "local version identifier". Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you @@ -926,7 +867,7 @@ def render_pep440(pieces: Dict[str, Any]) -> str: return rendered -def render_pep440_branch(pieces: Dict[str, Any]) -> str: +def render_pep440_branch(pieces): """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] . The ".dev0" means not master branch. Note that .dev0 sorts backwards @@ -956,7 +897,7 @@ def render_pep440_branch(pieces: Dict[str, Any]) -> str: return rendered -def pep440_split_post(ver: str) -> Tuple[str, Optional[int]]: +def pep440_split_post(ver): """Split pep440 version string at the post-release segment. Returns the release segments before the post-release and the @@ -966,7 +907,7 @@ def pep440_split_post(ver: str) -> Tuple[str, Optional[int]]: return vc[0], int(vc[1] or 0) if len(vc) == 2 else None -def render_pep440_pre(pieces: Dict[str, Any]) -> str: +def render_pep440_pre(pieces): """TAG[.postN.devDISTANCE] -- No -dirty. Exceptions: @@ -990,7 +931,7 @@ def render_pep440_pre(pieces: Dict[str, Any]) -> str: return rendered -def render_pep440_post(pieces: Dict[str, Any]) -> str: +def render_pep440_post(pieces): """TAG[.postDISTANCE[.dev0]+gHEX] . The ".dev0" means dirty. Note that .dev0 sorts backwards @@ -1017,7 +958,7 @@ def render_pep440_post(pieces: Dict[str, Any]) -> str: return rendered -def render_pep440_post_branch(pieces: Dict[str, Any]) -> str: +def render_pep440_post_branch(pieces): """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . The ".dev0" means not master branch. @@ -1046,7 +987,7 @@ def render_pep440_post_branch(pieces: Dict[str, Any]) -> str: return rendered -def render_pep440_old(pieces: Dict[str, Any]) -> str: +def render_pep440_old(pieces): """TAG[.postDISTANCE[.dev0]] . The ".dev0" means dirty. @@ -1068,7 +1009,7 @@ def render_pep440_old(pieces: Dict[str, Any]) -> str: return rendered -def render_git_describe(pieces: Dict[str, Any]) -> str: +def render_git_describe(pieces): """TAG[-DISTANCE-gHEX][-dirty]. Like 'git describe --tags --dirty --always'. @@ -1088,7 +1029,7 @@ def render_git_describe(pieces: Dict[str, Any]) -> str: return rendered -def render_git_describe_long(pieces: Dict[str, Any]) -> str: +def render_git_describe_long(pieces): """TAG-DISTANCE-gHEX[-dirty]. Like 'git describe --tags --dirty --always -long'. @@ -1108,7 +1049,7 @@ def render_git_describe_long(pieces: Dict[str, Any]) -> str: return rendered -def render(pieces: Dict[str, Any], style: str) -> Dict[str, Any]: +def render(pieces, style): """Render the given version pieces into the requested style.""" if pieces["error"]: return {"version": "unknown", @@ -1144,7 +1085,7 @@ def render(pieces: Dict[str, Any], style: str) -> Dict[str, Any]: "date": pieces.get("date")} -def get_versions() -> Dict[str, Any]: +def get_versions(): """Get version information or return default if unable to do so.""" # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have # __file__, we can work backwards from there to the root. Some @@ -1192,13 +1133,13 @@ def get_versions() -> Dict[str, Any]: @register_vcs_handler("git", "get_keywords") -def git_get_keywords(versionfile_abs: str) -> Dict[str, str]: +def git_get_keywords(versionfile_abs): """Extract version information from the given file.""" # the code embedded in _version.py can just fetch the value of these # keywords. When used from setup.py, we don't want to import _version.py, # so we do it with a regexp instead. This function is not used from # _version.py. - keywords: Dict[str, str] = {} + keywords = {} try: with open(versionfile_abs, "r") as fobj: for line in fobj: @@ -1220,11 +1161,7 @@ def git_get_keywords(versionfile_abs: str) -> Dict[str, str]: @register_vcs_handler("git", "keywords") -def git_versions_from_keywords( - keywords: Dict[str, str], - tag_prefix: str, - verbose: bool, -) -> Dict[str, Any]: +def git_versions_from_keywords(keywords, tag_prefix, verbose): """Get version information from git keywords.""" if "refnames" not in keywords: raise NotThisMethod("Short version file found") @@ -1288,12 +1225,7 @@ def git_versions_from_keywords( @register_vcs_handler("git", "pieces_from_vcs") -def git_pieces_from_vcs( - tag_prefix: str, - root: str, - verbose: bool, - runner: Callable = run_command -) -> Dict[str, Any]: +def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): """Get version from 'git describe' in the root of the source tree. This only gets called if the git-archive 'subst' keywords were *not* @@ -1333,7 +1265,7 @@ def git_pieces_from_vcs( raise NotThisMethod("'git rev-parse' failed") full_out = full_out.strip() - pieces: Dict[str, Any] = {} + pieces = {} pieces["long"] = full_out pieces["short"] = full_out[:7] # maybe improved later pieces["error"] = None @@ -1425,7 +1357,7 @@ def git_pieces_from_vcs( return pieces -def do_vcs_install(versionfile_source: str, ipy: Optional[str]) -> None: +def do_vcs_install(versionfile_source, ipy): """Git-specific installation logic for Versioneer. For Git, this means creating/changing .gitattributes to mark _version.py @@ -1463,11 +1395,7 @@ def do_vcs_install(versionfile_source: str, ipy: Optional[str]) -> None: run_command(GITS, ["add", "--"] + files) -def versions_from_parentdir( - parentdir_prefix: str, - root: str, - verbose: bool, -) -> Dict[str, Any]: +def versions_from_parentdir(parentdir_prefix, root, verbose): """Try to determine the version from the parent directory name. Source tarballs conventionally unpack into a directory that includes both @@ -1492,7 +1420,7 @@ def versions_from_parentdir( SHORT_VERSION_PY = """ -# This file was generated by 'versioneer.py' (0.29) from +# This file was generated by 'versioneer.py' (0.28) from # revision-control system data, or from the parent directory name of an # unpacked source archive. Distribution tarballs contain a pre-generated copy # of this file. @@ -1509,7 +1437,7 @@ def get_versions(): """ -def versions_from_file(filename: str) -> Dict[str, Any]: +def versions_from_file(filename): """Try to determine the version from _version.py if present.""" try: with open(filename) as f: @@ -1526,8 +1454,9 @@ def versions_from_file(filename: str) -> Dict[str, Any]: return json.loads(mo.group(1)) -def write_to_version_file(filename: str, versions: Dict[str, Any]) -> None: +def write_to_version_file(filename, versions): """Write the given version number to the given _version.py file.""" + os.unlink(filename) contents = json.dumps(versions, sort_keys=True, indent=1, separators=(",", ": ")) with open(filename, "w") as f: @@ -1536,14 +1465,14 @@ def write_to_version_file(filename: str, versions: Dict[str, Any]) -> None: print("set %s to '%s'" % (filename, versions["version"])) -def plus_or_dot(pieces: Dict[str, Any]) -> str: +def plus_or_dot(pieces): """Return a + if we don't already have one, else return a .""" if "+" in pieces.get("closest-tag", ""): return "." return "+" -def render_pep440(pieces: Dict[str, Any]) -> str: +def render_pep440(pieces): """Build up version string, with post-release "local version identifier". Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you @@ -1568,7 +1497,7 @@ def render_pep440(pieces: Dict[str, Any]) -> str: return rendered -def render_pep440_branch(pieces: Dict[str, Any]) -> str: +def render_pep440_branch(pieces): """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] . The ".dev0" means not master branch. Note that .dev0 sorts backwards @@ -1598,7 +1527,7 @@ def render_pep440_branch(pieces: Dict[str, Any]) -> str: return rendered -def pep440_split_post(ver: str) -> Tuple[str, Optional[int]]: +def pep440_split_post(ver): """Split pep440 version string at the post-release segment. Returns the release segments before the post-release and the @@ -1608,7 +1537,7 @@ def pep440_split_post(ver: str) -> Tuple[str, Optional[int]]: return vc[0], int(vc[1] or 0) if len(vc) == 2 else None -def render_pep440_pre(pieces: Dict[str, Any]) -> str: +def render_pep440_pre(pieces): """TAG[.postN.devDISTANCE] -- No -dirty. Exceptions: @@ -1632,7 +1561,7 @@ def render_pep440_pre(pieces: Dict[str, Any]) -> str: return rendered -def render_pep440_post(pieces: Dict[str, Any]) -> str: +def render_pep440_post(pieces): """TAG[.postDISTANCE[.dev0]+gHEX] . The ".dev0" means dirty. Note that .dev0 sorts backwards @@ -1659,7 +1588,7 @@ def render_pep440_post(pieces: Dict[str, Any]) -> str: return rendered -def render_pep440_post_branch(pieces: Dict[str, Any]) -> str: +def render_pep440_post_branch(pieces): """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . The ".dev0" means not master branch. @@ -1688,7 +1617,7 @@ def render_pep440_post_branch(pieces: Dict[str, Any]) -> str: return rendered -def render_pep440_old(pieces: Dict[str, Any]) -> str: +def render_pep440_old(pieces): """TAG[.postDISTANCE[.dev0]] . The ".dev0" means dirty. @@ -1710,7 +1639,7 @@ def render_pep440_old(pieces: Dict[str, Any]) -> str: return rendered -def render_git_describe(pieces: Dict[str, Any]) -> str: +def render_git_describe(pieces): """TAG[-DISTANCE-gHEX][-dirty]. Like 'git describe --tags --dirty --always'. @@ -1730,7 +1659,7 @@ def render_git_describe(pieces: Dict[str, Any]) -> str: return rendered -def render_git_describe_long(pieces: Dict[str, Any]) -> str: +def render_git_describe_long(pieces): """TAG-DISTANCE-gHEX[-dirty]. Like 'git describe --tags --dirty --always -long'. @@ -1750,7 +1679,7 @@ def render_git_describe_long(pieces: Dict[str, Any]) -> str: return rendered -def render(pieces: Dict[str, Any], style: str) -> Dict[str, Any]: +def render(pieces, style): """Render the given version pieces into the requested style.""" if pieces["error"]: return {"version": "unknown", @@ -1790,7 +1719,7 @@ class VersioneerBadRootError(Exception): """The project root directory is unknown or missing key files.""" -def get_versions(verbose: bool = False) -> Dict[str, Any]: +def get_versions(verbose=False): """Get the project version from whatever source is available. Returns dict with two keys: 'version' and 'full'. @@ -1805,7 +1734,7 @@ def get_versions(verbose: bool = False) -> Dict[str, Any]: assert cfg.VCS is not None, "please set [versioneer]VCS= in setup.cfg" handlers = HANDLERS.get(cfg.VCS) assert handlers, "unrecognized VCS '%s'" % cfg.VCS - verbose = verbose or bool(cfg.verbose) # `bool()` used to avoid `None` + verbose = verbose or cfg.verbose assert cfg.versionfile_source is not None, \ "please set versioneer.versionfile_source" assert cfg.tag_prefix is not None, "please set versioneer.tag_prefix" @@ -1866,12 +1795,12 @@ def get_versions(verbose: bool = False) -> Dict[str, Any]: "date": None} -def get_version() -> str: +def get_version(): """Get the short version string for this project.""" return get_versions()["version"] -def get_cmdclass(cmdclass: Optional[Dict[str, Any]] = None): +def get_cmdclass(cmdclass=None): """Get the custom setuptools subclasses used by Versioneer. If the package uses a different cmdclass (e.g. one from numpy), it @@ -1899,16 +1828,16 @@ def get_cmdclass(cmdclass: Optional[Dict[str, Any]] = None): class cmd_version(Command): description = "report generated version string" - user_options: List[Tuple[str, str, str]] = [] - boolean_options: List[str] = [] + user_options = [] + boolean_options = [] - def initialize_options(self) -> None: + def initialize_options(self): pass - def finalize_options(self) -> None: + def finalize_options(self): pass - def run(self) -> None: + def run(self): vers = get_versions(verbose=True) print("Version: %s" % vers["version"]) print(" full-revisionid: %s" % vers.get("full-revisionid")) @@ -1938,12 +1867,12 @@ def run(self) -> None: # we override different "build_py" commands for both environments if 'build_py' in cmds: - _build_py: Any = cmds['build_py'] + _build_py = cmds['build_py'] else: from setuptools.command.build_py import build_py as _build_py class cmd_build_py(_build_py): - def run(self) -> None: + def run(self): root = get_root() cfg = get_config_from_root(root) versions = get_versions() @@ -1962,12 +1891,12 @@ def run(self) -> None: cmds["build_py"] = cmd_build_py if 'build_ext' in cmds: - _build_ext: Any = cmds['build_ext'] + _build_ext = cmds['build_ext'] else: from setuptools.command.build_ext import build_ext as _build_ext class cmd_build_ext(_build_ext): - def run(self) -> None: + def run(self): root = get_root() cfg = get_config_from_root(root) versions = get_versions() @@ -1994,7 +1923,7 @@ def run(self) -> None: cmds["build_ext"] = cmd_build_ext if "cx_Freeze" in sys.modules: # cx_freeze enabled? - from cx_Freeze.dist import build_exe as _build_exe # type: ignore + from cx_Freeze.dist import build_exe as _build_exe # nczeczulin reports that py2exe won't like the pep440-style string # as FILEVERSION, but it can be used for PRODUCTVERSION, e.g. # setup(console=[{ @@ -2003,7 +1932,7 @@ def run(self) -> None: # ... class cmd_build_exe(_build_exe): - def run(self) -> None: + def run(self): root = get_root() cfg = get_config_from_root(root) versions = get_versions() @@ -2027,12 +1956,12 @@ def run(self) -> None: if 'py2exe' in sys.modules: # py2exe enabled? try: - from py2exe.setuptools_buildexe import py2exe as _py2exe # type: ignore + from py2exe.setuptools_buildexe import py2exe as _py2exe except ImportError: - from py2exe.distutils_buildexe import py2exe as _py2exe # type: ignore + from py2exe.distutils_buildexe import py2exe as _py2exe class cmd_py2exe(_py2exe): - def run(self) -> None: + def run(self): root = get_root() cfg = get_config_from_root(root) versions = get_versions() @@ -2055,12 +1984,12 @@ def run(self) -> None: # sdist farms its file list building out to egg_info if 'egg_info' in cmds: - _egg_info: Any = cmds['egg_info'] + _egg_info = cmds['egg_info'] else: from setuptools.command.egg_info import egg_info as _egg_info class cmd_egg_info(_egg_info): - def find_sources(self) -> None: + def find_sources(self): # egg_info.find_sources builds the manifest list and writes it # in one shot super().find_sources() @@ -2092,12 +2021,12 @@ def find_sources(self) -> None: # we override different "sdist" commands for both environments if 'sdist' in cmds: - _sdist: Any = cmds['sdist'] + _sdist = cmds['sdist'] else: from setuptools.command.sdist import sdist as _sdist class cmd_sdist(_sdist): - def run(self) -> None: + def run(self): versions = get_versions() self._versioneer_generated_versions = versions # unless we update this, the command will keep using the old @@ -2105,7 +2034,7 @@ def run(self) -> None: self.distribution.metadata.version = versions["version"] return _sdist.run(self) - def make_release_tree(self, base_dir: str, files: List[str]) -> None: + def make_release_tree(self, base_dir, files): root = get_root() cfg = get_config_from_root(root) _sdist.make_release_tree(self, base_dir, files) @@ -2170,7 +2099,7 @@ def make_release_tree(self, base_dir: str, files: List[str]) -> None: """ -def do_setup() -> int: +def do_setup(): """Do main VCS-independent setup function for installing Versioneer.""" root = get_root() try: @@ -2197,7 +2126,6 @@ def do_setup() -> int: ipy = os.path.join(os.path.dirname(cfg.versionfile_source), "__init__.py") - maybe_ipy: Optional[str] = ipy if os.path.exists(ipy): try: with open(ipy, "r") as f: @@ -2218,16 +2146,16 @@ def do_setup() -> int: print(" %s unmodified" % ipy) else: print(" %s doesn't exist, ok" % ipy) - maybe_ipy = None + ipy = None # Make VCS-specific changes. For git, this means creating/changing # .gitattributes to mark _version.py for export-subst keyword # substitution. - do_vcs_install(cfg.versionfile_source, maybe_ipy) + do_vcs_install(cfg.versionfile_source, ipy) return 0 -def scan_setup_py() -> int: +def scan_setup_py(): """Validate the contents of setup.py against Versioneer's expectations.""" found = set() setters = False @@ -2264,7 +2192,7 @@ def scan_setup_py() -> int: return errors -def setup_command() -> NoReturn: +def setup_command(): """Set up Versioneer and exit with appropriate error code.""" errors = do_setup() errors += scan_setup_py()