Mercurial > hgsubversion
changeset 562:c538229d02ca
setup: work around easy_install by getting version with a regex
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 15 Feb 2010 10:53:34 -0600 |
parents | 312c8c98eeff |
children | 09c016174e33 |
files | setup.py |
diffstat | 1 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- import os +import re import subprocess import sys import time @@ -76,16 +77,20 @@ elif os.path.exists('.hg_archival.txt'): else: version = kw.get('node', '')[:12] +verfile = os.path.join("hgsubversion", "__version__.py") if version: - f = open("hgsubversion/__version__.py", "w") + f = open(verfile, "w") f.write('# this file is autogenerated by setup.py\n') f.write('version = "%s"\n' % version) f.close() -try: - from hgsubversion import __version__ - version = __version__.version -except ImportError: +if os.path.exists(verfile): + # scrape the version out with a regex because setuptools + # needlessly swaps out file() for some non-object thing + # and breaks importing hgsubversion entirely + mat = re.findall('.*"(.*)"', open(verfile).read()) + version = mat[0] +if not version: version = 'unknown' try: