Skip to content

Commit ab60709

Browse files
authored
Add python virtual environment path to Input processor search path #1944 (#1945)
Added an if check before in the python code run before the input file and test if the VIRTUAL_ENV environment variable is set. If it is, add the path ${VIRTUAL_ENV}/python_<version>/site-packages to sys.path list.
1 parent a5fd0ec commit ab60709

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

trick_source/sim_services/InputProcessor/IPPython.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ int Trick::IPPython::init() {
111111
"import os\n"
112112
"import struct\n"
113113
"import binascii\n"
114+
"if 'VIRTUAL_ENV' in os.environ:\n"
115+
" sys.path.append(os.path.join(os.environ['VIRTUAL_ENV'], \"lib\", f\"python{sys.version_info.major}.{sys.version_info.minor}\", \"site-packages\"))\n"
114116
"sys.path.append(os.getcwd() + '/trick.zip')\n"
115117
"sys.path.append(os.path.join(os.environ['TRICK_HOME'], 'share/trick/pymods'))\n"
116118
"sys.path += map(str.strip, os.environ['TRICK_PYTHON_PATH'].split(':'))\n"

0 commit comments

Comments
 (0)