Author rutski
Recipients rutski
Date 2017-08-10.07:23:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1502349831.97.0.859885233288.issue31172@psf.upfronthosting.co.za>
In-reply-to
Content
Install Visual Studio 2017

Download and unpack Python-3.6.2.tgz

Open a Visual Studio command prompt
Browse to Python-3.6.2\PCBuild
Run build.bat -p x64 -c Release
Run build.bat -p x64 -c Debug
Add the PCbuild\amd64 directory to your PATH

Create a new Visual Studio Win32 GUI project called mypythonw

Copy-paste the source code of Python-3.6.2\PCBuild\WinMain.c into your mypthonw project.

Add Python-3.6.2\Include and Python-3.6.2\PC to mypythonw's include path.

Add Python-3.6.2\PCbuild\amd64 to mypythonw's library search path

Build mypthonw

Run these two commands:

pythonw -c "import ctypes; ctypes.windll.user32.MessageBoxW(0, 'Hello World!', 'Hello', 0)

mypythonw -c "import ctypes; ctypes.windll.user32.MessageBoxW(0, 'Hello World!', 'Hello', 0)

The first will show a message box, while the second will show nothing. You won't get an error message or a debugger from mypythonw.exe. It'll just silently do nothing.

There must be something in the configuration of pythonw.vcxproj that is necessary for Python embedding to work, and which makes it work in pythonw but fail in mypythonw. The two projects are executing the exact same C code, but one works and the other doesn't. What's going on here?
History
Date User Action Args
2017-08-10 07:23:52rutskisetrecipients: + rutski
2017-08-10 07:23:51rutskisetmessageid: <1502349831.97.0.859885233288.issue31172@psf.upfronthosting.co.za>
2017-08-10 07:23:51rutskilinkissue31172 messages
2017-08-10 07:23:51rutskicreate