from self_module import module

Hi Matt,
Can I import self defined module in different python file in klayout batch mode?
Something like below usage

from self_module import module   # import self defined module in different python file


BG,
KM

Comments

  • edited June 2020

    Sure, you can.

    In order to locate the file, either put it into one of the Python locations, KLayout offers. Or set the "KLAYOUT_PYTHONPATH" environment variable to point to your module (same as PYTHONPATH for the normal Python interpreter).

    Finally, you can also add your module's location to "sys.path" inside your code.

    It's getting more difficult if your module involves binary extensions. In this case, the extension needs to be compatible with KLayout's build (same runtime etc.).

    Matthias

Sign In or Register to comment.