diff options
-rw-r--r-- | .hgignore | 12 | ||||
-rw-r--r-- | README.rst | 29 | ||||
-rw-r--r-- | setup.py | 36 | ||||
-rw-r--r-- | setuptools_scm.sublime-project | 9 | ||||
-rw-r--r-- | setuptools_scm/__init__.py | 10 | ||||
-rw-r--r-- | setuptools_scm/__main__.py | 9 |
6 files changed, 76 insertions, 29 deletions
@@ -1,8 +1,10 @@ hgdistver_version.py MANIFEST$ .*\.egg-info -dist -build -\.tox -\.cache -\.env +dist/ +build/ +\.tox/ +\.cache/ +\.env/ +\.eggs/ +README.html @@ -62,9 +62,9 @@ To use setuptools_scm simple modify your project's setup.py file like this: 2. Add :code:`'setuptools_scm'` to the :code:`setup_requires` parameter E.g.: - + .. code:: python - + from setuptools import setup setup( ..., @@ -72,7 +72,7 @@ To use setuptools_scm simple modify your project's setup.py file like this: setup_requires=['setuptools_scm'], ..., ) - + In order to configure the way ``use_scm_version`` works you can provide a mapping with options instead of simple boolean value. @@ -148,3 +148,26 @@ Version number construction :node-and-date: adds the node on dev versions and the date on dirty workdir (default) :dirty-tag: adds :code:`+dirty` if the current workdir has changes + + +Importing in setup.py +~~~~~~~~~~~~~~~~~~~~~ + +To support usage in :code:`setup.py` passing a callable into use_scm_version +is supported. + +Within that callable, setuptools_scm is availiable for import. +The callable must return the configuration. + + +.. code:: python + + def myversion(): + from setuptools_scm.version import dirty_tag + def clean_scheme(version): + if not version.dirty: + return '+clean' + else: + return dirty_tag(version) + + return {'local_scheme': clean_scheme} @@ -7,27 +7,29 @@ will generate partial data its critical to run egg_info once before running sdist in a fresh checkouts """ - -from functools import partial +import pkg_resources import setuptools -from setuptools_scm.version import ( - guess_next_dev_version, - get_local_node_and_date, -) + +def scm_config(): + + from setuptools_scm.version import ( + guess_next_dev_version, + get_local_node_and_date, + ) + return dict( + version_scheme=guess_next_dev_version, + local_scheme=get_local_node_and_date, + ) with open('README.rst') as fp: long_description = fp.read() -setup = partial( - setuptools.setup, +arguments = dict( name='setuptools-scm', url='http://bitbucket.org/pypa/setuptools_scm/', # pass here since entrypints are not yet registred - use_scm_version={ - 'version_scheme': guess_next_dev_version, - 'local_scheme': get_local_node_and_date, - }, + use_scm_version=scm_config, author='Ronny Pfannschmidt', author_email='opensource@ronnypfannschmidt.de', description=('the blessed package to manage your versions by scm tags'), @@ -36,6 +38,12 @@ setup = partial( packages=[ 'setuptools_scm', ], + install_requires=[ + 'setuptools>=12' + ], + setup_requires=[ + 'setuptools>=12' + ], entry_points={ 'distutils.setup_keywords': [ 'use_scm_version = setuptools_scm:setuptools_version_keyword' @@ -72,5 +80,7 @@ setup = partial( 'Topic :: Utilities', ], ) + if __name__ == '__main__': - setup() + pkg_resources.require('setuptools>=12') + setuptools.setup(**arguments) diff --git a/setuptools_scm.sublime-project b/setuptools_scm.sublime-project new file mode 100644 index 0000000..9cbd597 --- /dev/null +++ b/setuptools_scm.sublime-project @@ -0,0 +1,9 @@ +{ + "folders": + [ + { + "follow_symlinks": true, + "path": "." + } + ] +} diff --git a/setuptools_scm/__init__.py b/setuptools_scm/__init__.py index ff71889..9951bbb 100644 --- a/setuptools_scm/__init__.py +++ b/setuptools_scm/__init__.py @@ -1,10 +1,8 @@ -from __future__ import print_function """ :copyright: 2010-2015 by Ronny Pfannschmidt :license: MIT """ import os -import sys from pkg_resources import iter_entry_points @@ -49,6 +47,8 @@ def setuptools_version_keyword(dist, keyword, value): return if value is True: value = {} + if getattr(value, '__call__', None): + value = value() try: dist.metadata.version = get_version(**value) except Exception as e: @@ -78,9 +78,3 @@ def find_files(path='.'): return command(path) else: return [] - -if __name__ == '__main__': - print('Guessed Version', get_version()) - if 'ls' in sys.argv: - for fname in find_files('.'): - print(fname) diff --git a/setuptools_scm/__main__.py b/setuptools_scm/__main__.py new file mode 100644 index 0000000..386cb5c --- /dev/null +++ b/setuptools_scm/__main__.py @@ -0,0 +1,9 @@ +from __future__ import print_function +import sys +from setuptools_scm import get_version, find_files + +if __name__ == '__main__': + print('Guessed Version', get_version()) + if 'ls' in sys.argv: + for fname in find_files('.'): + print(fname) |