Re: [Python-Dev] Py_Main() seems to be a NOOP

2017-08-10 Thread Terry Reedy

On 8/10/2017 3:26 AM, Patrick Rutkowski wrote:

On Thu, Aug 10, 2017 at 2:26 AM, Patrick Rutkowski
 wrote:

I'm working on Windows with Python 3.6. I'm trying to make a wWinMain() GUI
application that uses an embedded python interpreter. I'm having various
issues with being unable to load extension modules, but I won't go into that
now because I've tracked my issue down to a much simpler test case.

To begin, consider the source code of pythonw.exe...


Follow up. Filed a bug in the python issue tracker:
https://mail.google.com/mail/u/0/#inbox/15dcb0731f605c44


This returns a solicitation for gmail.  Try
https://bugs.python.org/issue31172
instead.

--
Terry Jan Reedy

___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Py_Main() seems to be a NOOP

2017-08-10 Thread Patrick Rutkowski
On Thu, Aug 10, 2017 at 2:26 AM, Patrick Rutkowski
 wrote:
> I'm working on Windows with Python 3.6. I'm trying to make a wWinMain() GUI
> application that uses an embedded python interpreter. I'm having various
> issues with being unable to load extension modules, but I won't go into that
> now because I've tracked my issue down to a much simpler test case.
>
> To begin, consider the source code of pythonw.exe...

Follow up. Filed a bug in the python issue tracker:
https://mail.google.com/mail/u/0/#inbox/15dcb0731f605c44
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Py_Main() seems to be a NOOP

2017-08-10 Thread Patrick Rutkowski
I'm working on Windows with Python 3.6. I'm trying to make a wWinMain() GUI
application that uses an embedded python interpreter. I'm having various
issues with being unable to load extension modules, but I won't go into that
now because I've tracked my issue down to a much simpler test case.

To begin, consider the source code of pythonw.exe:

/* Minimal main program -- everything is loaded from the library. */

#include "Python.h"

#define WIN32_LEAN_AND_MEAN
#include 

int WINAPI wWinMain(
HINSTANCE hInstance,  /* handle to current instance */
HINSTANCE hPrevInstance,  /* handle to previous instance */
LPWSTR lpCmdLine, /* pointer to command line */
int nCmdShow  /* show state of window */
)
{
return Py_Main(__argc, __wargv);
}

Now consider a simple python script, which I save in source.py

f = open('C:\\Users\\rutski\\Desktop\\hello.txt', 'w')
f.write('Hello World!\n')
f.flush()
f.close()

and run with

> pythonw.exe source.py

This produces the file `hello.txt` with the expected output. Now I create a
new Visual Studio solution. I make it Win32 project, choose "Windows
Application" and "Empty Project." I create a new source file main.c and I
copy-paste the source code of from pythonw (with Py_Main and all that). Now I
add the following settings:

C:\Users\rutski\Documents\python\PCbuild\amd64 --- Library Search Directory
C:\Users\rutski\Documents\python\Include   --- Include Directory
C:\Users\rutski\Documents\python\PC--- Include
Directory (for pyconfig.h)

I choose "Debug | x64" and hit build. I pop open cmd.exe, browse to where
mything.exe is, and execute

> mything.exe source.py

But this time nothing happens. No hello.txt gets created. I get no crash
window or error message. I do not get thrown into a debugger. I just get no
result. Am I missing some build flags here or something?

I'm running the __exact__ same C code that pythonw.exe is, but mine isn't
working. What gives?

I can't even seem to get Py_Main() to execute some python code from within my
own application, so trying to write my own embed code is basically hopeless.

If anybody could shed any light on this it would be much appreciated!
-Patrick
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com