diff options
| author | Jelmer Vernooij <jelmer@samba.org> | 2010-04-01 15:20:25 +0200 | 
|---|---|---|
| committer | Jelmer Vernooij <jelmer@samba.org> | 2010-04-01 15:33:07 +0200 | 
| commit | 84891b048d577e52da91c64d310f7bafa115d015 (patch) | |
| tree | 959c0794c00b484553ac876e21ee55cc3fa27d7c /source4/scripting/python | |
| parent | 64c564291d9ce60d934273aaac15150386d22127 (diff) | |
| download | samba-84891b048d577e52da91c64d310f7bafa115d015.tar.gz samba-84891b048d577e52da91c64d310f7bafa115d015.tar.bz2 samba-84891b048d577e52da91c64d310f7bafa115d015.zip | |
s4-python: Install external packages to a different directory but import into
the normal namespace when the system doesn't have it available.
Diffstat (limited to 'source4/scripting/python')
| -rw-r--r-- | source4/scripting/python/samba/__init__.py | 13 | 
1 files changed, 9 insertions, 4 deletions
| diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py index 87753b5a1d..50ecde2829 100644 --- a/source4/scripting/python/samba/__init__.py +++ b/source4/scripting/python/samba/__init__.py @@ -402,10 +402,15 @@ def ensure_external_module(modulename, location):      try:          __import__(modulename)      except ImportError: -        sys.path.insert(0,  -            os.path.join(os.path.dirname(__file__), -                         "../../../../lib", location)) -        __import__(modulename) +        import sys +        if _in_source_tree(): +            sys.path.insert(0,  +                os.path.join(os.path.dirname(__file__), +                             "../../../../lib", location)) +            __import__(modulename) +        else: +            sys.modules[modulename] = __import__( +                "samba.external.%s" % modulename, fromlist=["samba.external"])  version = glue.version | 
