diff --git a/src/lay/doc/programming/python.xml b/src/lay/doc/programming/python.xml index 1f9deb1f8..981b4c69f 100644 --- a/src/lay/doc/programming/python.xml +++ b/src/lay/doc/programming/python.xml @@ -33,14 +33,15 @@

The Python macro folder is in the "sys.path" search path so it is possible to install modules - there. To install libraries globally use "%INST_PATH%/lib/python/Lib" and "%INST_PATH%/lib/python/DLLs" on - Windows. %INST_PATH% is the installation path (where klayout.exe is located). On Linux, the + there. To install libraries globally use "inst_path/lib/python/Lib" and "inst_path/lib/python/DLLs" on + Windows. inst_path is the installation path (where klayout.exe is located). On Linux, the installation will share the Python interpreter with the system and modules installed there will be available for KLayout too.

- "$PYTHONPATH" is supported in the usual way. + "$PYTHONHOME" is not supported to prevent interference with other Python consumers. Instead, KLayout will + read the Python path from "$KLAYOUT_PYTHONPATH" (for Python >= 3.x).

Writing Macros in Python

@@ -101,14 +102,13 @@ layout.write("t.gds")

There is no clear advantage of one language over the other. The Python community is somewhat stronger, but performance-wise, Ruby is better. - In KLayout, the debugger support for Python is a little better, since the guts - of the interpreter are well documented in Python. For example, it is possible - to evaluate expressions in the context of the current stack frame. + In KLayout, the debugger support for Python is slighly better, since the guts + of the interpreter are better documented for Python.

- Apart from that, Python and Ruby coexist remarkably well and it was amazing, how easy it - was to extend the interfaces from Ruby to Python: not counting the different memory + Apart from that, Python and Ruby coexist remarkably well and it is amazing, how easy it + it to extend the interfaces from Ruby to Python: not counting the different in the memory management model (mark and sweep garbage collector in Ruby, reference counting in Python), the concepts are very similar.

@@ -118,7 +118,7 @@ layout.write("t.gds") considered when going from Ruby to Python.

-

Python PCell's

+

Python PCells

Please have a look at the PCell sample available in the templates. Pick the PCell sample @@ -129,6 +129,12 @@ layout.write("t.gds") PCell implementation in Python is very similar to Ruby.

+

+ Python macros are ".lym" files that are placed into the "pymacro" subfolder in the KLayout path. + Python libraries can be put into the "python" subfolder. This subfolder is included into the + "sys.path" variable, so macros can load libraries simply by using "import". +

+

Python Implementation Notes