mirror of
https://github.com/samba-team/samba.git
synced 2025-07-29 15:42:04 +03:00
s4-python: Install external packages to a different directory but import into
the normal namespace when the system doesn't have it available.
This commit is contained in:
@ -83,12 +83,13 @@ cp setup/provision.smb.conf.standalone $SETUPDIR || exit 1
|
||||
|
||||
echo "Installing external python libraries"
|
||||
mkdir -p $DESTDIR$PYTHONDIR || exit 1
|
||||
for p in $($PYTHON scripting/python/samba_external/missing.py);
|
||||
MISSING="$($PYTHON scripting/python/samba_external/missing.py)"
|
||||
for p in $MISSING
|
||||
do
|
||||
package=`basename $p`
|
||||
echo "Installing missing python package $package"
|
||||
mkdir -p $DESTDIR$PYTHONDIR/$package
|
||||
cp -r ../lib/$p/* $DESTDIR$PYTHONDIR/$package/ || exit 1
|
||||
mkdir -p $DESTDIR$PYTHONDIR/samba/external/$package
|
||||
cp -r ../lib/$p/* $DESTDIR$PYTHONDIR/samba/external/$package/ || exit 1
|
||||
done
|
||||
|
||||
echo "Installing stuff in $PRIVATEDIR"
|
||||
|
@ -38,7 +38,7 @@ from samba import glue
|
||||
from samba.auth import system_session
|
||||
from samba.samdb import SamDB
|
||||
|
||||
samba.ensure_external_module("dns.resolver", "dnspython")
|
||||
samba.ensure_external_module("dns", "dnspython")
|
||||
import dns.resolver as resolver
|
||||
|
||||
default_ttl = 900
|
||||
|
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user