From 4dbd088fd7bf72c9c58bebc929256d635e526582 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Wed, 8 Jun 2011 09:53:42 +0700 Subject: [PATCH] Support compiling python modules in cwd --- modules/modpython/compiler.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/modpython/compiler.cpp b/modules/modpython/compiler.cpp index a8b1718d..63806469 100644 --- a/modules/modpython/compiler.cpp +++ b/modules/modpython/compiler.cpp @@ -7,6 +7,7 @@ */ #include +#include void fail(PyObject* py, int n) { // Doesn't clear any variables, but meh, finalize anyway... @@ -27,7 +28,11 @@ int main(int argc, char** argv) { PyObject* pyFunc = PyObject_GetAttrString(pyModule, "compile"); fail(pyFunc, 2); - PyObject* pyKW = Py_BuildValue("{sssN}", "cfile", argv[2], "doraise", Py_True); + std::string cfile = argv[2]; + if (cfile.find('/') == std::string::npos) { + cfile = "./" + cfile; + } + PyObject* pyKW = Py_BuildValue("{sssN}", "cfile", cfile.c_str(), "doraise", Py_True); fail(pyKW, 3); PyObject* pyArg = Py_BuildValue("(s)", argv[1]);