summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-02-05 18:00:45 +1100
committerAndrew Tridgell <tridge@samba.org>2011-02-07 13:22:02 +1100
commit15d0166340baea91f117ea977539894e7444ee6b (patch)
tree65838dc452590393024dd487af488417c0b5351f
parent19c3546872216980ff49e5b3dbffb01433c07552 (diff)
downloadsamba-15d0166340baea91f117ea977539894e7444ee6b.tar.gz
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
-rw-r--r--source4/param/provision.c6
-rw-r--r--source4/samba_tool/samba_tool.c2
-rw-r--r--source4/scripting/python/modules.c20
-rw-r--r--source4/scripting/python/modules.h2
-rw-r--r--source4/web_server/wsgi.c3
5 files changed, 8 insertions, 25 deletions
diff --git a/source4/param/provision.c b/source4/param/provision.c
index e4236a59c5a..7b6e6e74b35 100644
--- a/source4/param/provision.c
+++ b/source4/param/provision.c
@@ -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"));
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();
@@ -240,7 +240,7 @@ NTSTATUS provision_store_self_join(TALLOC_CTX *mem_ctx, struct loadparm_context
}
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();
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;
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();
diff --git a/source4/samba_tool/samba_tool.c b/source4/samba_tool/samba_tool.c
index da08a716ce1..411eb6d98d1 100644
--- a/source4/samba_tool/samba_tool.c
+++ b/source4/samba_tool/samba_tool.c
@@ -308,7 +308,7 @@ static int binary_net(int argc, const char **argv)
}
Py_Initialize();
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();
if (py_cmds == NULL) {
diff --git a/source4/scripting/python/modules.c b/source4/scripting/python/modules.c
index 960239e8636..f2a45a98932 100644
--- a/source4/scripting/python/modules.c
+++ b/source4/scripting/python/modules.c
@@ -31,7 +31,7 @@ static bool PySys_PathPrepend(PyObject *list, const char *path)
return (PyList_Insert(list, 0, py_path) == 0);
}
-bool py_update_path(const char *bindir)
+bool py_update_path()
{
char *newpath;
PyObject *mod_sys, *py_path;
@@ -58,23 +58,5 @@ bool py_update_path(const char *bindir)
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;
}
diff --git a/source4/scripting/python/modules.h b/source4/scripting/python/modules.h
index 7c15fecabef..4e43e6de1dd 100644
--- a/source4/scripting/python/modules.h
+++ b/source4/scripting/python/modules.h
@@ -20,6 +20,6 @@
#ifndef __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__ */
diff --git a/source4/web_server/wsgi.c b/source4/web_server/wsgi.c
index 2f47af2d257..37ded294801 100644
--- a/source4/web_server/wsgi.c
+++ b/source4/web_server/wsgi.c
@@ -385,7 +385,8 @@ bool wsgi_initialize(struct web_server_data *wdata)
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)
return false;