Skip to content

Commit

Permalink
Update versioneer to 0.19
Browse files Browse the repository at this point in the history
versioneer 0.18 is incompatible with Python 3.12
  • Loading branch information
guyer committed Feb 22, 2024
1 parent a242c31 commit 85b69f4
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 104 deletions.
71 changes: 35 additions & 36 deletions fipy/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@
# that just contains the computed version number.

# This file is released into the public domain. Generated by
# versioneer-0.18 (https://github.com/warner/python-versioneer)
# versioneer-0.19 (https://github.com/python-versioneer/python-versioneer)

"""Git implementation of _version.py."""
from __future__ import print_function
from __future__ import unicode_literals


from builtins import object
from builtins import range
from builtins import str
import errno
import os
import re
Expand All @@ -36,12 +30,12 @@ def get_keywords():
return keywords


class VersioneerConfig(object):
class VersioneerConfig:
"""Container for Versioneer configuration parameters."""


def get_config():
"""Create, populate and return the `VersioneerConfig()` object."""
"""Create, populate and return the VersioneerConfig() object."""
# these strings are filled in when 'setup.py versioneer' creates
# _version.py
cfg = VersioneerConfig()
Expand All @@ -63,7 +57,7 @@ class NotThisMethod(Exception):


def register_vcs_handler(vcs, method): # decorator
"""Decorator to mark a method as the handler for a particular VCS."""
"""Create decorator to mark a method as the handler of a VCS."""
def decorate(f):
"""Store f in HANDLERS[vcs][method]."""
if vcs not in HANDLERS:
Expand Down Expand Up @@ -99,9 +93,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
if verbose:
print("unable to find command, tried %s" % (commands,))
return None, None
stdout = p.communicate()[0].strip()
if sys.version_info[0] >= 3:
stdout = stdout.decode()
stdout = p.communicate()[0].strip().decode()
if p.returncode != 0:
if verbose:
print("unable to run %s (error)" % dispcmd)
Expand Down Expand Up @@ -171,6 +163,10 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
raise NotThisMethod("no keywords at all, weird")
date = keywords.get("date")
if date is not None:
# Use only the last line. Previous lines may contain GPG signature
# information.
date = date.splitlines()[-1]

# git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant
# datestamp. However we prefer "%ci" (which expands to an "ISO-8601
# -like" string, which we must then edit to make compliant), because
Expand Down Expand Up @@ -221,10 +217,10 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):

@register_vcs_handler("git", "pieces_from_vcs")
def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
"""Get version from `git describe` in the root of the source tree.
"""Get version from 'git describe' in the root of the source tree.
This only gets called if the git-archive `subst` keywords were *not*
expanded, and `_version.py` hasn't already been rewritten with a short
This only gets called if the git-archive 'subst' keywords were *not*
expanded, and _version.py hasn't already been rewritten with a short
version string, meaning we're inside a checked out source tree.
"""
GITS = ["git"]
Expand Down Expand Up @@ -306,6 +302,9 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
# commit date: see ISO-8601 comment in git_versions_from_keywords()
date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"],
cwd=root)[0].strip()
# Use only the last line. Previous lines may contain GPG signature
# information.
date = date.splitlines()[-1]
pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1)

return pieces
Expand All @@ -321,11 +320,11 @@ def plus_or_dot(pieces):
def render_pep440(pieces):
"""Build up version string, with post-release "local version identifier".
Our goal: `TAG[+DISTANCE.gHEX[.dirty]]` . Note that if you
get a tagged build and then dirty it, you'll get `TAG+0.gHEX.dirty`
Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you
get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty
Exceptions:
1: no tags. git_describe was just HEX. `0+untagged.DISTANCE.gHEX[.dirty]`
1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty]
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
Expand All @@ -344,30 +343,30 @@ def render_pep440(pieces):


def render_pep440_pre(pieces):
"""`TAG[.post.devDISTANCE]` -- No `-dirty`.
"""TAG[.post0.devDISTANCE] -- No -dirty.
Exceptions:
1: no tags. `0.post.devDISTANCE`
1: no tags. 0.post0.devDISTANCE
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
if pieces["distance"]:
rendered += ".post.dev%d" % pieces["distance"]
rendered += ".post0.dev%d" % pieces["distance"]
else:
# exception #1
rendered = "0.post.dev%d" % pieces["distance"]
rendered = "0.post0.dev%d" % pieces["distance"]
return rendered


def render_pep440_post(pieces):
"""`TAG[.postDISTANCE[.dev0]+gHEX]` .
"""TAG[.postDISTANCE[.dev0]+gHEX] .
The "`.dev0`" means dirty. Note that `.dev0` sorts backwards
The ".dev0" means dirty. Note that .dev0 sorts backwards
(a dirty tree will appear "older" than the corresponding clean one),
but you shouldn't be releasing software with `-dirty` anyways.
but you shouldn't be releasing software with -dirty anyways.
Exceptions:
1: no tags. `0.postDISTANCE[.dev0]`
1: no tags. 0.postDISTANCE[.dev0]
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
Expand All @@ -387,12 +386,12 @@ def render_pep440_post(pieces):


def render_pep440_old(pieces):
"""`TAG[.postDISTANCE[.dev0]]` .
"""TAG[.postDISTANCE[.dev0]] .
The "`.dev0`" means dirty.
The ".dev0" means dirty.
Exceptions:
1: no tags. `0.postDISTANCE[.dev0]`
1: no tags. 0.postDISTANCE[.dev0]
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
Expand All @@ -409,12 +408,12 @@ def render_pep440_old(pieces):


def render_git_describe(pieces):
"""`TAG[-DISTANCE-gHEX][-dirty]`.
"""TAG[-DISTANCE-gHEX][-dirty].
Like `git describe --tags --dirty --always`.
Like 'git describe --tags --dirty --always'.
Exceptions:
1: no tags. `HEX[-dirty]` (note: no `g` prefix)
1: no tags. HEX[-dirty] (note: no 'g' prefix)
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
Expand All @@ -429,13 +428,13 @@ def render_git_describe(pieces):


def render_git_describe_long(pieces):
"""`TAG-DISTANCE-gHEX[-dirty]`.
"""TAG-DISTANCE-gHEX[-dirty].
Like `git describe --tags --dirty --always -long`.
Like 'git describe --tags --dirty --always -long'.
The distance/hash is unconditional.
Exceptions:
1: no tags. `HEX[-dirty]` (note: no `g` prefix)
1: no tags. HEX[-dirty] (note: no 'g' prefix)
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
Expand Down

0 comments on commit 85b69f4

Please sign in to comment.