Change a way how .pyc are generated from .py

Now Makefile does the search of .py in the source.
Also change some dependencies between other modpython stuff.

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2224 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
darthgandalf
2010-12-30 23:45:12 +00:00
parent 4be057200b
commit 4c6d52c904
2 changed files with 38 additions and 22 deletions

View File

@@ -10,15 +10,27 @@
int main(int argc, char** argv) {
Py_Initialize();
int res = PyRun_SimpleString(
"import compileall\n"
"print('Optimizing python files for later use...')\n"
"import sys\n"
"if sys.version_info < (3, 2):\n"
" compileall.compile_dir('.')\n"
"else:\n"
" compileall.compile_dir('.', legacy=True)\n"
);
PyObject* pyModule = PyImport_ImportModule("py_compile");
if (!pyModule) {
PyErr_Print();
Py_Finalize();
return 1;
}
PyObject* pyFunc = PyObject_GetAttrString(pyModule, "compile");
Py_CLEAR(pyModule);
if (!pyFunc) {
PyErr_Print();
Py_Finalize();
return 2;
}
PyObject* pyRes = PyObject_CallFunction(pyFunc, const_cast<char*>("ss"), argv[1], argv[2]);
Py_CLEAR(pyFunc);
if (!pyRes) {
PyErr_Print();
Py_Finalize();
return 3;
}
Py_CLEAR(pyRes);
Py_Finalize();
return res;
return 0;
}