diff -Nru setuptools-scm-1.15.0/appveyor.yml setuptools-scm-1.15.6/appveyor.yml --- setuptools-scm-1.15.0/appveyor.yml 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/appveyor.yml 2017-06-15 19:24:23.000000000 +0000 @@ -1,22 +1,22 @@ environment: matrix: - PYTHON: "C:\\Python27" - TOX_ENV: "py27" + TOX_ENV: "py-test" - PYTHON: "C:\\Python27-x64" - TOX_ENV: "py27" + TOX_ENV: "py-test" - PYTHON: "C:\\Python33" - TOX_ENV: "py33" + TOX_ENV: "py-test" - PYTHON: "C:\\Python33-x64" - TOX_ENV: "py33" + TOX_ENV: "py-test" - PYTHON: "C:\\Python34" - TOX_ENV: "py34" + TOX_ENV: "py-test" - PYTHON: "C:\\Python34-x64" - TOX_ENV: "py34" + TOX_ENV: "py-test" init: - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" diff -Nru setuptools-scm-1.15.0/CHANGELOG.rst setuptools-scm-1.15.6/CHANGELOG.rst --- setuptools-scm-1.15.0/CHANGELOG.rst 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/CHANGELOG.rst 2017-06-15 19:24:23.000000000 +0000 @@ -1,3 +1,42 @@ + +v1.15.6 +======= + +* fix #171 by unpinning the py version to allow a fixed one to get installed + +v1.15.5 +======= + +* fix #167 by correctly respecting preformatted version metadata + from PKG-INFO/EGG-INFO + +v1.15.4 +======= + +* fix issue #164: iterate all found entry points to avoid erros when pip remakes egg-info +* enhance self-use to enable pip install from github again + +v1.15.3 +======= + +* bring back correctly getting our version in the own sdist, finalizes #114 +* fix issue #150: strip local components of tags + +v1.15.2 +======= + +* fix issue #128: return None when a scm specific parse fails in a worktree to ease parse reuse + + +v1.15.1 +======= + +* fix issue #126: the local part of any tags is discarded + when guessing new versions +* minor performance optimization by doing fewer git calls + in the usual cases + + v1.15.0 ======= diff -Nru setuptools-scm-1.15.0/debian/changelog setuptools-scm-1.15.6/debian/changelog --- setuptools-scm-1.15.0/debian/changelog 2016-10-21 04:57:11.000000000 +0000 +++ setuptools-scm-1.15.6/debian/changelog 2017-06-29 05:05:20.000000000 +0000 @@ -1,3 +1,16 @@ +setuptools-scm (1.15.6-1) unstable; urgency=medium + + * New upstream release. + * Bump standards-version to 4.0.0. + + -- Julien Puydt Thu, 29 Jun 2017 07:05:20 +0200 + +setuptools-scm (1.15.0-2) unstable; urgency=medium + + * Add pypy-setuptools-scm package. Closes: #864687. + + -- Brian May Sat, 24 Jun 2017 19:37:30 +1000 + setuptools-scm (1.15.0-1) unstable; urgency=medium * New upstream release. diff -Nru setuptools-scm-1.15.0/debian/control setuptools-scm-1.15.6/debian/control --- setuptools-scm-1.15.0/debian/control 2016-10-11 13:23:10.000000000 +0000 +++ setuptools-scm-1.15.6/debian/control 2017-06-29 05:05:20.000000000 +0000 @@ -3,12 +3,14 @@ Uploaders: Julien Puydt Section: python Priority: optional -Standards-Version: 3.9.8 +Standards-Version: 4.0.0 Homepage: https://github.com/pypa/setuptools_scm -Build-Depends: debhelper (>= 10), dh-python, python, python3-all, - python-setuptools (>= 18.8-1~), python3-setuptools (>=12.2), - python-py, python3-py, python-pytest, python3-pytest, - git, mercurial, subversion +Build-Depends: debhelper (>= 10), dh-python, + python, python3-all, pypy, + python-setuptools (>= 18.8-1~), python3-setuptools (>=12.2), pypy-setuptools, + python-py, python3-py, pypy-py, + python-pytest, python3-pytest, pypy-pytest, + git, mercurial, subversion, X-Python-Version: >= 2.7 X-Python3-Version: >= 3.2 Vcs-Git: https://anonscm.debian.org/git/python-modules/packages/setuptools-scm.git @@ -31,3 +33,12 @@ It also handles file finders for the suppertes scm's. . This package installs the library for Python 3. + +Package: pypy-setuptools-scm +Architecture: all +Depends: ${misc:Depends}, ${python:Depends} +Description: blessed package to manage your versions by scm tags for PyPy + setuptools_scm handles managing your Python package versions in scm metadata. + It also handles file finders for the suppertes scm's. + . + This package installs the library for PyPy. diff -Nru setuptools-scm-1.15.0/debian/.git-dpm setuptools-scm-1.15.6/debian/.git-dpm --- setuptools-scm-1.15.0/debian/.git-dpm 2016-10-21 04:57:11.000000000 +0000 +++ setuptools-scm-1.15.6/debian/.git-dpm 2017-06-29 05:05:20.000000000 +0000 @@ -1,11 +1,11 @@ # see git-dpm(1) from git-dpm package -b907405afea877f62007f909fa13c2291c1b723f -b907405afea877f62007f909fa13c2291c1b723f -b907405afea877f62007f909fa13c2291c1b723f -b907405afea877f62007f909fa13c2291c1b723f -setuptools-scm_1.15.0.orig.tar.gz -273bb9fbc27d169cb9853b379db8f749ea7caede -23677 +df91001294782a6e1f1262b29b1b0c944abe6fa6 +df91001294782a6e1f1262b29b1b0c944abe6fa6 +df91001294782a6e1f1262b29b1b0c944abe6fa6 +df91001294782a6e1f1262b29b1b0c944abe6fa6 +setuptools-scm_1.15.6.orig.tar.gz +cce778e7e9aa2c2f2bc96ae621f671e6d21b019d +25779 debianTag="debian/%e%v" patchedTag="patched/%e%v" upstreamTag="upstream/%e%u" diff -Nru setuptools-scm-1.15.0/debian/rules setuptools-scm-1.15.6/debian/rules --- setuptools-scm-1.15.0/debian/rules 2016-06-13 11:59:12.000000000 +0000 +++ setuptools-scm-1.15.6/debian/rules 2017-06-24 09:12:26.000000000 +0000 @@ -6,7 +6,7 @@ export PYBUILD_TEST_ARGS={interpreter} -m pytest -k "not regressions" %: - dh $@ --with python2,python3 --buildsystem=pybuild + dh $@ --with python2,python3,pypy --buildsystem=pybuild override_dh_auto_test: python setup.py egg_info diff -Nru setuptools-scm-1.15.0/debian/watch setuptools-scm-1.15.6/debian/watch --- setuptools-scm-1.15.0/debian/watch 2016-06-13 11:59:12.000000000 +0000 +++ setuptools-scm-1.15.6/debian/watch 2017-06-24 09:09:12.000000000 +0000 @@ -1,3 +1,3 @@ version=3 opts=uversionmangle=s/(rc|a|b|c)/~$1/ \ -https://pypi.debian.net/setuptools_scm/setuptools_scm-(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz))) +https://pypi.python.org/pypi/setuptools_scm .*/setuptools_scm-(.+)\.tar\.gz#md5=.* diff -Nru setuptools-scm-1.15.0/default.nix setuptools-scm-1.15.6/default.nix --- setuptools-scm-1.15.0/default.nix 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/default.nix 2017-06-15 19:24:23.000000000 +0000 @@ -4,6 +4,12 @@ name = "setuptools_scm"; src = ./.; version = "git"; - buildInputs = [setuptools pip pytest pkgs.git pkgs.mercurial]; + buildInputs = [ + setuptools + pip + pytest + pkgs.git + pkgs.mercurial + ]; } diff -Nru setuptools-scm-1.15.0/.hgtags setuptools-scm-1.15.6/.hgtags --- setuptools-scm-1.15.0/.hgtags 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/.hgtags 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -1092123ef78598eade56aa9c57e484f3670c8da8 v1.9.0 diff -Nru setuptools-scm-1.15.0/PKG-INFO setuptools-scm-1.15.6/PKG-INFO --- setuptools-scm-1.15.0/PKG-INFO 2016-10-20 21:55:36.000000000 +0000 +++ setuptools-scm-1.15.6/PKG-INFO 2017-06-15 19:24:45.000000000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: setuptools_scm -Version: 1.15.0 +Version: 1.15.6 Summary: the blessed package to manage your versions by scm tags Home-page: https://github.com/pypa/setuptools_scm/ Author: Ronny Pfannschmidt @@ -26,7 +26,6 @@ 1. Add :code:`'setuptools_scm'` to the :code:`setup_requires` parameter 2. Add the :code:`use_scm_version` parameter and set it to ``True`` - E.g.: .. code:: python @@ -39,18 +38,47 @@ ..., ) + Arguments to ``get_version()`` (see below) may be passed as a + dictionary to ``use_scm_version``. For example: + + .. code:: python + + from setuptools import setup + setup( + ..., + use_scm_version = {"root": "..", "relative_to": __file__}, + setup_requires=['setuptools_scm'], + ..., + ) + + + 3. Access the version number in your package via :code:`pkg_resources` + + E.g. (`PEP-0396 `_): + + .. code:: python + + from pkg_resources import get_distribution, DistributionNotFound + try: + __version__ = get_distribution(__name__).version + except DistributionNotFound: + # package is not installed + pass + Programmatic usage ------------------ - In order to use setuptools_scm from code - that one directory deeper than the project's root, you can use: + In order to use ``setuptools_scm`` from code that one directory deeper + than the project's root, you can use: .. code:: python from setuptools_scm import get_version version = get_version(root='..', relative_to=__file__) + See `setup.py Usage`_ above for how to use this within setup.py. + Usage from sphinx ----------------- @@ -61,8 +89,8 @@ .. code:: python from pkg_resources import get_distribution - release = pkg_resources('myproject').version - # for the example take major/minor + release = get_distribution('myproject').version + # for example take major/minor version = '.'.join(release.split('.')[:2]) The underlying reason is, that services like readthedocs sometimes change @@ -94,15 +122,18 @@ :code:`no distance and clean`: :code:`{tag}` :code:`distance and clean`: - :code:`{next_version}.dev{distance}+n{revision hash}` + :code:`{next_version}.dev{distance}+{scm letter}{revision hash}` :code:`no distance and not clean`: :code:`{tag}+dYYYMMMDD` :code:`distance and not clean`: - :code:`{next_version}.dev{distance}+n{revision hash}.dYYYMMMDD` + :code:`{next_version}.dev{distance}+{scm letter}{revision hash}.dYYYMMMDD` The next version is calculated by adding ``1`` to the last numeric component of the tag. + For git projects, the version relies on `git describe `_, + so you will see an additional ``g`` prepended to the ``{revision hash}``. + Semantic Versioning (SemVer) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff -Nru setuptools-scm-1.15.0/README.rst setuptools-scm-1.15.6/README.rst --- setuptools-scm-1.15.0/README.rst 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/README.rst 2017-06-15 19:24:23.000000000 +0000 @@ -18,7 +18,6 @@ 1. Add :code:`'setuptools_scm'` to the :code:`setup_requires` parameter 2. Add the :code:`use_scm_version` parameter and set it to ``True`` - E.g.: .. code:: python @@ -31,18 +30,47 @@ ..., ) + Arguments to ``get_version()`` (see below) may be passed as a + dictionary to ``use_scm_version``. For example: + + .. code:: python + + from setuptools import setup + setup( + ..., + use_scm_version = {"root": "..", "relative_to": __file__}, + setup_requires=['setuptools_scm'], + ..., + ) + + +3. Access the version number in your package via :code:`pkg_resources` + + E.g. (`PEP-0396 `_): + + .. code:: python + + from pkg_resources import get_distribution, DistributionNotFound + try: + __version__ = get_distribution(__name__).version + except DistributionNotFound: + # package is not installed + pass + Programmatic usage ------------------ -In order to use setuptools_scm from code -that one directory deeper than the project's root, you can use: +In order to use ``setuptools_scm`` from code that one directory deeper +than the project's root, you can use: .. code:: python from setuptools_scm import get_version version = get_version(root='..', relative_to=__file__) +See `setup.py Usage`_ above for how to use this within setup.py. + Usage from sphinx ----------------- @@ -53,8 +81,8 @@ .. code:: python from pkg_resources import get_distribution - release = pkg_resources('myproject').version - # for the example take major/minor + release = get_distribution('myproject').version + # for example take major/minor version = '.'.join(release.split('.')[:2]) The underlying reason is, that services like readthedocs sometimes change @@ -86,15 +114,18 @@ :code:`no distance and clean`: :code:`{tag}` :code:`distance and clean`: - :code:`{next_version}.dev{distance}+n{revision hash}` + :code:`{next_version}.dev{distance}+{scm letter}{revision hash}` :code:`no distance and not clean`: :code:`{tag}+dYYYMMMDD` :code:`distance and not clean`: - :code:`{next_version}.dev{distance}+n{revision hash}.dYYYMMMDD` + :code:`{next_version}.dev{distance}+{scm letter}{revision hash}.dYYYMMMDD` The next version is calculated by adding ``1`` to the last numeric component of the tag. +For git projects, the version relies on `git describe `_, +so you will see an additional ``g`` prepended to the ``{revision hash}``. + Semantic Versioning (SemVer) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff -Nru setuptools-scm-1.15.0/setup.cfg setuptools-scm-1.15.6/setup.cfg --- setuptools-scm-1.15.0/setup.cfg 2016-10-20 21:55:36.000000000 +0000 +++ setuptools-scm-1.15.6/setup.cfg 2017-06-15 19:24:45.000000000 +0000 @@ -1,6 +1,9 @@ [bdist_wheel] universal = 1 +[metadata] +license_file = LICENSE + [devpi:upload] formats = sdist,bdist_wheel diff -Nru setuptools-scm-1.15.0/setup.py setuptools-scm-1.15.6/setup.py --- setuptools-scm-1.15.0/setup.py 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/setup.py 2017-06-15 19:24:23.000000000 +0000 @@ -15,25 +15,39 @@ import setuptools -PROBLEMATIC_COMMANDS = 'install', 'develop', 'easy_install', 'bdist_egg' - -if not os.path.isdir('setuptools_scm.egg-info'): - print(__doc__) - - if any(c in sys.argv for c in PROBLEMATIC_COMMANDS): - sys.exit('please run `python setup.py egg_info` first') - - def scm_config(): + here = os.path.dirname(os.path.abspath(__file__)) + egg_info = os.path.join(here, 'setuptools_scm.egg-info') + has_entrypoints = os.path.isdir(egg_info) + + sys.path.insert(0, here) + from setuptools_scm.hacks import parse_pkginfo + from setuptools_scm.git import parse as parse_git from setuptools_scm.version import ( + guess_next_dev_version, get_local_node_and_date, ) - return dict( + + def parse(root): + try: + return parse_pkginfo(root) + except IOError: + return parse_git(root) + + config = dict( version_scheme=guess_next_dev_version, local_scheme=get_local_node_and_date, ) + if has_entrypoints: + return dict(use_scm_version=config) + else: + from setuptools_scm import get_version + return dict(version=get_version( + root=here, parse=parse, **config)) + + with open('README.rst') as fp: long_description = fp.read() @@ -42,8 +56,6 @@ name='setuptools_scm', url='https://github.com/pypa/setuptools_scm/', zip_safe=True, - # pass here since entrypints are not yet registred - use_scm_version=scm_config, author='Ronny Pfannschmidt', author_email='opensource@ronnypfannschmidt.de', description=('the blessed package to manage your versions by scm tags'), @@ -63,13 +75,10 @@ .hg = setuptools_scm.hg:parse .git = setuptools_scm.git:parse - # those are left here for backward compatibility in the 1.x series - .hg_archival.txt = setuptools_scm.hg:parse_archival - PKG-INFO = setuptools_scm.hacks:parse_pkginfo - [setuptools_scm.parse_scm_fallback] .hg_archival.txt = setuptools_scm.hg:parse_archival PKG-INFO = setuptools_scm.hacks:parse_pkginfo + pip-egg-info = setuptools_scm.hacks:parse_pip_egg_info [setuptools_scm.files_command] .hg = setuptools_scm.hg:FILES_COMMAND @@ -103,4 +112,5 @@ ) if __name__ == '__main__': + arguments.update(scm_config()) setuptools.setup(**arguments) diff -Nru setuptools-scm-1.15.0/setuptools_scm/discover.py setuptools-scm-1.15.6/setuptools_scm/discover.py --- setuptools-scm-1.15.0/setuptools_scm/discover.py 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/setuptools_scm/discover.py 2017-06-15 19:24:23.000000000 +0000 @@ -3,11 +3,11 @@ from .utils import trace -def find_matching_entrypoint(path, entrypoint): +def iter_matching_entrypoints(path, entrypoint): trace('looking for ep', entrypoint, path) for ep in iter_entry_points(entrypoint): if os.path.exists(os.path.join(path, ep.name)): if os.path.isabs(ep.name): trace('ignoring bad ep', ep) trace('found ep', ep) - return ep + yield ep diff -Nru setuptools-scm-1.15.0/setuptools_scm/git.py setuptools-scm-1.15.6/setuptools_scm/git.py --- setuptools-scm-1.15.0/setuptools_scm/git.py 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/setuptools_scm/git.py 2017-06-15 19:24:23.000000000 +0000 @@ -4,7 +4,7 @@ import warnings FILES_COMMAND = 'git ls-files' -DEFAULT_DESCRIBE = 'git describe --tags --long --match *.*' +DEFAULT_DESCRIBE = 'git describe --dirty --tags --long --match *.*' def _normalized(path): @@ -77,24 +77,37 @@ """ if not has_command('git'): return - wd = GitWorkdir(root) + + wd = GitWorkdir.from_potential_worktree(root) + if wd is None: + return if pre_parse: pre_parse(wd) - rev_node = wd.node() - dirty = wd.is_dirty() - - if rev_node is None: - return meta('0.0', distance=0, dirty=dirty) out, err, ret = do_ex(describe_command, root) if ret: + # If 'git describe' failed, try to get the information otherwise. + rev_node = wd.node() + dirty = wd.is_dirty() + + if rev_node is None: + return meta('0.0', distance=0, dirty=dirty) + return meta( '0.0', distance=wd.count_all_nodes(), - node=rev_node, + node='g' + rev_node, dirty=dirty, ) + # 'out' looks e.g. like 'v1.5.0-0-g4060507' or + # 'v1.15.1rc1-37-g9bd1298-dirty'. + if out.endswith('-dirty'): + dirty = True + out = out[:-6] + else: + dirty = False + tag, number, node = out.rsplit('-', 2) number = int(number) if number: diff -Nru setuptools-scm-1.15.0/setuptools_scm/hacks.py setuptools-scm-1.15.6/setuptools_scm/hacks.py --- setuptools-scm-1.15.0/setuptools_scm/hacks.py 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/setuptools_scm/hacks.py 2017-06-15 19:24:23.000000000 +0000 @@ -10,4 +10,15 @@ data = data_from_mime(pkginfo) version = data.get('Version') if version != 'UNKNOWN': - return meta(version) + return meta(version, preformatted=True) + + +def parse_pip_egg_info(root): + pipdir = os.path.join(root, 'pip-egg-info') + if not os.path.isdir(pipdir): + return + items = os.listdir(pipdir) + trace('pip-egg-info', pipdir, items) + if not items: + return + return parse_pkginfo(os.path.join(pipdir, items[0])) diff -Nru setuptools-scm-1.15.0/setuptools_scm/hg.py setuptools-scm-1.15.6/setuptools_scm/hg.py --- setuptools-scm-1.15.0/setuptools_scm/hg.py 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/setuptools_scm/hg.py 2017-06-15 19:24:23.000000000 +0000 @@ -7,7 +7,7 @@ def _hg_tagdist_normalize_tagcommit(root, tag, dist, node): dirty = node.endswith('+') - node = node.strip('+') + node = 'h' + node.strip('+') revset = ("(branch(.) and tag({tag!r})::. and file('re:^(?!\.hgtags).*$')" " - tag({tag!r}))").format(tag=tag) if tag != '0.0': @@ -26,6 +26,8 @@ if not has_command('hg'): return l = do('hg id -i -t', root).split() + if not l: + return node = l.pop(0) tags = tags_to_versions(l) # filter tip in degraded mode on old setuptools @@ -56,14 +58,17 @@ def archival_to_version(data): trace('data', data) + node = data.get('node', '')[:12] + if node: + node = 'h' + node if 'tag' in data: return meta(data['tag']) elif 'latesttag' in data: return meta(data['latesttag'], distance=data['latesttagdistance'], - node=data['node'][:12]) + node=node) else: - return meta('0.0', node=data.get('node', '')[:12]) + return meta('0.0', node=node) def parse_archival(root): diff -Nru setuptools-scm-1.15.0/setuptools_scm/__init__.py setuptools-scm-1.15.6/setuptools_scm/__init__.py --- setuptools-scm-1.15.0/setuptools_scm/__init__.py 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/setuptools_scm/__init__.py 2017-06-15 19:24:23.000000000 +0000 @@ -8,7 +8,7 @@ from .utils import trace from .version import format_version, meta, ScmVersion -from .discover import find_matching_entrypoint +from .discover import iter_matching_entrypoints PRETEND_KEY = 'SETUPTOOLS_SCM_PRETEND_VERSION' @@ -32,9 +32,10 @@ def _version_from_entrypoint(root, entrypoint): - ep = find_matching_entrypoint(root, entrypoint) - if ep: - return ep.load()(root) + for ep in iter_matching_entrypoints(root, entrypoint): + version = ep.load()(root) + if version: + return version def dump_version(root, version, write_to, template=None): @@ -79,7 +80,8 @@ root, 'setuptools_scm.parse_scm_fallback') else: # include fallbacks after dropping them from the main entrypoint - version = version_from_scm(root) + version = version_from_scm(root) or _version_from_entrypoint( + root, 'setuptools_scm.parse_scm_fallback') if version: return version diff -Nru setuptools-scm-1.15.0/setuptools_scm/integration.py setuptools-scm-1.15.6/setuptools_scm/integration.py --- setuptools-scm-1.15.0/setuptools_scm/integration.py 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/setuptools_scm/integration.py 2017-06-15 19:24:23.000000000 +0000 @@ -2,7 +2,7 @@ from .version import _warn_if_setuptools_outdated from .utils import do -from .discover import find_matching_entrypoint +from .discover import iter_matching_entrypoints from . import get_version @@ -14,7 +14,10 @@ value = {} if getattr(value, '__call__', None): value = value() - if os.path.exists('PKG-INFO'): + # this piece of code is a hack to counter the mistake in root finding + matching_fallbacks = iter_matching_entrypoints( + '.', 'setuptools_scm.parse_scm_fallback') + if any(matching_fallbacks): value.pop('root', None) dist.metadata.version = get_version(**value) @@ -23,7 +26,8 @@ if not path: path = '.' abs = os.path.abspath(path) - ep = find_matching_entrypoint(abs, 'setuptools_scm.files_command') + ep = next(iter_matching_entrypoints( + abs, 'setuptools_scm.files_command'), None) if ep: command = ep.load() try: diff -Nru setuptools-scm-1.15.0/setuptools_scm/version.py setuptools-scm-1.15.6/setuptools_scm/version.py --- setuptools-scm-1.15.0/setuptools_scm/version.py 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/setuptools_scm/version.py 2017-06-15 19:24:23.000000000 +0000 @@ -1,5 +1,6 @@ from __future__ import print_function import datetime +import warnings import re from .utils import trace @@ -23,6 +24,7 @@ trace('ep', (group, callable_or_name)) if isinstance(callable_or_name, str): for ep in iter_entry_points(group, callable_or_name): + trace("ep found:", ep.name) return ep.load() else: return callable_or_name @@ -30,8 +32,12 @@ def tag_to_version(tag): trace('tag', tag) + if '+' in tag: + warnings.warn("tag %r will be stripped of the local component" % tag) + tag = tag.split('+')[0] # lstrip the v because of py2/py3 differences in setuptools # also required for old versions of setuptools + version = tag.rsplit('-', 1)[-1].lstrip('v') if parse_version is None: return version @@ -49,7 +55,10 @@ class ScmVersion(object): def __init__(self, tag_version, distance=None, node=None, dirty=False, + preformatted=False, **kw): + if kw: + trace("unknown args", kw) self.tag = tag_version if dirty and distance is None: distance = 0 @@ -58,6 +67,7 @@ self.time = datetime.datetime.now() self.extra = kw self.dirty = dirty + self.preformatted = preformatted @property def exact(self): @@ -78,24 +88,45 @@ return self.format_with(dirty_format if self.dirty else clean_format) -def meta(tag, distance=None, dirty=False, node=None, **kw): +def _parse_tag(tag, preformatted): + if preformatted: + return tag if SetuptoolsVersion is None or not isinstance(tag, SetuptoolsVersion): tag = tag_to_version(tag) - trace('version', tag) + return tag + +def meta(tag, distance=None, dirty=False, node=None, preformatted=False, **kw): + tag = _parse_tag(tag, preformatted) + trace('version', tag) assert tag is not None, 'cant parse version %s' % tag - return ScmVersion(tag, distance, node, dirty, **kw) + return ScmVersion(tag, distance, node, dirty, preformatted, **kw) def guess_next_version(tag_version, distance): - version = str(tag_version) - if '.dev' in version: - prefix, tail = version.rsplit('.dev', 1) - assert tail == '0', 'own dev numbers are unsupported' - return '%s.dev%s' % (prefix, distance) - else: - prefix, tail = re.match('(.*?)(\d+)$', version).groups() - return '%s%d.dev%s' % (prefix, int(tail) + 1, distance) + version = _strip_local(str(tag_version)) + bumped = _bump_dev(version) or _bump_regex(version) + suffix = '.dev%s' % distance + return bumped + suffix + + +def _strip_local(version_string): + public, sep, local = version_string.partition('+') + return public + + +def _bump_dev(version): + if '.dev' not in version: + return + + prefix, tail = version.rsplit('.dev', 1) + assert tail == '0', 'own dev numbers are unsupported' + return prefix + + +def _bump_regex(version): + prefix, tail = re.match('(.*?)(\d+)$', version).groups() + return '%s%d' % (prefix, int(tail) + 1) def guess_next_dev_version(version): @@ -109,7 +140,7 @@ if version.exact or version.node is None: return version.format_choice("", "+d{time:%Y%m%d}") else: - return version.format_choice("+n{node}", "+n{node}.d{time:%Y%m%d}") + return version.format_choice("+{node}", "+{node}.d{time:%Y%m%d}") def get_local_dirty_tag(version): @@ -126,6 +157,8 @@ def format_version(version, **config): trace('scm version', version) trace('config', config) + if version.preformatted: + return version.tag version_scheme = callable_or_entrypoint( 'setuptools_scm.version_scheme', config['version_scheme']) local_scheme = callable_or_entrypoint( diff -Nru setuptools-scm-1.15.0/setuptools_scm.egg-info/entry_points.txt setuptools-scm-1.15.6/setuptools_scm.egg-info/entry_points.txt --- setuptools-scm-1.15.0/setuptools_scm.egg-info/entry_points.txt 2016-10-20 21:55:36.000000000 +0000 +++ setuptools-scm-1.15.6/setuptools_scm.egg-info/entry_points.txt 2017-06-15 19:24:45.000000000 +0000 @@ -9,13 +9,10 @@ .hg = setuptools_scm.hg:parse .git = setuptools_scm.git:parse - # those are left here for backward compatibility in the 1.x series - .hg_archival.txt = setuptools_scm.hg:parse_archival - PKG-INFO = setuptools_scm.hacks:parse_pkginfo - [setuptools_scm.parse_scm_fallback] .hg_archival.txt = setuptools_scm.hg:parse_archival PKG-INFO = setuptools_scm.hacks:parse_pkginfo + pip-egg-info = setuptools_scm.hacks:parse_pip_egg_info [setuptools_scm.files_command] .hg = setuptools_scm.hg:FILES_COMMAND diff -Nru setuptools-scm-1.15.0/setuptools_scm.egg-info/PKG-INFO setuptools-scm-1.15.6/setuptools_scm.egg-info/PKG-INFO --- setuptools-scm-1.15.0/setuptools_scm.egg-info/PKG-INFO 2016-10-20 21:55:36.000000000 +0000 +++ setuptools-scm-1.15.6/setuptools_scm.egg-info/PKG-INFO 2017-06-15 19:24:45.000000000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: setuptools-scm -Version: 1.15.0 +Version: 1.15.6 Summary: the blessed package to manage your versions by scm tags Home-page: https://github.com/pypa/setuptools_scm/ Author: Ronny Pfannschmidt @@ -26,7 +26,6 @@ 1. Add :code:`'setuptools_scm'` to the :code:`setup_requires` parameter 2. Add the :code:`use_scm_version` parameter and set it to ``True`` - E.g.: .. code:: python @@ -39,18 +38,47 @@ ..., ) + Arguments to ``get_version()`` (see below) may be passed as a + dictionary to ``use_scm_version``. For example: + + .. code:: python + + from setuptools import setup + setup( + ..., + use_scm_version = {"root": "..", "relative_to": __file__}, + setup_requires=['setuptools_scm'], + ..., + ) + + + 3. Access the version number in your package via :code:`pkg_resources` + + E.g. (`PEP-0396 `_): + + .. code:: python + + from pkg_resources import get_distribution, DistributionNotFound + try: + __version__ = get_distribution(__name__).version + except DistributionNotFound: + # package is not installed + pass + Programmatic usage ------------------ - In order to use setuptools_scm from code - that one directory deeper than the project's root, you can use: + In order to use ``setuptools_scm`` from code that one directory deeper + than the project's root, you can use: .. code:: python from setuptools_scm import get_version version = get_version(root='..', relative_to=__file__) + See `setup.py Usage`_ above for how to use this within setup.py. + Usage from sphinx ----------------- @@ -61,8 +89,8 @@ .. code:: python from pkg_resources import get_distribution - release = pkg_resources('myproject').version - # for the example take major/minor + release = get_distribution('myproject').version + # for example take major/minor version = '.'.join(release.split('.')[:2]) The underlying reason is, that services like readthedocs sometimes change @@ -94,15 +122,18 @@ :code:`no distance and clean`: :code:`{tag}` :code:`distance and clean`: - :code:`{next_version}.dev{distance}+n{revision hash}` + :code:`{next_version}.dev{distance}+{scm letter}{revision hash}` :code:`no distance and not clean`: :code:`{tag}+dYYYMMMDD` :code:`distance and not clean`: - :code:`{next_version}.dev{distance}+n{revision hash}.dYYYMMMDD` + :code:`{next_version}.dev{distance}+{scm letter}{revision hash}.dYYYMMMDD` The next version is calculated by adding ``1`` to the last numeric component of the tag. + For git projects, the version relies on `git describe `_, + so you will see an additional ``g`` prepended to the ``{revision hash}``. + Semantic Versioning (SemVer) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff -Nru setuptools-scm-1.15.0/setuptools_scm.egg-info/SOURCES.txt setuptools-scm-1.15.6/setuptools_scm.egg-info/SOURCES.txt --- setuptools-scm-1.15.0/setuptools_scm.egg-info/SOURCES.txt 2016-10-20 21:55:36.000000000 +0000 +++ setuptools-scm-1.15.6/setuptools_scm.egg-info/SOURCES.txt 2017-06-15 19:24:45.000000000 +0000 @@ -1,5 +1,4 @@ .gitignore -.hgtags .travis.yml CHANGELOG.rst LICENSE @@ -25,6 +24,7 @@ setuptools_scm.egg-info/top_level.txt setuptools_scm.egg-info/zip-safe testing/conftest.py +testing/runtests_travis.py testing/test_basic_api.py testing/test_functions.py testing/test_git.py diff -Nru setuptools-scm-1.15.0/testing/conftest.py setuptools-scm-1.15.6/testing/conftest.py --- setuptools-scm-1.15.0/testing/conftest.py 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/testing/conftest.py 2017-06-15 19:24:23.000000000 +0000 @@ -52,14 +52,26 @@ self(self.add_command) self.commit(reason=reason) - @property - def version(self): + def get_version(self, **kw): __tracebackhide__ = True from setuptools_scm import get_version - version = get_version(root=str(self.cwd)) + version = get_version(root=str(self.cwd), **kw) print(version) return version + @property + def version(self): + __tracebackhide__ = True + return self.get_version() + + +@pytest.yield_fixture(autouse=True) +def debug_mode(): + from setuptools_scm import utils + utils.DEBUG = True + yield + utils.DEBUG = False + @pytest.fixture def wd(tmpdir): diff -Nru setuptools-scm-1.15.0/testing/runtests_travis.py setuptools-scm-1.15.6/testing/runtests_travis.py --- setuptools-scm-1.15.0/testing/runtests_travis.py 1970-01-01 00:00:00.000000000 +0000 +++ setuptools-scm-1.15.6/testing/runtests_travis.py 2017-06-15 19:24:23.000000000 +0000 @@ -0,0 +1,17 @@ + +from subprocess import call + +import os + +if os.environ.get('TOXENV'): + # normal tox run, lets jsut have tox do its job + import tox + tox.cmdline() +elif os.environ.get('SELFINSTALL'): + # self install testing needs some clarity + # so its being executed without any other tools running + call('python setup.py sdist', shell=True) + call('easy_install dist/*', shell=True) + import pkg_resources + dist = pkg_resources.get_distribution('setuptools_scm') + assert set(dist.version) == set(".0"), dist.version diff -Nru setuptools-scm-1.15.0/testing/test_basic_api.py setuptools-scm-1.15.6/testing/test_basic_api.py --- setuptools-scm-1.15.0/testing/test_basic_api.py 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/testing/test_basic_api.py 2017-06-15 19:24:23.000000000 +0000 @@ -30,6 +30,9 @@ wd.write('PKG-INFO', 'Version: 0.1') assert wd.version == '0.1' + # replicate issue 167 + assert wd.get_version(version_scheme="1.{0.distance}.0".format) == '0.1' + def assert_root(monkeypatch, expected_root): """ @@ -45,9 +48,9 @@ setuptools_scm.get_version() -def test_root_parameter_pass_by(monkeypatch): - assert_root(monkeypatch, '/tmp') - setuptools_scm.get_version(root='/tmp') +def test_root_parameter_pass_by(monkeypatch, tmpdir): + assert_root(monkeypatch, tmpdir) + setuptools_scm.get_version(root=tmpdir.strpath) def test_pretended(monkeypatch): @@ -56,9 +59,9 @@ assert setuptools_scm.get_version() == pretense -def test_root_relative_to(monkeypatch): - assert_root(monkeypatch, '/tmp/alt') - __file__ = '/tmp/module/file.py' +def test_root_relative_to(monkeypatch, tmpdir): + assert_root(monkeypatch, tmpdir.join('alt').strpath) + __file__ = tmpdir.join('module/file.py').strpath setuptools_scm.get_version(root='../alt', relative_to=__file__) diff -Nru setuptools-scm-1.15.0/testing/test_functions.py setuptools-scm-1.15.6/testing/test_functions.py --- setuptools-scm-1.15.0/testing/test_functions.py 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/testing/test_functions.py 2017-06-15 19:24:23.000000000 +0000 @@ -14,6 +14,7 @@ ('1.1', '1.2.dev0'), ('1.2.dev', '1.2.dev0'), ('1.1a2', '1.1a3.dev0'), + ('23.24.post2+deadbeef', '23.24.post3.dev0'), ]) def test_next_tag(tag, expected): version = pkg_resources.parse_version(tag) diff -Nru setuptools-scm-1.15.0/testing/test_git.py setuptools-scm-1.15.6/testing/test_git.py --- setuptools-scm-1.15.0/testing/test_git.py 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/testing/test_git.py 2017-06-15 19:24:23.000000000 +0000 @@ -19,21 +19,25 @@ assert wd.version == '0.1.dev0' wd.commit_testfile() - assert wd.version.startswith('0.1.dev1+') + assert wd.version.startswith('0.1.dev1+g') assert not wd.version.endswith('1-') wd('git tag v0.1') assert wd.version == '0.1' wd.write('test.txt', 'test2') - assert wd.version.startswith('0.2.dev0+') + assert wd.version.startswith('0.2.dev0+g') wd.commit_testfile() - assert wd.version.startswith('0.2.dev1+') + assert wd.version.startswith('0.2.dev1+g') wd('git tag version-0.2') assert wd.version.startswith('0.2') + wd.commit_testfile() + wd('git tag version-0.2.post210+gbe48adfpost3+g0cc25f2') + assert wd.version.startswith('0.2') + @pytest.mark.issue(108) @pytest.mark.issue(109) @@ -92,7 +96,13 @@ assert integration.find_files(str(wd.cwd/'project')) == [] +@pytest.mark.issue(128) +def test_parse_no_worktree(tmpdir): + ret = git.parse(str(tmpdir)) + assert ret is None + + def test_alphanumeric_tags_match(wd): wd.commit_testfile() wd('git tag newstyle-development-started') - assert wd.version.startswith('0.1.dev1+') + assert wd.version.startswith('0.1.dev1+g') diff -Nru setuptools-scm-1.15.0/testing/test_mercurial.py setuptools-scm-1.15.6/testing/test_mercurial.py --- setuptools-scm-1.15.0/testing/test_mercurial.py 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/testing/test_mercurial.py 2017-06-15 19:24:23.000000000 +0000 @@ -1,5 +1,5 @@ from setuptools_scm import format_version -from setuptools_scm.hg import archival_to_version +from setuptools_scm.hg import archival_to_version, parse from setuptools_scm import integration import pytest @@ -12,9 +12,10 @@ wd.commit_command = 'hg commit -m test-{reason} -u test -d "0 0"' return wd + archival_mapping = { '1.0': {'tag': '1.0'}, - '1.1.dev3+n000000000000': { + '1.1.dev3+h000000000000': { 'latesttag': '1.0', 'latesttagdistance': '3', 'node': '0'*20, @@ -90,7 +91,7 @@ 'latesttagdistance: 3\n' ) - assert wd.version == '0.2.dev3+n000000000000' + assert wd.version == '0.2.dev3+h000000000000' @pytest.mark.issue('#72') @@ -101,3 +102,9 @@ wd.commit_testfile() wd('hg merge --tool :merge') assert wd.version is not None + + +@pytest.mark.issue(128) +def test_parse_no_worktree(tmpdir): + ret = parse(str(tmpdir)) + assert ret is None diff -Nru setuptools-scm-1.15.0/testing/test_regressions.py setuptools-scm-1.15.6/testing/test_regressions.py --- setuptools-scm-1.15.0/testing/test_regressions.py 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/testing/test_regressions.py 2017-06-15 19:24:23.000000000 +0000 @@ -1,9 +1,12 @@ import sys +import subprocess -import pytest +from setuptools_scm import get_version from setuptools_scm.git import parse from setuptools_scm.utils import do_ex, do +import pytest + def test_pkginfo_noscmroot(tmpdir, monkeypatch): """if we are indeed a sdist, the root does not apply""" @@ -16,19 +19,45 @@ 'from setuptools import setup;' 'setup(use_scm_version={"root": ".."})') - _, stderr, ret = do_ex('python setup.py --version', p) + _, stderr, ret = do_ex((sys.executable, 'setup.py', '--version'), p) assert 'setuptools-scm was unable to detect version for' in stderr assert ret == 1 p.join("PKG-INFO").write('Version: 1.0') - res = do('python setup.py --version', p) + res = do((sys.executable, 'setup.py', '--version'), p) assert res == '1.0' do('git init', p.dirpath()) - res = do('python setup.py --version', p) + res = do((sys.executable, 'setup.py', '--version'), p) assert res == '1.0' +def test_pip_egg_info(tmpdir, monkeypatch): + """if we are indeed a sdist, the root does not apply""" + + # we should get the version from pkg-info if git is broken + p = tmpdir.ensure('sub/package', dir=1) + tmpdir.mkdir('.git') + p.join('setup.py').write( + 'from setuptools import setup;' + 'setup(use_scm_version={"root": ".."})') + + with pytest.raises(LookupError): + get_version(root=p.strpath) + + p.ensure('pip-egg-info/random.egg-info/PKG-INFO').write('Version: 1.0') + assert get_version(root=p.strpath) == '1.0' + + +@pytest.mark.issue(164) +def test_pip_download(tmpdir, monkeypatch): + monkeypatch.chdir(tmpdir) + subprocess.check_call([ + sys.executable, '-c', + 'import pip;pip.main()', 'download', 'lz4==0.9.0', + ]) + + def test_use_scm_version_callable(tmpdir, monkeypatch): """use of callable as use_scm_version argument""" monkeypatch.delenv("SETUPTOOLS_SCM_DEBUG") @@ -45,7 +74,7 @@ ''') p.join("PKG-INFO").write('Version: 1.0') - res = do('python setup.py --version', p) + res = do((sys.executable, 'setup.py', '--version'), p) assert res == '1.0' diff -Nru setuptools-scm-1.15.0/tox.ini setuptools-scm-1.15.6/tox.ini --- setuptools-scm-1.15.0/tox.ini 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/tox.ini 2017-06-15 19:24:23.000000000 +0000 @@ -8,7 +8,6 @@ [testenv] usedevelop=True deps= - py==1.4.26 pytest commands= test: py.test [] diff -Nru setuptools-scm-1.15.0/.travis.yml setuptools-scm-1.15.6/.travis.yml --- setuptools-scm-1.15.0/.travis.yml 2016-10-20 21:55:22.000000000 +0000 +++ setuptools-scm-1.15.6/.travis.yml 2017-06-15 19:24:23.000000000 +0000 @@ -6,7 +6,7 @@ - '3.3' - '3.4' - '3.5' -- '3.6-dev' +- '3.6' env: - TOXENV=py-test @@ -16,13 +16,17 @@ env: TOXENV=flake8 - python: '3.5' env: TOXENV=flake8 + - python: '2.7' + env: SELFINSTALL=1 + - python: '3.5' + env: SELFINSTALL=1 cache: files: - $HOME/.pip/cache - $Home/.cache/pip install: pip install tox script: -- tox -e $TOXENV +- python testing/runtests_travis.py @@ -42,4 +46,4 @@ - <<: *pypi on: tags: true - distributions: "bdist_egg" \ No newline at end of file + distributions: "bdist_egg"