Using the Windows "embedded" distribution of Python

eryk sun eryksun at gmail.com
Thu Sep 29 07:55:26 EDT 2016


On Thu, Sep 29, 2016 at 10:41 AM, Paul  Moore <p.f.moore at gmail.com> wrote:
> On Thursday, 29 September 2016 10:39:10 UTC+1, eryk sun  wrote:
>> On Thu, Sep 29, 2016 at 8:35 AM, Paul  Moore <p.f.moore at gmail.com> wrote:
>> > PS It's a shame there's no way to put the embedded distribution in a subdirectory
>> > *without* needing to use dynamic loading, but I guess that's basically an OS limitation.
>>
>> There are ways to do this. The simplest way is to use a subdirectory
>> with same name as the executable plus ".local". For example, for
>> "app.exe" create a directory named "app.exe.local".
>
> Oh, wow. Now you mention it, I recall that convention (from somewhere). I'll
> investigate that option (although it may not suit my use case, as I want multiple exes
> in the one "main" directory sharing a single "local" Python runtime).

In that case you can use an application manifest with a dependent
assembly. Say embedded Python 3.6 is in the "py3embed" subdirectory.
Add the following manifest file to that directory:

py3embed.manifest:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
        <assemblyIdentity name="py3embed"
                          version="3.6.111.1013"
                          type="win32"
                          processorArchitecture="amd64" />
        <file name="python3.dll" />
        <file name="python36.dll" />
        <file name="vcruntime140.dll" />
    </assembly>

Add this assembly as a dependency in the application manifest, either
embedded in the executable (resource #1) or as a separate file named
the same as the executable plus ".manifest", e.g. "app.exe.manifest".
You can start with the manifest that's used by python.exe, from
PC\python.manifest.

  <dependency>
    <dependentAssembly>
      <assemblyIdentity name="py3embed"
                        version="3.6.111.1013"
                        type="win32"
                        processorArchitecture="amd64" />
    </dependentAssembly>
  </dependency>



More information about the Python-list mailing list