[Python Plugin] Having Problems With PYTHONPATH/sys.path

All:

I am trying to figure out how the the Perforce plugin is setting the sys.path and how to get it set correctly.

I am developing a python module that has the following basic structure:
Project Root
      - abt
          - __import__.py
          - Utilities
               - __import__.py
               - ScriptTemplate.py
          - Tests
               - __import__.py
               - Test.py

The Test.py includes the following import:
import abt.Utilities.ScriptTemplate

I have defined a runtime with two basic configuration:

  • script:  Project Root/abt/Tests/Test.py
  • working directory: Project Root


When I run this configuration it fails with an unable to import the abt.Utilities.ScriptTemplate

When I dump out the sys.path being used I notice that it is being set to Project Root/Tests rather than the expected Project Root - in other words the sys.path is being set to the absolute location of the script being run rather than either the set working directory or the root directory of the project. Further, attempting to set PYTHONPATH as an environment variable does nothing

Anyone know what is going on here - bug or fundamental misunderstanding on my part.

Any ideas on how to fix?

Thanks

-steve

Steve Nesbitt

Please sign in to leave a comment.