diff --git a/PC/bdist_wininst/install.c b/PC/bdist_wininst/install.c --- a/PC/bdist_wininst/install.c +++ b/PC/bdist_wininst/install.c @@ -271,7 +271,7 @@ static int do_compile_files(int (__cdecl while (p) { ++n; wsprintf(Buffer, - "import py_compile; py_compile.compile (r'%s')", + "import py_compile; py_compile.compile(r'%s')", p->path); if (PyRun_SimpleString(Buffer)) { ++errors; @@ -280,8 +280,18 @@ static int do_compile_files(int (__cdecl * be created so that the uninstaller will remove them * in case they are created later. */ - wsprintf(Buffer, "%s%c", p->path, optimize ? 'o' : 'c'); + wsprintf(Buffer, + "import imp; imp.cache_from_source(r'%s')", + p->path); + if (PyRun_SimpleString(Buffer)) { + ++errors; + } notify(FILE_CREATED, Buffer); + /* Register the directory after the files, so that it's + * removed when empty. + */ + wsprintf(Buffer, "%s\\__pycache__", p->path); + notify(DIR_CREATED, Buffer); SendDlgItemMessage(hDialog, IDC_PROGRESS, PBM_SETPOS, n, 0); SetDlgItemText(hDialog, IDC_INFO, p->path);