Commits

anatoly techtonik committed 58d0c2c

add Trac source code patching

Comments (0)

Files changed (1)

 # Placed into public domain by anatoly techtonik
 
 import os
+import shutil
 import sys
 import subprocess
 
 
 # module checkout URLs
 GENSHI = 'http://svn.edgewall.org/repos/genshi/branches/stable/0.6.x/genshi'
+PATCH = 'http://python-patch.googlecode.com/svn/tags/11.01'
+
+# setuptools curse lifting patch
+TRACPATCH = DEVPATH + '/trac-0.12.2.patch'
 
 
 print("Executing Trac from source checkout (using .trac/ environment)")
 import genshi
 print("... imported Genshi %s" % genshi.__version__)
 
+
+print("0x. Patching Trac to get rid of setuptools dependency")
+try:
+  import imp
+  imp.find_module('patch')
+except ImportError:
+  PATCHPATH = os.path.join(LIBPATH, 'patch')
+  if not os.path.exists(PATCHPATH + '.py'):
+    print('... fetching python-patch')
+    get_module(PATCH, PATCHPATH)
+    shutil.move(os.path.join(PATCHPATH, 'patch.py'), LIBPATH)
+    shutil.rmtree(PATCHPATH)
+  else:
+    sys.exit('FAIL: can\'t get python-patch')
+cmd = "python %s/patch.py %s" % (LIBPATH, TRACPATCH)
+retcode = subprocess.call(cmd, shell=True)
+# [ ] TODO return status code if file is already patched
+print('... patch returned %s (which doesn\'t mean anything on second run)' % retcode)
+
 print("03. Importing Core Trac Modules")
 # even core Trac modules are imported through setuptools, and
 # here is a workaround to get rid of the dependency