update in-tree versioneer
This commit is contained in:
parent
22a2c3a70c
commit
242ec23e2d
25
version.py
25
version.py
|
@ -6,7 +6,7 @@
|
||||||
# that just contains the computed version number.
|
# that just contains the computed version number.
|
||||||
|
|
||||||
# This file is released into the public domain. Generated by
|
# 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."""
|
"""Git implementation of _version.py."""
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ HANDLERS = {}
|
||||||
|
|
||||||
|
|
||||||
def register_vcs_handler(vcs, method): # decorator
|
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):
|
def decorate(f):
|
||||||
"""Store f in HANDLERS[vcs][method]."""
|
"""Store f in HANDLERS[vcs][method]."""
|
||||||
if vcs not in HANDLERS:
|
if vcs not in HANDLERS:
|
||||||
|
@ -93,9 +93,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
|
||||||
if verbose:
|
if verbose:
|
||||||
print("unable to find command, tried %s" % (commands,))
|
print("unable to find command, tried %s" % (commands,))
|
||||||
return None, None
|
return None, None
|
||||||
stdout = p.communicate()[0].strip()
|
stdout = p.communicate()[0].strip().decode()
|
||||||
if sys.version_info[0] >= 3:
|
|
||||||
stdout = stdout.decode()
|
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
if verbose:
|
if verbose:
|
||||||
print("unable to run %s (error)" % dispcmd)
|
print("unable to run %s (error)" % dispcmd)
|
||||||
|
@ -165,6 +163,10 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
|
||||||
raise NotThisMethod("no keywords at all, weird")
|
raise NotThisMethod("no keywords at all, weird")
|
||||||
date = keywords.get("date")
|
date = keywords.get("date")
|
||||||
if date is not None:
|
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
|
# git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant
|
||||||
# datestamp. However we prefer "%ci" (which expands to an "ISO-8601
|
# datestamp. However we prefer "%ci" (which expands to an "ISO-8601
|
||||||
# -like" string, which we must then edit to make compliant), because
|
# -like" string, which we must then edit to make compliant), because
|
||||||
|
@ -300,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()
|
# commit date: see ISO-8601 comment in git_versions_from_keywords()
|
||||||
date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"],
|
date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"],
|
||||||
cwd=root)[0].strip()
|
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)
|
pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1)
|
||||||
|
|
||||||
return pieces
|
return pieces
|
||||||
|
@ -338,18 +343,18 @@ def render_pep440(pieces):
|
||||||
|
|
||||||
|
|
||||||
def render_pep440_pre(pieces):
|
def render_pep440_pre(pieces):
|
||||||
"""TAG[.post.devDISTANCE] -- No -dirty.
|
"""TAG[.post0.devDISTANCE] -- No -dirty.
|
||||||
|
|
||||||
Exceptions:
|
Exceptions:
|
||||||
1: no tags. 0.post.devDISTANCE
|
1: no tags. 0.post0.devDISTANCE
|
||||||
"""
|
"""
|
||||||
if pieces["closest-tag"]:
|
if pieces["closest-tag"]:
|
||||||
rendered = pieces["closest-tag"]
|
rendered = pieces["closest-tag"]
|
||||||
if pieces["distance"]:
|
if pieces["distance"]:
|
||||||
rendered += ".post.dev%d" % pieces["distance"]
|
rendered += ".post0.dev%d" % pieces["distance"]
|
||||||
else:
|
else:
|
||||||
# exception #1
|
# exception #1
|
||||||
rendered = "0.post.dev%d" % pieces["distance"]
|
rendered = "0.post0.dev%d" % pieces["distance"]
|
||||||
return rendered
|
return rendered
|
||||||
|
|
||||||
|
|
||||||
|
@ -385,7 +390,7 @@ def render_pep440_old(pieces):
|
||||||
|
|
||||||
The ".dev0" means dirty.
|
The ".dev0" means dirty.
|
||||||
|
|
||||||
Eexceptions:
|
Exceptions:
|
||||||
1: no tags. 0.postDISTANCE[.dev0]
|
1: no tags. 0.postDISTANCE[.dev0]
|
||||||
"""
|
"""
|
||||||
if pieces["closest-tag"]:
|
if pieces["closest-tag"]:
|
||||||
|
|
167
versioneer.py
167
versioneer.py
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
# Version: 0.18
|
# Version: 0.19
|
||||||
|
|
||||||
"""The Versioneer - like a rocketeer, but for versions.
|
"""The Versioneer - like a rocketeer, but for versions.
|
||||||
|
|
||||||
|
@ -7,16 +7,12 @@ The Versioneer
|
||||||
==============
|
==============
|
||||||
|
|
||||||
* like a rocketeer, but for versions!
|
* like a rocketeer, but for versions!
|
||||||
* https://github.com/warner/python-versioneer
|
* https://github.com/python-versioneer/python-versioneer
|
||||||
* Brian Warner
|
* Brian Warner
|
||||||
* License: Public Domain
|
* License: Public Domain
|
||||||
* Compatible With: python2.6, 2.7, 3.2, 3.3, 3.4, 3.5, 3.6, and pypy
|
* Compatible with: Python 3.6, 3.7, 3.8, 3.9 and pypy3
|
||||||
* [![Latest Version]
|
* [![Latest Version][pypi-image]][pypi-url]
|
||||||
(https://pypip.in/version/versioneer/badge.svg?style=flat)
|
* [![Build Status][travis-image]][travis-url]
|
||||||
](https://pypi.python.org/pypi/versioneer/)
|
|
||||||
* [![Build Status]
|
|
||||||
(https://travis-ci.org/warner/python-versioneer.png?branch=master)
|
|
||||||
](https://travis-ci.org/warner/python-versioneer)
|
|
||||||
|
|
||||||
This is a tool for managing a recorded version number in distutils-based
|
This is a tool for managing a recorded version number in distutils-based
|
||||||
python projects. The goal is to remove the tedious and error-prone "update
|
python projects. The goal is to remove the tedious and error-prone "update
|
||||||
|
@ -27,9 +23,10 @@ system, and maybe making new tarballs.
|
||||||
|
|
||||||
## Quick Install
|
## Quick Install
|
||||||
|
|
||||||
* `pip install versioneer` to somewhere to your $PATH
|
* `pip install versioneer` to somewhere in your $PATH
|
||||||
* add a `[versioneer]` section to your setup.cfg (see below)
|
* add a `[versioneer]` section to your setup.cfg (see [Install](INSTALL.md))
|
||||||
* run `versioneer install` in your source tree, commit the results
|
* run `versioneer install` in your source tree, commit the results
|
||||||
|
* Verify version information with `python setup.py version`
|
||||||
|
|
||||||
## Version Identifiers
|
## Version Identifiers
|
||||||
|
|
||||||
|
@ -61,7 +58,7 @@ version 1.3). Many VCS systems can report a description that captures this,
|
||||||
for example `git describe --tags --dirty --always` reports things like
|
for example `git describe --tags --dirty --always` reports things like
|
||||||
"0.7-1-g574ab98-dirty" to indicate that the checkout is one revision past the
|
"0.7-1-g574ab98-dirty" to indicate that the checkout is one revision past the
|
||||||
0.7 tag, has a unique revision id of "574ab98", and is "dirty" (it has
|
0.7 tag, has a unique revision id of "574ab98", and is "dirty" (it has
|
||||||
uncommitted changes.
|
uncommitted changes).
|
||||||
|
|
||||||
The version identifier is used for multiple purposes:
|
The version identifier is used for multiple purposes:
|
||||||
|
|
||||||
|
@ -166,7 +163,7 @@ which may help identify what went wrong).
|
||||||
|
|
||||||
Some situations are known to cause problems for Versioneer. This details the
|
Some situations are known to cause problems for Versioneer. This details the
|
||||||
most significant ones. More can be found on Github
|
most significant ones. More can be found on Github
|
||||||
[issues page](https://github.com/warner/python-versioneer/issues).
|
[issues page](https://github.com/python-versioneer/python-versioneer/issues).
|
||||||
|
|
||||||
### Subprojects
|
### Subprojects
|
||||||
|
|
||||||
|
@ -180,7 +177,7 @@ two common reasons why `setup.py` might not be in the root:
|
||||||
`setup.cfg`, and `tox.ini`. Projects like these produce multiple PyPI
|
`setup.cfg`, and `tox.ini`. Projects like these produce multiple PyPI
|
||||||
distributions (and upload multiple independently-installable tarballs).
|
distributions (and upload multiple independently-installable tarballs).
|
||||||
* Source trees whose main purpose is to contain a C library, but which also
|
* Source trees whose main purpose is to contain a C library, but which also
|
||||||
provide bindings to Python (and perhaps other langauges) in subdirectories.
|
provide bindings to Python (and perhaps other languages) in subdirectories.
|
||||||
|
|
||||||
Versioneer will look for `.git` in parent directories, and most operations
|
Versioneer will look for `.git` in parent directories, and most operations
|
||||||
should get the right version string. However `pip` and `setuptools` have bugs
|
should get the right version string. However `pip` and `setuptools` have bugs
|
||||||
|
@ -194,9 +191,9 @@ work too.
|
||||||
Pip-8.1.1 is known to have this problem, but hopefully it will get fixed in
|
Pip-8.1.1 is known to have this problem, but hopefully it will get fixed in
|
||||||
some later version.
|
some later version.
|
||||||
|
|
||||||
[Bug #38](https://github.com/warner/python-versioneer/issues/38) is tracking
|
[Bug #38](https://github.com/python-versioneer/python-versioneer/issues/38) is tracking
|
||||||
this issue. The discussion in
|
this issue. The discussion in
|
||||||
[PR #61](https://github.com/warner/python-versioneer/pull/61) describes the
|
[PR #61](https://github.com/python-versioneer/python-versioneer/pull/61) describes the
|
||||||
issue from the Versioneer side in more detail.
|
issue from the Versioneer side in more detail.
|
||||||
[pip PR#3176](https://github.com/pypa/pip/pull/3176) and
|
[pip PR#3176](https://github.com/pypa/pip/pull/3176) and
|
||||||
[pip PR#3615](https://github.com/pypa/pip/pull/3615) contain work to improve
|
[pip PR#3615](https://github.com/pypa/pip/pull/3615) contain work to improve
|
||||||
|
@ -224,22 +221,10 @@ regenerated while a different version is checked out. Many setup.py commands
|
||||||
cause egg_info to be rebuilt (including `sdist`, `wheel`, and installing into
|
cause egg_info to be rebuilt (including `sdist`, `wheel`, and installing into
|
||||||
a different virtualenv), so this can be surprising.
|
a different virtualenv), so this can be surprising.
|
||||||
|
|
||||||
[Bug #83](https://github.com/warner/python-versioneer/issues/83) describes
|
[Bug #83](https://github.com/python-versioneer/python-versioneer/issues/83) describes
|
||||||
this one, but upgrading to a newer version of setuptools should probably
|
this one, but upgrading to a newer version of setuptools should probably
|
||||||
resolve it.
|
resolve it.
|
||||||
|
|
||||||
### Unicode version strings
|
|
||||||
|
|
||||||
While Versioneer works (and is continually tested) with both Python 2 and
|
|
||||||
Python 3, it is not entirely consistent with bytes-vs-unicode distinctions.
|
|
||||||
Newer releases probably generate unicode version strings on py2. It's not
|
|
||||||
clear that this is wrong, but it may be surprising for applications when then
|
|
||||||
write these strings to a network connection or include them in bytes-oriented
|
|
||||||
APIs like cryptographic checksums.
|
|
||||||
|
|
||||||
[Bug #71](https://github.com/warner/python-versioneer/issues/71) investigates
|
|
||||||
this question.
|
|
||||||
|
|
||||||
|
|
||||||
## Updating Versioneer
|
## Updating Versioneer
|
||||||
|
|
||||||
|
@ -265,6 +250,12 @@ installation by editing setup.py . Alternatively, it might go the other
|
||||||
direction and include code from all supported VCS systems, reducing the
|
direction and include code from all supported VCS systems, reducing the
|
||||||
number of intermediate scripts.
|
number of intermediate scripts.
|
||||||
|
|
||||||
|
## Similar projects
|
||||||
|
|
||||||
|
* [setuptools_scm](https://github.com/pypa/setuptools_scm/) - a non-vendored build-time
|
||||||
|
dependency
|
||||||
|
* [minver](https://github.com/jbweston/miniver) - a lightweight reimplementation of
|
||||||
|
versioneer
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
@ -274,13 +265,15 @@ Specifically, both are released under the Creative Commons "Public Domain
|
||||||
Dedication" license (CC0-1.0), as described in
|
Dedication" license (CC0-1.0), as described in
|
||||||
https://creativecommons.org/publicdomain/zero/1.0/ .
|
https://creativecommons.org/publicdomain/zero/1.0/ .
|
||||||
|
|
||||||
|
[pypi-image]: https://img.shields.io/pypi/v/versioneer.svg
|
||||||
|
[pypi-url]: https://pypi.python.org/pypi/versioneer/
|
||||||
|
[travis-image]:
|
||||||
|
https://img.shields.io/travis/com/python-versioneer/python-versioneer.svg
|
||||||
|
[travis-url]: https://travis-ci.com/github/python-versioneer/python-versioneer
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
try:
|
|
||||||
import configparser
|
import configparser
|
||||||
except ImportError:
|
|
||||||
import ConfigParser as configparser
|
|
||||||
import errno
|
import errno
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
@ -339,9 +332,9 @@ def get_config_from_root(root):
|
||||||
# configparser.NoOptionError (if it lacks "VCS="). See the docstring at
|
# configparser.NoOptionError (if it lacks "VCS="). See the docstring at
|
||||||
# the top of versioneer.py for instructions on writing your setup.cfg .
|
# the top of versioneer.py for instructions on writing your setup.cfg .
|
||||||
setup_cfg = os.path.join(root, "setup.cfg")
|
setup_cfg = os.path.join(root, "setup.cfg")
|
||||||
parser = configparser.SafeConfigParser()
|
parser = configparser.ConfigParser()
|
||||||
with open(setup_cfg, "r") as f:
|
with open(setup_cfg, "r") as f:
|
||||||
parser.readfp(f)
|
parser.read_file(f)
|
||||||
VCS = parser.get("versioneer", "VCS") # mandatory
|
VCS = parser.get("versioneer", "VCS") # mandatory
|
||||||
|
|
||||||
def get(parser, name):
|
def get(parser, name):
|
||||||
|
@ -371,7 +364,7 @@ HANDLERS = {}
|
||||||
|
|
||||||
|
|
||||||
def register_vcs_handler(vcs, method): # decorator
|
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):
|
def decorate(f):
|
||||||
"""Store f in HANDLERS[vcs][method]."""
|
"""Store f in HANDLERS[vcs][method]."""
|
||||||
if vcs not in HANDLERS:
|
if vcs not in HANDLERS:
|
||||||
|
@ -407,9 +400,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
|
||||||
if verbose:
|
if verbose:
|
||||||
print("unable to find command, tried %s" % (commands,))
|
print("unable to find command, tried %s" % (commands,))
|
||||||
return None, None
|
return None, None
|
||||||
stdout = p.communicate()[0].strip()
|
stdout = p.communicate()[0].strip().decode()
|
||||||
if sys.version_info[0] >= 3:
|
|
||||||
stdout = stdout.decode()
|
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
if verbose:
|
if verbose:
|
||||||
print("unable to run %s (error)" % dispcmd)
|
print("unable to run %s (error)" % dispcmd)
|
||||||
|
@ -418,7 +409,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
|
||||||
return stdout, p.returncode
|
return stdout, p.returncode
|
||||||
|
|
||||||
|
|
||||||
LONG_VERSION_PY['git'] = '''
|
LONG_VERSION_PY['git'] = r'''
|
||||||
# This file helps to compute a version number in source trees obtained from
|
# This file helps to compute a version number in source trees obtained from
|
||||||
# git-archive tarball (such as those provided by githubs download-from-tag
|
# git-archive tarball (such as those provided by githubs download-from-tag
|
||||||
# feature). Distribution tarballs (built by setup.py sdist) and build
|
# feature). Distribution tarballs (built by setup.py sdist) and build
|
||||||
|
@ -426,7 +417,7 @@ LONG_VERSION_PY['git'] = '''
|
||||||
# that just contains the computed version number.
|
# that just contains the computed version number.
|
||||||
|
|
||||||
# This file is released into the public domain. Generated by
|
# 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."""
|
"""Git implementation of _version.py."""
|
||||||
|
|
||||||
|
@ -477,7 +468,7 @@ HANDLERS = {}
|
||||||
|
|
||||||
|
|
||||||
def register_vcs_handler(vcs, method): # decorator
|
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):
|
def decorate(f):
|
||||||
"""Store f in HANDLERS[vcs][method]."""
|
"""Store f in HANDLERS[vcs][method]."""
|
||||||
if vcs not in HANDLERS:
|
if vcs not in HANDLERS:
|
||||||
|
@ -513,9 +504,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
|
||||||
if verbose:
|
if verbose:
|
||||||
print("unable to find command, tried %%s" %% (commands,))
|
print("unable to find command, tried %%s" %% (commands,))
|
||||||
return None, None
|
return None, None
|
||||||
stdout = p.communicate()[0].strip()
|
stdout = p.communicate()[0].strip().decode()
|
||||||
if sys.version_info[0] >= 3:
|
|
||||||
stdout = stdout.decode()
|
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
if verbose:
|
if verbose:
|
||||||
print("unable to run %%s (error)" %% dispcmd)
|
print("unable to run %%s (error)" %% dispcmd)
|
||||||
|
@ -585,6 +574,10 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
|
||||||
raise NotThisMethod("no keywords at all, weird")
|
raise NotThisMethod("no keywords at all, weird")
|
||||||
date = keywords.get("date")
|
date = keywords.get("date")
|
||||||
if date is not None:
|
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
|
# git-2.2.0 added "%%cI", which expands to an ISO-8601 -compliant
|
||||||
# datestamp. However we prefer "%%ci" (which expands to an "ISO-8601
|
# datestamp. However we prefer "%%ci" (which expands to an "ISO-8601
|
||||||
# -like" string, which we must then edit to make compliant), because
|
# -like" string, which we must then edit to make compliant), because
|
||||||
|
@ -720,6 +713,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()
|
# commit date: see ISO-8601 comment in git_versions_from_keywords()
|
||||||
date = run_command(GITS, ["show", "-s", "--format=%%ci", "HEAD"],
|
date = run_command(GITS, ["show", "-s", "--format=%%ci", "HEAD"],
|
||||||
cwd=root)[0].strip()
|
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)
|
pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1)
|
||||||
|
|
||||||
return pieces
|
return pieces
|
||||||
|
@ -758,18 +754,18 @@ def render_pep440(pieces):
|
||||||
|
|
||||||
|
|
||||||
def render_pep440_pre(pieces):
|
def render_pep440_pre(pieces):
|
||||||
"""TAG[.post.devDISTANCE] -- No -dirty.
|
"""TAG[.post0.devDISTANCE] -- No -dirty.
|
||||||
|
|
||||||
Exceptions:
|
Exceptions:
|
||||||
1: no tags. 0.post.devDISTANCE
|
1: no tags. 0.post0.devDISTANCE
|
||||||
"""
|
"""
|
||||||
if pieces["closest-tag"]:
|
if pieces["closest-tag"]:
|
||||||
rendered = pieces["closest-tag"]
|
rendered = pieces["closest-tag"]
|
||||||
if pieces["distance"]:
|
if pieces["distance"]:
|
||||||
rendered += ".post.dev%%d" %% pieces["distance"]
|
rendered += ".post0.dev%%d" %% pieces["distance"]
|
||||||
else:
|
else:
|
||||||
# exception #1
|
# exception #1
|
||||||
rendered = "0.post.dev%%d" %% pieces["distance"]
|
rendered = "0.post0.dev%%d" %% pieces["distance"]
|
||||||
return rendered
|
return rendered
|
||||||
|
|
||||||
|
|
||||||
|
@ -805,7 +801,7 @@ def render_pep440_old(pieces):
|
||||||
|
|
||||||
The ".dev0" means dirty.
|
The ".dev0" means dirty.
|
||||||
|
|
||||||
Eexceptions:
|
Exceptions:
|
||||||
1: no tags. 0.postDISTANCE[.dev0]
|
1: no tags. 0.postDISTANCE[.dev0]
|
||||||
"""
|
"""
|
||||||
if pieces["closest-tag"]:
|
if pieces["closest-tag"]:
|
||||||
|
@ -977,6 +973,10 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
|
||||||
raise NotThisMethod("no keywords at all, weird")
|
raise NotThisMethod("no keywords at all, weird")
|
||||||
date = keywords.get("date")
|
date = keywords.get("date")
|
||||||
if date is not None:
|
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
|
# git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant
|
||||||
# datestamp. However we prefer "%ci" (which expands to an "ISO-8601
|
# datestamp. However we prefer "%ci" (which expands to an "ISO-8601
|
||||||
# -like" string, which we must then edit to make compliant), because
|
# -like" string, which we must then edit to make compliant), because
|
||||||
|
@ -1112,6 +1112,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()
|
# commit date: see ISO-8601 comment in git_versions_from_keywords()
|
||||||
date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"],
|
date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"],
|
||||||
cwd=root)[0].strip()
|
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)
|
pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1)
|
||||||
|
|
||||||
return pieces
|
return pieces
|
||||||
|
@ -1181,7 +1184,7 @@ def versions_from_parentdir(parentdir_prefix, root, verbose):
|
||||||
|
|
||||||
|
|
||||||
SHORT_VERSION_PY = """
|
SHORT_VERSION_PY = """
|
||||||
# This file was generated by 'versioneer.py' (0.18) from
|
# This file was generated by 'versioneer.py' (0.19) from
|
||||||
# revision-control system data, or from the parent directory name of an
|
# revision-control system data, or from the parent directory name of an
|
||||||
# unpacked source archive. Distribution tarballs contain a pre-generated copy
|
# unpacked source archive. Distribution tarballs contain a pre-generated copy
|
||||||
# of this file.
|
# of this file.
|
||||||
|
@ -1259,18 +1262,18 @@ def render_pep440(pieces):
|
||||||
|
|
||||||
|
|
||||||
def render_pep440_pre(pieces):
|
def render_pep440_pre(pieces):
|
||||||
"""TAG[.post.devDISTANCE] -- No -dirty.
|
"""TAG[.post0.devDISTANCE] -- No -dirty.
|
||||||
|
|
||||||
Exceptions:
|
Exceptions:
|
||||||
1: no tags. 0.post.devDISTANCE
|
1: no tags. 0.post0.devDISTANCE
|
||||||
"""
|
"""
|
||||||
if pieces["closest-tag"]:
|
if pieces["closest-tag"]:
|
||||||
rendered = pieces["closest-tag"]
|
rendered = pieces["closest-tag"]
|
||||||
if pieces["distance"]:
|
if pieces["distance"]:
|
||||||
rendered += ".post.dev%d" % pieces["distance"]
|
rendered += ".post0.dev%d" % pieces["distance"]
|
||||||
else:
|
else:
|
||||||
# exception #1
|
# exception #1
|
||||||
rendered = "0.post.dev%d" % pieces["distance"]
|
rendered = "0.post0.dev%d" % pieces["distance"]
|
||||||
return rendered
|
return rendered
|
||||||
|
|
||||||
|
|
||||||
|
@ -1306,7 +1309,7 @@ def render_pep440_old(pieces):
|
||||||
|
|
||||||
The ".dev0" means dirty.
|
The ".dev0" means dirty.
|
||||||
|
|
||||||
Eexceptions:
|
Exceptions:
|
||||||
1: no tags. 0.postDISTANCE[.dev0]
|
1: no tags. 0.postDISTANCE[.dev0]
|
||||||
"""
|
"""
|
||||||
if pieces["closest-tag"]:
|
if pieces["closest-tag"]:
|
||||||
|
@ -1480,8 +1483,12 @@ def get_version():
|
||||||
return get_versions()["version"]
|
return get_versions()["version"]
|
||||||
|
|
||||||
|
|
||||||
def get_cmdclass():
|
def get_cmdclass(cmdclass=None):
|
||||||
"""Get the custom setuptools/distutils subclasses used by Versioneer."""
|
"""Get the custom setuptools/distutils subclasses used by Versioneer.
|
||||||
|
|
||||||
|
If the package uses a different cmdclass (e.g. one from numpy), it
|
||||||
|
should be provide as an argument.
|
||||||
|
"""
|
||||||
if "versioneer" in sys.modules:
|
if "versioneer" in sys.modules:
|
||||||
del sys.modules["versioneer"]
|
del sys.modules["versioneer"]
|
||||||
# this fixes the "python setup.py develop" case (also 'install' and
|
# this fixes the "python setup.py develop" case (also 'install' and
|
||||||
|
@ -1495,9 +1502,9 @@ def get_cmdclass():
|
||||||
# parent is protected against the child's "import versioneer". By
|
# parent is protected against the child's "import versioneer". By
|
||||||
# removing ourselves from sys.modules here, before the child build
|
# removing ourselves from sys.modules here, before the child build
|
||||||
# happens, we protect the child from the parent's versioneer too.
|
# happens, we protect the child from the parent's versioneer too.
|
||||||
# Also see https://github.com/warner/python-versioneer/issues/52
|
# Also see https://github.com/python-versioneer/python-versioneer/issues/52
|
||||||
|
|
||||||
cmds = {}
|
cmds = {} if cmdclass is None else cmdclass.copy()
|
||||||
|
|
||||||
# we add "version" to both distutils and setuptools
|
# we add "version" to both distutils and setuptools
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
|
@ -1539,7 +1546,9 @@ def get_cmdclass():
|
||||||
# setup.py egg_info -> ?
|
# setup.py egg_info -> ?
|
||||||
|
|
||||||
# we override different "build_py" commands for both environments
|
# we override different "build_py" commands for both environments
|
||||||
if "setuptools" in sys.modules:
|
if 'build_py' in cmds:
|
||||||
|
_build_py = cmds['build_py']
|
||||||
|
elif "setuptools" in sys.modules:
|
||||||
from setuptools.command.build_py import build_py as _build_py
|
from setuptools.command.build_py import build_py as _build_py
|
||||||
else:
|
else:
|
||||||
from distutils.command.build_py import build_py as _build_py
|
from distutils.command.build_py import build_py as _build_py
|
||||||
|
@ -1559,6 +1568,31 @@ def get_cmdclass():
|
||||||
write_to_version_file(target_versionfile, versions)
|
write_to_version_file(target_versionfile, versions)
|
||||||
cmds["build_py"] = cmd_build_py
|
cmds["build_py"] = cmd_build_py
|
||||||
|
|
||||||
|
if "setuptools" in sys.modules:
|
||||||
|
from setuptools.command.build_ext import build_ext as _build_ext
|
||||||
|
else:
|
||||||
|
from distutils.command.build_ext import build_ext as _build_ext
|
||||||
|
|
||||||
|
class cmd_build_ext(_build_ext):
|
||||||
|
def run(self):
|
||||||
|
root = get_root()
|
||||||
|
cfg = get_config_from_root(root)
|
||||||
|
versions = get_versions()
|
||||||
|
_build_ext.run(self)
|
||||||
|
if self.inplace:
|
||||||
|
# build_ext --inplace will only build extensions in
|
||||||
|
# build/lib<..> dir with no _version.py to write to.
|
||||||
|
# As in place builds will already have a _version.py
|
||||||
|
# in the module dir, we do not need to write one.
|
||||||
|
return
|
||||||
|
# now locate _version.py in the new build/ directory and replace
|
||||||
|
# it with an updated value
|
||||||
|
target_versionfile = os.path.join(self.build_lib,
|
||||||
|
cfg.versionfile_source)
|
||||||
|
print("UPDATING %s" % target_versionfile)
|
||||||
|
write_to_version_file(target_versionfile, versions)
|
||||||
|
cmds["build_ext"] = cmd_build_ext
|
||||||
|
|
||||||
if "cx_Freeze" in sys.modules: # cx_freeze enabled?
|
if "cx_Freeze" in sys.modules: # cx_freeze enabled?
|
||||||
from cx_Freeze.dist import build_exe as _build_exe
|
from cx_Freeze.dist import build_exe as _build_exe
|
||||||
# nczeczulin reports that py2exe won't like the pep440-style string
|
# nczeczulin reports that py2exe won't like the pep440-style string
|
||||||
|
@ -1592,10 +1626,7 @@ def get_cmdclass():
|
||||||
del cmds["build_py"]
|
del cmds["build_py"]
|
||||||
|
|
||||||
if 'py2exe' in sys.modules: # py2exe enabled?
|
if 'py2exe' in sys.modules: # py2exe enabled?
|
||||||
try:
|
from py2exe.distutils_buildexe import py2exe as _py2exe
|
||||||
from py2exe.distutils_buildexe import py2exe as _py2exe # py3
|
|
||||||
except ImportError:
|
|
||||||
from py2exe.build_exe import py2exe as _py2exe # py2
|
|
||||||
|
|
||||||
class cmd_py2exe(_py2exe):
|
class cmd_py2exe(_py2exe):
|
||||||
def run(self):
|
def run(self):
|
||||||
|
@ -1620,7 +1651,9 @@ def get_cmdclass():
|
||||||
cmds["py2exe"] = cmd_py2exe
|
cmds["py2exe"] = cmd_py2exe
|
||||||
|
|
||||||
# we override different "sdist" commands for both environments
|
# we override different "sdist" commands for both environments
|
||||||
if "setuptools" in sys.modules:
|
if 'sdist' in cmds:
|
||||||
|
_sdist = cmds['sdist']
|
||||||
|
elif "setuptools" in sys.modules:
|
||||||
from setuptools.command.sdist import sdist as _sdist
|
from setuptools.command.sdist import sdist as _sdist
|
||||||
else:
|
else:
|
||||||
from distutils.command.sdist import sdist as _sdist
|
from distutils.command.sdist import sdist as _sdist
|
||||||
|
@ -1695,7 +1728,7 @@ del get_versions
|
||||||
|
|
||||||
|
|
||||||
def do_setup():
|
def do_setup():
|
||||||
"""Main VCS-independent setup function for installing Versioneer."""
|
"""Do main VCS-independent setup function for installing Versioneer."""
|
||||||
root = get_root()
|
root = get_root()
|
||||||
try:
|
try:
|
||||||
cfg = get_config_from_root(root)
|
cfg = get_config_from_root(root)
|
||||||
|
|
Loading…
Reference in New Issue