From 7451edd83caf5882259cc84d1ba76dc39863d26e Mon Sep 17 00:00:00 2001 From: Lakshmi Vyasarajan Date: Mon, 20 Feb 2012 15:58:58 +0530 Subject: [PATCH] Issue #107: Added support for plugin paths relative to site. --- CHANGELOG.rst | 5 +++++ README.rst | 2 +- hyde/plugin.py | 2 +- hyde/util.py | 13 +++++++++---- hyde/version.py | 2 +- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4c066a7..2ba5176 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,8 @@ +Version 0.8.5a14 +============================================================ + +* Bug Fix: Added support for plugin paths relative to site. (Issue #107) + Version 0.8.5a13 ============================================================ diff --git a/README.rst b/README.rst index b0ccd31..2d4e737 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -Version 0.8.5a13 +Version 0.8.5a14 A brand new **hyde** ==================== diff --git a/hyde/plugin.py b/hyde/plugin.py index a8e0fc9..90e7e9f 100644 --- a/hyde/plugin.py +++ b/hyde/plugin.py @@ -326,7 +326,7 @@ class CLTransformer(Plugin): # Honour the PATH environment variable. if app_path is not None and not os.path.isabs(app_path): - app_path = discover_executable(app_path) + app_path = discover_executable(app_path, self.site.sitepath) if app_path is None: raise self.template.exception_class( diff --git a/hyde/util.py b/hyde/util.py index 5305553..e7d1fd3 100644 --- a/hyde/util.py +++ b/hyde/util.py @@ -124,12 +124,17 @@ def first_match(predicate, iterable): return item return None -def discover_executable(name): +def discover_executable(name, sitepath): """ - Finds an executable in the path list provided by the PATH - environment variable. + Finds an executable in the given sitepath or in the + path list provided by the PATH environment variable. """ - for path in os.environ['PATH'].split(os.pathsep): + + # Check if an executable can be found in the site path first. + # If not check the os $PATH for its presence. + + paths = [unicode(sitepath)] + os.environ['PATH'].split(os.pathsep) + for path in paths: full_name = os.path.join(path, name) if os.path.exists(full_name): return full_name diff --git a/hyde/version.py b/hyde/version.py index f00fd41..6e028af 100644 --- a/hyde/version.py +++ b/hyde/version.py @@ -3,4 +3,4 @@ Handles hyde version TODO: Use fabric like versioning scheme """ -__version__ = '0.8.5a13' +__version__ = '0.8.5a14'