This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: bdist_wininst should not depend on the vc runtime?
Type: Stage:
Components: Distutils Versions: Python 3.0, Python 3.1, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: mhammond Nosy List: loewis, mhammond
Priority: normal Keywords: patch

Created on 2009-01-27 05:00 by mhammond, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bug-5075.patch mhammond, 2009-01-28 02:17 link a static copy of the CRT and use the win32 api to redirect std handles
Messages (7)
msg80620 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2009-01-27 05:00
After consideration of issue 4120 and issue 4566, it seems to me that
executables created by bdist_wininst will have a manifest referencing
the MSVC9 assembly, and thus will be in a similar position to the .pyd
files in issue 4120 - that unless the assembly is installed globally or
next to the executable itself, the executable will not start.  Note that
I have not verified this, but have verified the final installer
executable references the CRT assembly, and given those other bugs,
expect it to be true.

It seems to me a reasonable solution would be to have the bdist_wininst
stub use a static copy of the C runtime library.  While this means 2
copies of the CRT will eventually be loaded and would otherwise be
considered evil, the way the stub dynamically loads Python and the few
API functions it uses means it might be reasonable in this case.  Would
the trivial patch which achieves this be desired?
msg80631 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-01-27 07:23
I think it would be even better if it didn't link with the CRT at all,
but until somebody provides a patch for that, linking statically sounds
fine to me.
msg80640 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2009-01-27 10:14
Ironically I just received personal mail:

"""I have downloaded pywin32_212 [2.6] three times today. the download
completes successfully. but on running the pywin installer i repeatedly
get an error."""

Attached is a screen-shot of the error dialog
"pywin32-212-win32-py2.6.exe...has failed to start because the
application configuration is incorrect..."""

My apologies for not being more on top of this, but I couldn't find the
answer in the developer FAQ.  This question applies to issue 4566 and
will partially apply to issue 5076.  The patches are against the trunk -
after checking in, what action should I take to ensure it is merged to
2.6 and 3.x?  I'm happy to manually merge and checkin to those branches
if appropriate; if so, should I check it into branches/release30-maint
as well as branches/py3k?

Thanks
msg80663 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-01-27 17:53
> My apologies for not being more on top of this, but I couldn't find the
> answer in the developer FAQ.  This question applies to issue 4566 and
> will partially apply to issue 5076.  The patches are against the trunk -
> after checking in, what action should I take to ensure it is merged to
> 2.6 and 3.x?  I'm happy to manually merge and checkin to those branches
> if appropriate; if so, should I check it into branches/release30-maint
> as well as branches/py3k?

If you want to backport the changes yourself, you should run
svnmerge.py; not sure how well this works on Windows, though (it invokes
an svn binary). The merge flow would be

  trunk -> release26-maint
       \-> py3k -> release30-maint

It's important to use svnmerge only, so that the merge tracking
properties are right.

In 2.6, do "svnmerge.py merge -r<rev>", then "svn commit -F
svnmerge-<tab>". In 3k, do the same, although you might have
to recompile the stubs in-between in case there are merge
conflicts on the binary files. In 3.0, do the same, but you
need to "svn revert .", because there will be merge conflicts
on ".".

If you don't want to perform all these operations, let me know,
and I'll do them.
msg80687 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2009-01-28 02:17
Thanks for the merging advice!

The patch to the build system is indeed trivial - unfortunately it also
failed to work correctly due to install.c using freopen, a CRT function,
to redirect the output.  Interestingly, this probably means that if
someone attempted to use python 2.6 to create a pure-python .exe
installer, they would fail to see any output when installed to earlier
Python versions (and vice-versa...)

I've worked up a patch for install.c which uses the win32 API to achieve
the same result using SetStdHandle() etc.  This technique requires the
handles to be redirected before the Python DLL is loaded, so I took the
opportunity to refactor things a little - we now have 2 locations that
perform the redirection instead of 3 but I didn't see huge benefit in
trying to knock that down to 1.

The patch is against the trunk but should also be applied to 2.6 and the
3.x branches.  I've tested the new code-paths using a 32bit trunk build
only but it should work the same everywhere.
msg80724 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-01-28 19:52
Looks fine to me, please apply.

As all the IO is done with Win32 directly, you might as well call
DeleteFile instead of remove (unless I miss something).
msg80760 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2009-01-29 12:42
Checked into trunk as r69094; merged to release26-maint as r69095, py3k
as r69096 and release30-maint as r69097.
History
Date User Action Args
2022-04-11 14:56:44adminsetgithub: 49325
2009-01-29 12:42:30mhammondsetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg80760
2009-01-28 19:52:05loewissetkeywords: - needs review
resolution: accepted
messages: + msg80724
2009-01-28 02:17:46mhammondsetkeywords: + patch, needs review
files: + bug-5075.patch
messages: + msg80687
2009-01-27 17:53:05loewissetmessages: + msg80663
2009-01-27 10:14:56mhammondsetmessages: + msg80640
2009-01-27 07:23:59loewissetnosy: + loewis
messages: + msg80631
2009-01-27 05:00:31mhammondcreate