[Distutils] Compiling / Installing extensions

Greg Ward gward@python.net
Tue, 8 Feb 2000 20:20:01 -0500

On 08 February 2000, Thomas Heller said:
> I suggest:
>         if self.compiler.compiler_type == 'msvc':
>             def_file = build_info.get ('def_file')
>             if def_file is None:
>                 source_dir = os.path.dirname (sources[0])
>                 ext_base = (string.split (extension_name, '.'))[-1]
>                 def_file = os.path.join (source_dir, "%s.def" % ext_base)
>                 if not os.path.exists (def_file):
>                     self.warn ("file '%s' not found: " % def_file +
>                                "might have problems building DLL")
>                     def_file = None
>             if def_file is not None:
>                 extra_args.append ('/DEF:' + def_file)
>             else:
>                 modname = string.split (extension_name, '.')[-1]
>                 extra_args.append('/export:init%s'%modname)
> split(extension_name) is needed for extensions living in package
> directories.

D'oh!  Thanks, fixed it (not in CVS yet though).

> If the developer bothers to write a def file, it should be used.
> Otherwise guess the exported symbol.
> Note:
> For normal python extensions, only this single export is used.
> This may be different for COM-modules for example...

Oh bother.  OK, if it's really needed.  ;-(

A question for the crowd (especially Windows extension developers)
before I give in: have you ever needed to define a .def file to link
your extensions?  Or, more bluntly, is Thomas correct, that a
COM-aware extension might need to export more symbols than 'initfoo'?
No offense Thomas, I just want to make sure that this ugly hack really
is needed.

Greg Ward - programmer-at-large                         gward@python.net
It has just been discovered that research causes cancer in rats.