1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-04 08:22:08 +03:00

s4-python Don't force "bin" into the python sys.path

This patch uses the fact that dyn_PYTHONDIR and dyn_PYTHONARCHDIR is
now set properly at all times, incluidng for installed and
build-directory binaries.  So we don't need to make assumptions about
bin being magic any more.

Andrew Bartlett
This commit is contained in:
Andrew Bartlett
2011-02-05 18:00:45 +11:00
committed by Andrew Tridgell
parent 19c3546872
commit 15d0166340
5 changed files with 8 additions and 25 deletions

View File

@ -84,7 +84,7 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
DEBUG(0,("Provision for Become-DC test using python\n")); DEBUG(0,("Provision for Become-DC test using python\n"));
Py_Initialize(); Py_Initialize();
py_update_path("bin"); /* FIXME: Can't assume this is always the case */ py_update_path(); /* Put the samba path at the start of sys.path */
provision_mod = provision_module(); provision_mod = provision_module();
@ -240,7 +240,7 @@ NTSTATUS provision_store_self_join(TALLOC_CTX *mem_ctx, struct loadparm_context
} }
Py_Initialize(); Py_Initialize();
py_update_path("bin"); /* FIXME: Can't assume this is always the case */ py_update_path(); /* Put the samba path at the start of sys.path */
provision_mod = provision_module(); provision_mod = provision_module();
if (provision_mod == NULL) { if (provision_mod == NULL) {
@ -336,7 +336,7 @@ struct ldb_context *provision_get_schema(TALLOC_CTX *mem_ctx, struct loadparm_co
PyObject *schema_mod, *schema_dict, *schema_fn, *py_result, *parameters; PyObject *schema_mod, *schema_dict, *schema_fn, *py_result, *parameters;
Py_Initialize(); Py_Initialize();
py_update_path("bin"); /* FIXME: Can't assume this is always the case */ py_update_path(); /* Put the samba path at the start of sys.path */
schema_mod = schema_module(); schema_mod = schema_module();

View File

@ -308,7 +308,7 @@ static int binary_net(int argc, const char **argv)
} }
Py_Initialize(); Py_Initialize();
PySys_SetArgv(argc, discard_const_p(char *, argv)); PySys_SetArgv(argc, discard_const_p(char *, argv));
py_update_path("bin"); /* FIXME: Can't assume this is always the case */ py_update_path(); /* Put the Samba path at the start of sys.path */
py_cmds = py_commands(); py_cmds = py_commands();
if (py_cmds == NULL) { if (py_cmds == NULL) {

View File

@ -31,7 +31,7 @@ static bool PySys_PathPrepend(PyObject *list, const char *path)
return (PyList_Insert(list, 0, py_path) == 0); return (PyList_Insert(list, 0, py_path) == 0);
} }
bool py_update_path(const char *bindir) bool py_update_path()
{ {
char *newpath; char *newpath;
PyObject *mod_sys, *py_path; PyObject *mod_sys, *py_path;
@ -58,23 +58,5 @@ bool py_update_path(const char *bindir)
return false; return false;
} }
if (asprintf(&newpath, "%s/../scripting/python", bindir) < 0) {
return false;
}
if (!PySys_PathPrepend(py_path, newpath)) {
free(newpath);
return false;
}
free(newpath);
if (asprintf(&newpath, "%s/python", bindir) < 0) {
return false;
}
if (!PySys_PathPrepend(py_path, newpath)) {
free(newpath);
return false;
}
free(newpath);
return true; return true;
} }

View File

@ -20,6 +20,6 @@
#ifndef __SAMBA_PYTHON_MODULES_H__ #ifndef __SAMBA_PYTHON_MODULES_H__
#define __SAMBA_PYTHON_MODULES_H__ #define __SAMBA_PYTHON_MODULES_H__
bool py_update_path(const char *bindir); bool py_update_path();
#endif /* __SAMBA_PYTHON_MODULES_H__ */ #endif /* __SAMBA_PYTHON_MODULES_H__ */

View File

@ -385,7 +385,8 @@ bool wsgi_initialize(struct web_server_data *wdata)
Py_Initialize(); Py_Initialize();
py_update_path("bin"); /* FIXME: Can't assume this is always the case */ py_update_path(); /* Ensure that we have the Samba paths at
* the start of the sys.path() */
if (PyType_Ready(&web_request_Type) < 0) if (PyType_Ready(&web_request_Type) < 0)
return false; return false;