[GRASS-SVN] r67894 - grass/trunk/lib/python/script
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Feb 20 02:04:53 PST 2016
Author: martinl
Date: 2016-02-20 02:04:53 -0800 (Sat, 20 Feb 2016)
New Revision: 67894
Modified:
grass/trunk/lib/python/script/utils.py
Log:
pythonlib: fix get_lib_path() for g.extension
Modified: grass/trunk/lib/python/script/utils.py
===================================================================
--- grass/trunk/lib/python/script/utils.py 2016-02-20 10:03:04 UTC (rev 67893)
+++ grass/trunk/lib/python/script/utils.py 2016-02-20 10:04:53 UTC (rev 67894)
@@ -268,7 +268,7 @@
def get_lib_path(modname, libname=None):
"""Return the path of the libname contained in the module.
"""
- from os.path import isdir, join
+ from os.path import isdir, join, sep
from os import getenv
if isdir(join(getenv('GISBASE'), 'etc', modname)):
@@ -282,15 +282,16 @@
elif getenv('GRASS_ADDON_BASE') and \
isdir(join(getenv('GRASS_ADDON_BASE'), modname, modname)):
path = join(os.getenv('GRASS_ADDON_BASE'), modname, modname)
- elif libname and isdir(join('..', libname)): # used by g.extension compilation process
- path = join('..', libname)
- elif isdir(join('..', 'etc', modname)): # used by g.extension compilation process
- path = join('..', 'etc', modname)
- elif isdir(join('etc', modname)): # used by g.extension compilation process
- path = join('etc', modname)
else:
- path = None
-
+ # used by g.extension compilation process
+ cwd = os.getcwd()
+ idx = cwd.find(modname)
+ if idx < 0:
+ return None
+ path = cwd[:idx+len(modname)] + sep + 'etc' + sep + modname
+ if libname:
+ path = join(path, libname)
+
return path
@@ -368,4 +369,5 @@
pathname = os.path.join(modulename, dirname) if dirname else modulename
raise ImportError("Not able to find the path '%s' directory "
"(current dir '%s')." % (pathname, os.getcwd()))
- sys.path.append(path)
+
+ sys.path.insert(0, path)
More information about the grass-commit
mailing list