Why does setup_python_env.sh include the root directory into PYTHONPATH?

Isaac Sim Version

4.5.0

Operating System

Ubuntu 22.04

Topic Description

Detailed Description

The file setup_python_env.sh contains the following:

export PYTHONPATH=$PYTHONPATH:$SCRIPT_DIR/../../../$PYTHONPATH:$SCRIPT_DIR/kit/python/lib/python3.10:<more_paths...>

Since Isaac Sim is supposed to be installed in $HOME/isaacsim, if PYTHONPATH is empty beforehand, this segment $SCRIPT_DIR/../../../$PYTHONPATH will end up adding the root directory / into PYTHONPATH. Then this means I can import the root path subfolders as packages, e.g.:

user@machine ~/isaacsim$ ./python.sh
Python 3.10.15 (tags/v3.10.15-dirty:ffee63f, Oct  8 2024, 18:53:10) [GCC 7.3.1 20180303 (Red Hat 7.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import opt
>>>

The root folder is also visible in sys.path:

>>> import sys
>>> print(sys.path)
['', '/home/user/isaacsim', '/', ...] 

This can introduce package import conflicts and confusing behavior depending on the names of subfolders under /. Is there any reason for this entry into PYTHONPATH? Also, the LD_LIBRARY_PATH suffers from the same.

Thanks for raising this issue and for the detailed analysis. I will create an internal ticket to address this in a future release. In the meantime, you can safely update your local script.