.lym file load order

Hi Matthias,

Do you know if there is an order to how files are loaded at KLayout start-up, specifically all the Python .lym files in different Technologies, Packages, etc. We've encountered challenges where the load order is different on Windows than Mac OSX, for example.

If I have three files:

pymacros/A.lym
pymacros/subfolder/B.lym
pymacros/subfoder/C.lym

do we know whether A would be always loaded before B and C?

thank you

Comments

  • Hi Lukas,

    the macros should be run in literal (case-sensitive, UTF-8 encoding) order, subfolders before local macros. So in your case, the order should be:

    pymacros/subfolder/B.lym
    pymacros/subfolder/C.lym
    pymacros/A.lym

    Me recommendation however is to use Python modules if you need to load dependencies. You'll just need to adjust sys.path if you like to lookup the modules relative to the main file.

    This is what I did: I replaced B.lym and C.lym by plain Python files (B.py, C.py) and inside A.lym I used:

    # A.lym:
    import sys
    import os
    # add <path of A.lym>/subfolder to search path
    sys.path.append(os.path.join(os.path.dirname(__file__), "subfolder"))
    
    import B
    import C
    

    This is make sure that B.py and C.py is read before A and you do not need to rely on a certain load order.

    Best regards,

    Matthias

Sign In or Register to comment.