diff options
-rw-r--r-- | hgvers.py | 47 | ||||
-rw-r--r-- | setup.py | 6 | ||||
-rw-r--r-- | version_detect/__init__.py | 1 | ||||
-rw-r--r-- | version_detect/hg_keywords.py | 21 | ||||
-rw-r--r-- | version_detect/version.py | 10 |
5 files changed, 50 insertions, 35 deletions
diff --git a/hgvers.py b/hgvers.py new file mode 100644 index 0000000..57b7d48 --- /dev/null +++ b/hgvers.py @@ -0,0 +1,47 @@ +# Copyright 2008 Lime Nest LLC + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import re + +repo = None +version = None + +try: + import hgversion as hgv + +except ImportError: + # either we couldn't find hgversion or + # hgversion couldn't find mercurial libraries + pass +else: + repo = hgv.repository # could be None if we're not in an hg repository + +if repo is None: + + try: + f = open('PKG-INFO') + except IOError: + pass + else: + regex = re.compile('^Version:\s+(\S+)') + for line in f: + mo = regex.match(line) + if mo is not None: + version = mo.group(1) + break +else: + version = hgv.version() + +if __name__ == '__main__': + print version @@ -1,10 +1,10 @@ from setuptools import setup -import version_detect +import hgvers setup( name = "urllib2_kerberos", - version = version_detect.version, - py_modules = [ 'urllib2_kerberos' ], + version = hgvers.version, + py_modules = [ 'urllib2_kerberos', 'hgvers' ], # install_requires = ['kerberos'], diff --git a/version_detect/__init__.py b/version_detect/__init__.py deleted file mode 100644 index 2eb889b..0000000 --- a/version_detect/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from version import version diff --git a/version_detect/hg_keywords.py b/version_detect/hg_keywords.py deleted file mode 100644 index edc9bae..0000000 --- a/version_detect/hg_keywords.py +++ /dev/null @@ -1,21 +0,0 @@ -import re - -keyword_rx = re.compile('^\$(\w+)\:\s+(\S*)\s*\$$') - -# returns tuple (key, value) -# returns None if kwstring is not a keyword expansion -def extract_keyvalue(kwstring): - mo = keyword_rx.match(kwstring) - if mo is None: return None - - try: - return mo.group(1,2) - except IndexError: - return None - - - -def keywords(*kwstrings): - keyvalues = [extract_keyvalue(kws) for kws in kwstrings] - compacted_keyvalues = [kv for kv in keyvalues if kv is not None] - return dict(compacted_keyvalues) diff --git a/version_detect/version.py b/version_detect/version.py deleted file mode 100644 index f9efac4..0000000 --- a/version_detect/version.py +++ /dev/null @@ -1,10 +0,0 @@ -import hg_keywords - -keywords = hg_keywords.keywords( - "$branches$", - "$node$", - "$rev$", - "$tags$" - ) - -version = "dev_%s_%s" % tuple([keywords[x] for x in 'rev', 'node']) |