It looks like you're new here. If you want to get involved, click one of these buttons!
Hi,
Having recently moved from Windows to Ubuntu OS, I have several Python Pcell libraries that work perfectly and start with the Klayout windows edition startup.
Pcells, however, do not start automatically with Klayout startup since I moved to Ubuntu and using Klayout Ubuntu edition. I need to start them manually every time.
In all of these codes, there is a "# $autorun-early" at the beginning.
Is there any reason why they do not run when Klayout starts?
Comments
@ashkan There is no difference between Windows and Ubuntu in that respect.
There is one difference though: On Windows, KLayout keeps its configuration in "c:\users\\KLayout" while on Ubuntu the folder is "/home//.klayout" (lowercase "klayout" with a leading dot).
Maybe you did not put your files into ".klayout"?
Matthias
Hi @Matthias,
In fact, all of the codes are inside "pymacros" folder inside .klayout.
But Klayout still not running my python codes. I need to run them manually.
Maybe your macro search path then needs to have
~/.klayout/pymacros
included as well as the default .klayout?
What happens if you move the Python scripts to ~/.klayout level?
@ashkan If your code is in ".klayout" that is WRONG. It needs to go into "KLayout" instead of ".klayout" on Windows. More specifically,
%HOME%\KLayout
orc:\users\matthias\KLayout
in my case (sorry, Markdown swallowed a few characters in my above reply).Matthias
@dick_freebird Actually, I have a lot of codes. Codes that should be visible in menu is working correctly and are shown inside Macros' menu. But Codes that must show in the Libraries are not showed and I have to run them manually.
I don't have this problem in Windows OS. They work correctly in Windows OS.
@Matthias The problem is not in Windows.
As I told @dick_freebird I don't have any problem in Windows.
But in Ubuntu, my codes are in the .klayout but still are not available in the libraries.
Okay, so maybe you need to explain to me what you mean. I do not understand the details.
So "Codes that must show in the Libraries" means script code that is supposed to be executed on startup, but isn't? So you have a specific file that you expect to be executed but it is not?
If so then
1.) Please gain some evidence that the file really isn't executed. I may be executed, but the problem may be elsewhere, i.e. library registration is failing. Run Klayout with high verbosity ("klayout -d 31 .."). You will see messages like
and finally
2.) Check for errors printed on the console. They may explain what goes wrong.
2.) If your file is loaded, but not executed, give some details about the file header (XML elements or first text lines) so I can check what makes the file not being auto-executed.
Matthias
I still don't see addressed, my question whether ".klayout/pymacros"
(3rd post) is (1) normal / proper, (2) a valid search path entry.
Might suggest trying to invoke these "missing" scripts by full
path and see whether it's finding them that's the problem, or
not liking what's found.
@Matthias :
You are right: Python codes for Pcells (that work perfectly in klayout Windows os version) is not running at the startup in klayout Ubuntu version.
By running ("klayout -d 31 ..") I get errors which I attached to this comment.
top 13 lines are like:
@dick_freebird:
I have several folders inside ./klayout/pymacros but there are several files too.
None of them is run at the start-up. It doesn't matter if I put them in ./klayout. They are not running. However, when I put them in ./klayout directory, they do not appear even in the macro development section.
The last error (21) indicates that something in your path structure is a directory instead of whatever you want to do and it's an illegal operation for a director. I assume you expect to write something to a file that is actually a directory. POSIX error is EISDIR (see
man errno
) and in python you can get it easily byimport errno; errno.errorcode[21]
I am not sure whether the other errors are relevant but you have two files that cause errors, which I suspect are your files that define the pcell libraries.
@dick_freebird and @sebastian,
Could you check if the macros are marked "autorun early"?
In this case please switch to "autorun" (without "early").
Background: "early autorun" means the scripts are executed (in not specific order) with a fresh Python. There are internal macros which also are executed in this step, specifically the ones that contribute "PCellDeclarationHelper". So autorun-early macros cannot necessarily assume this class is there and that is why this message is seen: "module 'pya' has no attribute 'PCellDeclarationHelper'".
I think that under Windows - not intentionally, but maybe because of the different paths and lexical order - the execution sequence of autorun-early macros is different than on Linux.
Your PCell code can safely go into normal "autorun" which is executed after "early" and will find a well-initialized environment.
If you need to establish true dependencies with execution guaranteed before specific code, please consider using "import" and Python modules. Python then will make sure those modules are loaded before.
Kind regards,
Matthias
Thank you @Matthias.
By changing autorun-early to autorun, the problem has been solved.
Great! Thanks for letting me know!
Matthias