Make trick (Python package) a namespace package

Namespace packages are a mechanism for splitting a single Python
package across multiple directories on disk. With the addition of
$(TRICK_HOME)/pymods/trick, there now exists a package named 'trick' at
$(TRICK_HOME)/pymods and in each SIM_* directory. This change allows sims
to import modules from both locations.

Refs #365
This commit is contained in:
Derek Bankieris 2017-01-20 09:49:55 -06:00
parent fc63f5c6b1
commit 4146b440b8
3 changed files with 5 additions and 0 deletions

View File

@ -377,6 +377,8 @@ py_%.cpp: %.i
}
open INITFILE , ">trick/__init__.py" or return ;
print INITFILE "from pkgutil import extend_path\n" ;
print INITFILE "__path__ = extend_path(__path__, __name__)\n" ;
print INITFILE "import sys\n" ;
print INITFILE "import os\n" ;
print INITFILE "sys.path.append(os.getcwd() + \"/trick\")\n" ;

View File

@ -0,0 +1,2 @@
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)

View File

@ -103,6 +103,7 @@ int Trick::IPPython::init() {
"import struct\n"
"import binascii\n"
"sys.path.append(os.getcwd())\n"
"sys.path.append(os.path.join(os.environ['TRICK_HOME'], 'pymods'))\n"
"sys.path += map(str.strip, os.environ['TRICK_PYTHON_PATH'].split(':'))\n"
"import trick\n"
"sys.path.append(os.getcwd() + \"/Modified_data\")\n"