- # When swig generated some shadow classes, place them under
- # self.build_lib (the build directory for Python source).
- import string
- swig_shadow = string.split(os.path.basename(source), ".")[0]
- swig_shadow = swig_shadow + '.py'
- infile = os.path.join(os.path.dirname(source), swig_shadow)
- if os.path.isfile(infile):
- outfile = [self.build_lib, self.distribution.get_name()]
- outfile.append(swig_shadow)
- outfile = apply(os.path.join, outfile)
- self.copy_file(infile, outfile, preserve_mode=0)
+ # When swig generated some shadow classes, place them under
+ # self.build_lib (the build directory for Python source).
+ if self.swig_cpp:
+ # Generate the full pathname of the shadow classes file
+ import string
+ swig_shadow = string.split(os.path.basename(source), ".")[0]
+ swig_shadow = swig_shadow + '.py'
+ # On win32 swig places the shadow classes in the directory
+ # where it was invoked. This is to be opposed to posix where
+ # swig places the shadow classes aside the C++ wrapping code
+ # (the target in our context).
+ if(os.name=='posix'):
+ infile = os.path.join(os.path.dirname(source), swig_shadow)
+ else:
+ infile = swig_shadow
+ if os.path.isfile(infile):
+ outfile = [self.build_lib, self.distribution.get_name()]
+ outfile.append(swig_shadow)
+ outfile = apply(os.path.join, outfile)
+ self.copy_file(infile, outfile, preserve_mode=0)
+ else:
+ self.announce("Warning: swig shadow classes not copied")