Monday, March 31, 2008

setuptools and Subversion 1.5

Heads up: if you do not patch setuptools, installs from svn working copies *will* error out when you upgrade to Subversion 1.5. This isn't a big deal, really. If you're not using the new features, you can easily downgrade your working copy (left as an exercise for the reader, since I don't want to empower that kind of bad behavior). That said, if you are like me, you want to just fix setuptools. I figured out the patch. It's actually trivial, since they are already parsing the entries file in a sane way, all that needed to happen was to bump the accepted version of the entries file in the setuptools sources and move on with my day. Unfortunately, they have been totally silent on the patch. As such, I'm posting it here so that Google at least has a chance of finding this and making the world able to fix this problem. Here's the patch:

Index: setuptools/command/egg_info.py
===================================================================
--- setuptools/command/egg_info.py (revision 61076)
+++ setuptools/command/egg_info.py (working copy)
@@ -217,9 +217,9 @@
data = f.read()
f.close()

- if data.startswith('8'):
+ if data.startswith('8') or data.startswith('9'):
data = map(str.splitlines,data.split('\n\x0c\n'))
- del data[0][0] # get rid of the '8'
+ del data[0][0] # get rid of the '8' or '9'
dirurl = data[0][3]
localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]+[0])
elif data.startswith('<?xml'):
Index: setuptools/command/sdist.py
===================================================================
--- setuptools/command/sdist.py (revision 61076)
+++ setuptools/command/sdist.py (working copy)
@@ -86,7 +86,7 @@
f = open(filename,'rU')
data = f.read()
f.close()
- if data.startswith('8'): # subversion 1.4
+ if data.startswith('8') or data.startswith('9'): # subversion 1.4 or 1.5
for record in map(str.splitlines, data.split('\n\x0c\n')[1:]):
if not record or len(record)>=6 and record[5]=="delete":
continue # skip deleted

If this works for you (and you are sure you are using svn 1.5 client binaries ("head -n 1 .svn/entries" prints "9"), please head over to the distutils SIG list and mention that it works for you. Of course, if you're reading this and you can be more of an authority than I can (I read the the libsvn_wc docs (search "The entries file")), please comment over there if the patch is right, or give me feedback so I can submit a more resilient patch.