@@ -99,6 +99,9 @@ bool PyStand::CheckEnviron(const wchar_t *rtp)
99
99
100
100
// init: _pystand (full path of PyStand.exe)
101
101
GetModuleFileNameW (NULL , path, MAX_PATH + 1 );
102
+ #if 0
103
+ wsprintf(path, L"e:\\github\\tools\\pystand\\pystand.exe");
104
+ #endif
102
105
_pystand = path;
103
106
104
107
// init: _home
@@ -201,23 +204,23 @@ int PyStand::RunString(const wchar_t *script)
201
204
}
202
205
int hr = 0 ;
203
206
int i;
204
- std::vector<std::wstring> argv ;
207
+ _py_argv. resize ( 0 ) ;
205
208
// init arguments
206
- argv .push_back (_argv[0 ]);
207
- argv .push_back (L" -I" );
208
- argv .push_back (L" -s" );
209
- argv .push_back (L" -S" );
210
- argv .push_back (L" -c" );
211
- argv .push_back (script);
209
+ _py_argv .push_back (_argv[0 ]);
210
+ _py_argv .push_back (L" -I" );
211
+ _py_argv .push_back (L" -s" );
212
+ _py_argv .push_back (L" -S" );
213
+ _py_argv .push_back (L" -c" );
214
+ _py_argv .push_back (script);
212
215
for (i = 1 ; i < (int )_argv.size (); i++) {
213
- argv .push_back (_argv[i]);
216
+ _py_argv .push_back (_argv[i]);
214
217
}
215
218
// finalize arguments
216
- std::vector< wchar_t *> real_argv ;
217
- for (i = 0 ; i < (int )argv .size (); i++) {
218
- real_argv .push_back ((wchar_t *)argv [i].c_str ());
219
+ _py_args. resize ( 0 ) ;
220
+ for (i = 0 ; i < (int )_py_argv .size (); i++) {
221
+ _py_args .push_back ((wchar_t *)_py_argv [i].c_str ());
219
222
}
220
- hr = _Py_Main ((int )argv .size (), &real_argv [0 ]);
223
+ hr = _Py_Main ((int )_py_args .size (), &_py_args [0 ]);
221
224
return hr;
222
225
}
223
226
@@ -300,12 +303,9 @@ const char *init_script =
300
303
" sys.path.append(os.path.abspath(PYSTAND_HOME))\n "
301
304
" sys.argv = [PYSTAND_SCRIPT] + sys.argv[1:]\n "
302
305
" text = open(PYSTAND_SCRIPT).read()\n "
303
- " environ = {'__file__': PYSTAND_SCRIPT}\n "
304
- " saveloc = copy.copy(locals())\n "
305
- " for k in saveloc:\n "
306
- " if k.startswith('__'):\n "
307
- " environ[k] = saveloc[k]\n "
308
- " exec(text, globals(), environ)\n "
306
+ " environ = {'__file__': PYSTAND_SCRIPT, '__name__': '__main__'}\n "
307
+ " environ['__package__'] = None\n "
308
+ " exec(text, environ)\n "
309
309
" " ;
310
310
311
311
@@ -317,14 +317,15 @@ const char *init_script =
317
317
// ! src:
318
318
// ! mode: win
319
319
// ! int: objs
320
- int APIENTRY
320
+ int WINAPI
321
321
WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR args, int show)
322
322
{
323
323
PyStand ps (" runtime" );
324
324
if (ps.DetectScript () != 0 ) {
325
325
return 3 ;
326
326
}
327
327
if (AttachConsole (ATTACH_PARENT_PROCESS)) {
328
+ #if 0
328
329
freopen("CONOUT$", "w", stdout);
329
330
freopen("CONOUT$", "w", stderr);
330
331
freopen("CONIN$", "r", stdin);
@@ -338,6 +339,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR args, int show)
338
339
std::string fn = std::to_string(fd);
339
340
SetEnvironmentVariableA("PYSTAND_STDIN", fn.c_str());
340
341
}
342
+ #endif
341
343
}
342
344
int hr = ps.RunString (init_script);
343
345
// printf("finalize\n");
0 commit comments