[python-win32] How Do You Make Your Speech or SAPI 5 Voices Portable?

Tim Roberts timr at probo.com
Thu Jun 26 19:49:08 CEST 2008


FT wrote:
> NOTE:
>     If you do make an executable you may also after compiling the Voice2.py
> get an error if you do not
> have MSVcp71.dll, mfc71.dll, and gdiplus.dll copied into your setup.py file.
> In other words a copy command to
> copy the dll's from your system32 folder. For if you do not, some computers
> it is run on will fail if they do not have those dll's installed. It would
> appear that they are not automatically copied.
>
>     I am assuming that most of you probably have all the C dll's and such
> and may not need the note, but those who do not will need the dll's.
>
> #FORCE THE NEEDED DLL'S OR COMMENT THEM OUT!
> shutil.copy("c:/windows/system32/msvcp71.dll", os.path.join(os.getcwd(),
> "dist", "msvcp71.dll"))
> shutil.copy("c:/windows/system32/msvcp71.dll", os.path.join(os.getcwd(),
> "dist", "mfc71.dll"))
> shutil.copy("c:/windows/system32/msvcp71.dll", os.path.join(os.getcwd(),
> "dist", "gdiplus.dll"))
>   

These DLLs should have been loaded on every Windows XP by Windows 
Update, so anyone with a recent system should have them.

However, that short snippet has a couple of problems.  First, you assume 
that everyone's Windows directory is called "c:/windows".  Second, you 
are copying all three files to the same destination name.  Instead, do 
something like this:

    dest = os.path.join( os.environ['WINDIR'], 'system32' )
    for dll in ("msvcp71.dll", "mfc71.dll", "gdiplus.dll"):
        if not os.path.isfile( os.path.join( dest, dll ) ):
            shutil.copy( os.path.join( dest, dll ), os.path.join( 
'dist', dll ) )

You may think this is nitpicking, and you're probably right, but once 
you start trying to release code into the wild, you have to start 
thinking about the issues you encounter in the strange and magical world 
of the average user.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list