Installer vs py2exe: Windows DLLs

Gordon McMillan gmcm at hypernet.com
Thu Jun 6 08:37:07 EDT 2002


Paul Moore wrote:

[Installer's dependency on win32api / pywintypes]

> OK, I analyzed this a bit further. This is all for Python 2.2 on
> Windows 2000.
> 
> The win32api dependency (and hence the PyWinTypes22 dependency) comes
> from iu.py, in the RegistryImportDirector. Two questions come to mind
> - first is whether it is appropriate for Installer-built
> applications to look in the registry for Python entries in any case, as
> the whole point is to run independently of any installed copy of
> Python. I imagine that something later in the process disables picking
> up registry entries, but that leaves the RegistryImportDirector code as
> dead code (which isn't worth worrying about, except for the spurious
> dependency).

Well iu.py is a drop-in import replacement. I guess I'll have to
think about refactoring it so Installer can use it without drawing
in the registry code.

> The second question is whether RegistryImportDirector she
> translation is pretty much automatic - I attach a patch. This gives a
> dependency on _winreg.pyd (pity - I'd assumed _winreg would be built
> in on Windows :-() but that is *much* smaller than win32api +
> PyWinTypes22. Minimal testing shows no problems, but a better test
> would be worth doing...

_winreg.pyd didn't exist as of Py 1.5, but your patch looks
good.
 
> The dependency on _sre comes from posixpath (in expandvars()), which
> is imported conditionally by os. And os is imported by archive.py, to
> get at os.path.basename, and os.path.splitext. Would it not be
> possible here to directly use {dos,mac,nt,posix}path?

Sure. In fact, iu is already doing that, so archive could probably
get at them that way (although it currently doesn't know about iu).
But archive only imports os when *building* an archive, so if that's
the only import of os, you're free to exclude it.
 
> I know that in the grand scheme of things, removing dependencies like
> this is fairly pointless for any "real" application, but it appeals to
> my sense of minimalism. 

You can get a cross-reference of dependencies from mf.py for this
exact reason (deciding what can be safely excluded).

-- Gordon
http://www.mcmillan-inc.com/




More information about the Python-list mailing list