8000 added pep440 compliance option by sebastianneubauer · Pull Request #45 · python-versioneer/python-versioneer · GitHub
[go: up one dir, main page]

Skip to content

added pep440 compliance option #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ The Versioneer
* Brian Warner
* License: Public Domain
* Compatible With: python2.6, 2.7, 3.2, 3.3, 3.4, and pypy

[![Build Status](https://travis-ci.org/warner/python-versioneer.png?branch=master)](https://travis-ci.org/warner/python-versioneer)
* [![Latest Version](https://pypip.in/version/versioneer/badge.svg?style=flat)](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
python projects. The goal is to remove the tedious and error-prone "update
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""

# as nice as it'd be to versioneer ourselves, that sounds messy.
VERSION = "0.12+"
VERSION = "0.13"


def ver(s):
Expand Down
36 changes: 32 additions & 4 deletions src/get_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,55 @@ def get_versions(default=DEFAULT, verbose=False):
ver = versions_from_keywords_f(vcs_keywords, tag_prefix)
if ver:
if verbose: print("got version from expanded keyword %s" % ver)
return ver
if not pep440_compliant:
return ver
else:
return rep_by_pep440(ver)

ver = versions_from_file(versionfile_abs)
if ver:
if verbose: print("got version from file %s %s" % (versionfile_abs,ver))
return ver
if not pep440_compliant:
return ver
else:
return rep_by_pep440(ver)

versions_from_vcs_f = vcs_function(VCS, "versions_from_vcs")
if versions_from_vcs_f:
ver = versions_from_vcs_f(tag_prefix, root, verbose)
if ver:
if verbose: print("got version from VCS %s" % ver)
return ver
if not pep440_compliant:
return ver
else:
return rep_by_pep440(ver)

ver = versions_from_parentdir(parentdir_prefix, root, verbose)
if ver:
if verbose: print("got version from parentdir %s" % ver)
return ver
if not pep440_compliant:
return ver
else:
return rep_by_pep440(ver)

if verbose: print("got version from default %s" % default)
return default

def get_version(verbose=False):
return get_versions(verbose=verbose)["version"]


def git2pep440(ver_str):
try:
tag, commits, local = ver_str.split('-', 2)
if local_version:
return "{}.{}{}+{}".format(tag, release_type_string, commits, local)
else:
return "{}.{}{}".format(tag, release_type_string, commits)
except ValueError:
return ver_str


def rep_by_pep440(ver):
ver["version"] = git2pep440(ver["version"])
return ver
6 changes: 3 additions & 3 deletions src/git/long_get_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def get_versions(default={"version": "unknown", "full": ""}, verbose=False):
keywords = {"refnames": git_refnames, "full": git_full}
ver = git_versions_from_keywords(keywords, tag_prefix, verbose)
if ver:
return ver
return rep_by_pep440(ver)

try:
root = os.path.abspath(__file__)
root = os.path.realpath(__file__)
# versionfile_source is the relative path from the top of the source
# tree (where the .git directory might live) to this file. Invert
# this to find the root from __file__.
Expand All @@ -20,6 +20,6 @@ def get_versions(default={"version": "unknown", "full": ""}, verbose=False):
except NameError:
return default

return (git_versions_from_vcs(tag_prefix, root, verbose)
return rep_by_pep440(git_versions_from_vcs(tag_prefix, root, verbose)
or versions_from_parentdir(parentdir_prefix, root, verbose)
or default)
4 changes: 3 additions & 1 deletion src/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
tag_prefix = None
parentdir_prefix = None
VCS = None

pep440_compliant = True
release_type_string = "post.dev"
local_version = True
# these dictionaries contain VCS-specific tools
LONG_VERSION_PY = {}
4 changes: 2 additions & 2 deletions test/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_no_prefix(self):
self.assertEqual(v["version"], "full")
self.assertEqual(v["full"], "full")

VERBOSE = False
VERBOSE = True

class Repo(unittest.TestCase):
def git(self, *args, **kwargs):
Expand Down Expand Up @@ -201,7 +201,7 @@ def run_test(self, demoapp_dir, script_only):
self.git("add", "setup.py")
self.git("commit", "-m", "dirty")
full = self.git("rev-parse", "HEAD")
short = "1.0-1-g%s" % full[:7]
short = "1.0.post.dev1+g%s" % full[:7]
self.do_checks(short, full, dirty=False, state="SC")


Expand Down
0