[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r16449 - trunk/build/generator

From: David James <james82_at_gmail.com>
Date: 2005-10-04 17:46:14 CEST

On 10/4/05, Max Bowsher <maxb@ukf.net> wrote:
> David James wrote:
> > On 10/4/05, djames@tigris.org <djames@tigris.org> wrote:
> >> Author: djames
> >> Date: Tue Oct 4 09:52:26 2005
> >> New Revision: 16449
> >>
> >> Modified:
> >> trunk/build/generator/gen_make.py
> >>
> >> Log:
> >> Ensure that all python modules import libsvn._core before importing
> >> any other modules, so that the initialization code is run in the correct
> >> order (thus preventing segfaults). We can't implement this trick in SWIG,
> >> so we do it by postprocessing the SWIG output files.
> >>
> >> * build/generator/gen_make.py
> >> (Generator.write): Update generated *.py files to import libsvn._core
> >> first.
> >>
> >>
> >>
> >> Modified: trunk/build/generator/gen_make.py
> >> Url:
> >> http://svn.collab.net/viewcvs/svn/trunk/build/generator/gen_make.py?rev=16449&p1=trunk/build/generator/gen_make.py&p2=trunk/build/generator/gen_make.py&r1=16448&r2=16449
> >> ==============================================================================
> >> --- trunk/build/generator/gen_make.py (original) +++
> >> trunk/build/generator/gen_make.py Tue Oct 4 09:52:26 2005 @@ -1,10
> >> +1,10 @@ -#
> >> # gen_make.py -- generate makefiles and dependencies
> >> #
> >>
> >> import os
> >> import sys
> >> import string
> >> +import re
> >>
> >> import gen_base
> >> import generator.util.executable
> >> @@ -209,7 +209,20 @@
> >> 'cp -pf $(abs_srcdir)/%s/*.i ' % source_dir +
> >> '$(abs_builddir)/%s; fi\n' % source_dir +
> >> '\t$(SWIG) $(SWIG_INCLUDES) %s ' % opts +
> >> - '-o $@ $(abs_builddir)/%s\n' % source +
> >> + '-o $@ $(abs_builddir)/%s\n' % source
> >> + )
> >> + if objname.lang == "python":
> >> + # Ensure that all python modules import libsvn._core before
> >> importing + # any other modules, so that the initialization code
> >> is
> >> run in the + # correct order. We can't implement this trick in
> >> SWIG, so we do it + # by postprocessing the SWIG output files.
> >> + pyfile = re.sub(r"(?:svn_)?(\w+)\.c$",r"\1.py", str(objname))
> >> + self.ofile.write(
> >> + '\tmv %s %s-swig ' % (pyfile, pyfile) +
> >> + '&& (echo import _core | cat - %s-swig > %s) ' % (pyfile,
> >> pyfile) + + '&& rm %s-swig\n' % (pyfile)
> >> + )
> >> + self.ofile.write(
> >> 'autogen-swig-%s: copy-swig-%s\n' % (short[objname.lang],
> >> objname) + 'copy-swig-%s: %s\n' % (objname, objname) +
> >> '\t@if test $(abs_srcdir) != $(abs_builddir) -a ' +
> >
> > Any suggestions for how we can port this fix to Windows?
> >
> > Here's a test case:
> > python -c "import svn.wc"
> That fix is _reeeaaaaly_ hacky :-(
>
> Also, why is it needed at all?
I hope that this fix is not necessary, or that we can find a different
way of implementing it. :)

> The testcase completes successfully for me without this revision, plus, I
> manually examined the generated .py files and found that _core was being
> imported soon enough anyway without this fix.
Is it? On my machine, libsvn/wc.py starts like this:
  # This file was created automatically by SWIG.
  # Don't modify this file, modify the SWIG interface instead.
  # This file is compatible with both classic and new-style classes.

  import _wc

Oops! We imported _wc before importing _core. I'm not sure why
importing _wc before _core leads to crashes on my machine now -- it
used to work fine.

Cheers,

David

--
David James -- http://www.cs.toronto.edu/~james
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Oct 4 17:47:32 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.