summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.hgignore12
-rw-r--r--README.rst29
-rw-r--r--setup.py36
-rw-r--r--setuptools_scm.sublime-project9
-rw-r--r--setuptools_scm/__init__.py10
-rw-r--r--setuptools_scm/__main__.py9
6 files changed, 76 insertions, 29 deletions
diff --git a/.hgignore b/.hgignore
index b17d1dd..a0451a1 100644
--- a/.hgignore
+++ b/.hgignore
@@ -1,8 +1,10 @@
hgdistver_version.py
MANIFEST$
.*\.egg-info
-dist
-build
-\.tox
-\.cache
-\.env
+dist/
+build/
+\.tox/
+\.cache/
+\.env/
+\.eggs/
+README.html
diff --git a/README.rst b/README.rst
index 0f7b852..eafcedc 100644
--- a/README.rst
+++ b/README.rst
@@ -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}
diff --git a/setup.py b/setup.py
index 3a4ea29..8c2d681 100644
--- a/setup.py
+++ b/setup.py
@@ -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)