Title: Static Windows Build fails to locate existing installation
Type: behavior Stage: resolved
Components: Build Versions: Python 3.8
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: loewis Nosy List: amaury.forgeotdarc, babydoe, georg.brandl, loewis, steve.dower, tim.golden, zach.ware
Priority: low Keywords: patch

Created on 2005-10-15 18:43 by babydoe, last changed 2019-08-02 22:48 by steve.dower. This issue is now closed.

File name Uploaded Description Edit
dl_nt.c babydoe, 2005-10-15 18:43 Modified dl_nt.c (for static/dynamic build)
Messages (7)
msg48869 - (view) Author: Doe, Baby (babydoe) Date: 2005-10-15 18:43
I have used the Python 2.4.2 source to create a static
linkable version under windows (.lib). The executables
using that library fail to find the registry path of an
already existing Python 2.4 installation.

I have traced this down to the PC/dl_nt.c file, where
the variable PyWin_DLLVersionString is defined, but not
initialized, execpt if the DllMain function is called.
That function is only called by a process loading a
DLL, this is not the case with an static linked library.

I have used a preprocessor check against
Py_NO_ENABLE_SHARED to create a modified version of
dl_nt.c that will initialize the variable and remove
the DLLMain function from the static version (and keep
the original code when making a shared DLL)

With this minimal modification "import site" works as
usual even in an static linked version.

For your convenience the modified file can be found in
the attachement.
msg48870 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-02-19 15:48
Logged In: YES 

What does the Windows expert say?
msg90575 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-07-16 17:58
Do we want to support this? What is the use of a static build?
msg90577 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-07-16 18:37
I think it would be nice to support it, atleast in the C files (not
necessarily, but possibly, in the project files as well).

The point of a static Python library is that you can embed it into an
application without requiring an additional DLL. That also allows you to
leave out modules that you don't need at link time. Combine this with
freeze, and you can embed an application without any additional files to
be shipped. Without embedding, but with freeze, you get true standalone
binaries (as opposed to py2exe-fake-I-silently-extract-at-run-time
standalone binaries)
msg224513 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-08-01 18:55
Opinions from our Windows experts please.
msg321070 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2018-07-05 03:30
The patch is many years out of date by this point.  Does anyone know what it takes to create a static binary on Windows these days?
msg321103 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2018-07-05 13:36
Not sure, though I have thought about it a bit. And as with the embeddable package, I wouldn't want it finding a global install anyway. So this probably isn't an issue. (I'm pretty sure I also changed the version string to be statically initialised, so maybe this is fixed?)
Date User Action Args
2019-08-02 22:48:39steve.dowersetstatus: open -> closed
resolution: out of date
stage: test needed -> resolved
2018-07-05 13:36:39steve.dowersetmessages: + msg321103
2018-07-05 09:43:44BreamoreBoysetnosy: - BreamoreBoy
2018-07-05 03:30:09zach.waresetmessages: + msg321070
versions: + Python 3.8, - Python 2.7, Python 3.4, Python 3.5
2014-08-01 18:55:31BreamoreBoysetnosy: + BreamoreBoy, tim.golden, zach.ware, steve.dower

messages: + msg224513
versions: + Python 3.4, Python 3.5, - Python 3.1, Python 3.2
2010-08-22 01:06:03BreamoreBoysetversions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6
2009-07-16 18:37:25loewissetmessages: + msg90577
2009-07-16 17:58:57amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg90575
2009-03-20 22:59:33ajaksu2setpriority: normal -> low
stage: test needed
type: behavior
versions: + Python 2.6
2005-10-15 18:43:43babydoecreate