Skip to content
This repository was archived by the owner on Dec 31, 2021. It is now read-only.

Commit 5623a7c

Browse files
committed
Revert using setuptools svn revision, it is broken.
1 parent fe23881 commit 5623a7c

File tree

1 file changed

+20
-37
lines changed

1 file changed

+20
-37
lines changed

setup.py

+20-37
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import os
2020
import sys
2121
import re
22+
import subprocess
2223

2324
CLASSIFIERS = """\
2425
Development Status :: 5 - Production/Stable
@@ -53,42 +54,24 @@
5354
ISRELEASED = False
5455
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
5556

56-
# Return the svn version as a string (copied from setuptools)
57-
def svn_revision():
58-
from numpy.distutils import log
59-
revision = 0
60-
urlre = re.compile('url="([^"]+)"')
61-
revre = re.compile('committed-rev="(\d+)"')
62-
63-
for base,dirs,files in os.walk(os.curdir):
64-
if '.svn' not in dirs:
65-
dirs[:] = []
66-
continue # no sense walking uncontrolled subdirs
67-
dirs.remove('.svn')
68-
f = open(os.path.join(base,'.svn','entries'))
69-
data = f.read()
70-
f.close()
71-
72-
if data.startswith('9') or data.startswith('8'):
73-
data = map(str.splitlines,data.split('\n\x0c\n'))
74-
del data[0][0] # get rid of the '8' or '9'
75-
dirurl = data[0][3]
76-
localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]+[0])
77-
elif data.startswith('<?xml'):
78-
dirurl = urlre.search(data).group(1) # get repository URL
79-
localrev = max([int(m.group(1)) for m in revre.finditer(data)]+[0])
80-
else:
81-
log.warn("unrecognized .svn/entries format; skipping %s", base)
82-
dirs[:] = []
83-
continue
84-
if base==os.curdir:
85-
base_url = dirurl+'/' # save the root url
86-
elif not dirurl.startswith(base_url):
87-
dirs[:] = []
88-
continue # not part of the same svn tree, skip it
89-
revision = max(revision, localrev)
90-
91-
return str(revision)
57+
# Return the svn version as a string, raise a ValueError otherwise
58+
def svn_version():
59+
try:
60+
out = subprocess.Popen(['svn', 'info'], stdout = subprocess.PIPE).communicate()[0]
61+
except OSError:
62+
print " --- Could not run svn info --- "
63+
return ""
64+
65+
r = re.compile('Revision: ([0-9]+)')
66+
svnver = None
67+
for line in out.split('\n'):
68+
m = r.match(line)
69+
if m:
70+
svnver = m.group(1)
71+
72+
if not svnver:
73+
raise ValueError("Error while parsing svn version ?")
74+
return svnver
9275

9376
# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
9477
# update it when the contents of directories change.
@@ -105,7 +88,7 @@ def svn_revision():
10588
FULLVERSION += '.dev'
10689
# If in git or something, bypass the svn rev
10790
if os.path.exists('.svn'):
108-
FULLVERSION += svn_revision()
91+
FULLVERSION += svn_version()
10992

11093
def write_version_py(filename='numpy/version.py'):
11194
cnt = """

0 commit comments

Comments
 (0)