Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit 672fc3c

Browse files
authored
Merge pull request #24 from apiaryio/wvi/import-fix
Fixes import submodules in hooks files
2 parents 550d600 + 5c897ab commit 672fc3c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

dredd_hooks/dredd.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ def load_hook_files(pathname):
124124

125125
fsglob = glob.iglob(pathname)
126126
for path in fsglob:
127-
module = imp.load_source(os.path.basename(path), path)
127+
real_path = os.path.realpath(path)
128+
# Append hooks file directory to the sys.path so submodules can be
129+
# loaded too.
130+
if os.path.dirname(real_path) not in sys.path:
131+
sys.path.append(os.path.dirname(real_path))
132+
module = imp.load_source(os.path.basename(path), real_path)
128133
for name in dir(module):
129134
obj = getattr(module, name)
130135
if hasattr(obj, 'dredd_hooks') and callable(obj):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name='dredd_hooks',
9-
version='0.1.0',
9+
version='0.1.1',
1010
url='https://github.com/apiaryio/dredd-hooks-python/',
1111
download_url='http://pypi.python.org/pypi/dredd_hooks',
1212
license='MIT License',

0 commit comments

Comments
 (0)