mirror of
https://github.com/samba-team/samba.git
synced 2025-01-03 01:18:10 +03:00
r26594: Add right paths to the Python sys.path setting so we don't have to set magic environment variables when running from the build directory.
(This used to be commit 2d2674ad79
)
This commit is contained in:
parent
7c146c42d2
commit
e8bca8dd71
@ -43,3 +43,11 @@ void py_load_samba_modules(void)
|
|||||||
PyImport_ExtendInittab(&py_modules[i]);
|
PyImport_ExtendInittab(&py_modules[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void py_update_path(const char *bindir)
|
||||||
|
{
|
||||||
|
char *newpath;
|
||||||
|
asprintf(&newpath, "%s:%s/python:%s/../scripting/python", Py_GetPath(), bindir, bindir);
|
||||||
|
PySys_SetPath(newpath);
|
||||||
|
free(newpath);
|
||||||
|
}
|
||||||
|
@ -21,9 +21,16 @@
|
|||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
|
||||||
void py_load_samba_modules(void);
|
void py_load_samba_modules(void);
|
||||||
|
void py_update_path(const char *bindir);
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
py_load_samba_modules();
|
py_load_samba_modules();
|
||||||
|
Py_Initialize();
|
||||||
|
if (strchr(argv[0], '/') != NULL) {
|
||||||
|
char *bindir = strndup(argv[0], strrchr(argv[0], '/')-argv[0]);
|
||||||
|
py_update_path(bindir);
|
||||||
|
free(bindir);
|
||||||
|
}
|
||||||
return Py_Main(argc,argv);
|
return Py_Main(argc,argv);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user