I've worked out how to fix up the DSP files to remove the need to
change the Tools Directories settings in MSDEV for each build.
You can now build subversion python binding for any python without
reconfiguring MSDEV. It looked like a lot of work to understand the
generator code; I fix up the DSPs after its done its thing.
fix_python_dsp.py makes sure that:
1. Paths to tools are full. python.exe and swig.exe
2. Python include dir is added to all C++ compiles
3. Path to Python library directory is added to links.
This should work for all the 2.x pythons and and SWIG you wish to use.
Use the python.exe that you wish to build the extensions for when running
fix_python_dsp.py. Below I'm using python23, python22 will work as well.
I do the following steps in the subversion directory:
------------------------------------
c:\python23\python gen-make.py -t dsp --with-httpd=..\httpd-2.0.47
c:\python23\python ..\fix_python_dsp.py c:\SWIG-1.3.19\swig.exe
build\win32\msvc-dsp\libsvn_swig_py_msvc.dsp
c:\python23\python ..\fix_python_dsp.py c:\SWIG-1.3.19\swig.exe
build\win32\msvc-dsp\swig_python_*.dsp
msdev subversion_msvc.dsw /MAKE "__ALL__ - Win32 Release"
------------------------------------
This relies on this patch to build/win32/gen_swig_runtime.py
Index: gen_swig_runtime.py
===================================================================
--- gen_swig_runtime.py (revision 7257)
+++ gen_swig_runtime.py (working copy)
@@ -66,14 +66,15 @@
}
if __name__ == "__main__":
- if len(sys.argv) != 3:
- print >> sys.stderr, 'Usage: %s language output.c' % sys.argv[0]
+ if len(sys.argv) != 4:
+ print >> sys.stderr, 'Usage: %s swig-exe language output.c' % sys.argv[0]
sys.exit(1)
- language = sys.argv[1]
- output = sys.argv[2]
+ swig_exe = sys.argv[1]
+ language = sys.argv[2]
+ output = sys.argv[3]
- fp = os.popen('swig -swiglib', 'r')
+ fp = os.popen('%s -swiglib' % swig_exe, 'r')
try:
SWIG_LIB = string.rstrip(fp.readline())
finally:
---------------------------------------------
This is fix_python_dsp.py:
---------------------------------------------
import sys
import os
import glob
from distutils import sysconfig
cpp_add_prefix = '# ADD CPP /nologo '
len_cpp_add_prefix = len(cpp_add_prefix)
link_add_prefix = '# ADD LINK32 /nologo '
len_link_add_prefix = len(link_add_prefix)
python_prefix = '\tpython '
len_python_prefix = len( python_prefix )
swig_prefix = '\tswig '
len_swig_prefix = len( swig_prefix )
python_gen_swig = '\tpython $(InputPath) '
len_python_gen_swig = len(python_gen_swig)
def main( swig_exe, filename ):
print 'Info: Add Python include to %s' % filename
inc = sysconfig.get_python_inc()
plat = sysconfig.get_python_inc(plat_specific=1)
if inc == plat:
py_include = '/I "%s"' % inc
else:
py_include = '/I "%s" /I "%s"' % (inc, plat)
# distutils doesn't know this one sigh...
py_lib = '/libpath:"%s"' % os.path.join( os.path.normpath(sys.prefix),
'libs' )
all_lines = open( filename, 'r' ).readlines()
f = open( filename, 'w' )
for line in all_lines:
if line[0:len_cpp_add_prefix] == cpp_add_prefix:
f.write( '%s %s %s' % (cpp_add_prefix, py_include,
line[len_cpp_add_prefix:]) )
elif line[0:len_link_add_prefix] == link_add_prefix:
f.write( '%s %s %s' % (link_add_prefix, py_lib,
line[len_link_add_prefix:]) )
elif line[0:len_python_gen_swig] == python_gen_swig:
f.write( '\t%s $(InputPath) %s %s' % (sys.executable, swig_exe,
line[len_python_gen_swig:]) )
elif line[0:len_python_prefix] == python_prefix:
f.write( '\t%s %s' % (sys.executable, line[len_python_prefix:]) )
elif line[0:len_swig_prefix] == swig_prefix:
f.write( '\t%s %s' % (swig_exe, line[len_swig_prefix:]) )
else:
f.write( '%s' % line )
f.close()
if __name__ == '__main__':
swig_exe = sys.argv[1]
for filename in glob.glob( sys.argv[2] ):
main( swig_exe, filename )
-------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Sep 30 22:28:17 2003