From 56ea9de16ee2130bf85a789e69e9c16e3b77e240 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 16 Jun 2014 16:22:24 -0400 Subject: [PATCH] prepend PWD to PYTHONPATH --- devsupApp/src/setup.c | 12 ++++++++++++ documentation/environment.rst | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/devsupApp/src/setup.c b/devsupApp/src/setup.c index 34b3734..1731f08 100644 --- a/devsupApp/src/setup.c +++ b/devsupApp/src/setup.c @@ -371,7 +371,19 @@ static void setupPyPath(void) Py_XDECREF(mod); if(path) { + PyObject *cur; + char cwd[PATH_MAX]; + insertDefaultPath(path); + + /* prepend current directory */ + if(getcwd(cwd, sizeof(cwd)-1)) { + cwd[sizeof(cwd)-1] = '\0'; + cur = PyString_FromString(cwd); + if(cur) + PyList_Insert(path, 0, cur); + Py_XDECREF(cur); + } } Py_XDECREF(path); } diff --git a/documentation/environment.rst b/documentation/environment.rst index b01e2f8..785dd86 100644 --- a/documentation/environment.rst +++ b/documentation/environment.rst @@ -27,9 +27,10 @@ PYTHONPATH The interpreter search path is automatically prefixed with the following additional paths: -* ``$(EPICS_BASE)/python/$(EPICS_ARCH)`` -* ``$(PYDEV_BASE)/python/$(EPICS_ARCH)`` +* ``${PWD}`` * ``$(TOP)/python/$(EPICS_ARCH)`` +* ``$(PYDEV_BASE)/python/$(EPICS_ARCH)`` +* ``$(EPICS_BASE)/python/$(EPICS_ARCH)`` The environment variables ``EPICS_BASE``, ``PYDEV_BASE``, ``TOP``, and ``EPICS_ARCH`` will be used if set. Compile time defaults are selected for