-
-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v6 MacOS functionality and wxwidgets #252
Comments
I am not a mac user but I was wondering if the binary `pcbnew-nightly isn't just a wrapper script that properly set all library paths - just like in #246. The paths, of course, could be different. |
So I set
all live. But, I still got the same error as above. Is there another path I should be setting? |
Quick googling told me that mac uses |
Okay I set my
There are 3
|
Could you:
|
BTW: I am sorry; I probably closed this issue yesterday by mistake when posting an answer. |
@yaqwsx I think the issue here is that the Python bundled with KiCad is ultimately calling @a7hybnj2 Can you try adding something like the following to your
This should allow the KiCad python to find any dylibs installed by homebrew. |
Sorry, I misread this earlier, and now that I think about this, I think @a7hybnj2 is right, it seems like these should be included with KiCad in
Slight edit to what I proposed earlier, this should allow KiCad Python to find
|
I tested with your above fix and was still getting the same errors so just in console I
all of the previous errors went away and were replaced by: What is |
I'm brand new to KiKit, and I didn't realize earlier that it wasn't just using the Python bundled with KiCad, so the @a7hybnj2 are you seeing any difference when setting
It appears to be a macro for the dynamic loader that lets you specify dependency paths that are resolved at runtime. (see https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/RunpathDependentLibraries.html#//apple_ref/doc/uid/TP40008306-SW1)
You can inspect these rpaths using
You can actually experiment with changing the rpaths using
This results in absolute paths that are already resolved:
However, even after replacing the rpaths with absolute paths, I'm still getting the same
At this point, I'm out of ideas... 🤷 |
Now that KiCad 6 is officially out I suspect it is only a matter of time before someone figures it out. I too have done all I know how to do. |
I am still unsure whether it is safe to release v1, if I cannot confirm it works on Mac. Or if it is better to release v1, find the Mac users and then release v1.0.1 that is patched for Mac. |
Given that Mac users can run KiKit in Docker, I'd say just release v1 and make a note that macOS isn't supported yet (who knows how long until somebody figures out how to get this working on Mac...) |
It seems like the MacOS Version KiCAD compile a standalone python version. The python library did not share w/ system or brew version python. The easy way is to use kicad python to install kikit. And use that kikit to do panelize. Install Panelize |
Well, I just tried the above and it seems promising although I still ran into some errors. When I installed kikit I get a
seems like this might be a pythonpath dyld thing again. I will try to locate those packages and point to them correctly and update here. EDIT: Looks like it is looking in the correct places but something with a signature or ¯\(ツ)/¯. I am again past my knowledge of the issue. EDIT 2: I had just installed STABLE this morning upgrading/replacing the nightly build. I am under the impression removing kicad will also remove its version of python and associated packages so nothing local should be messing it up. |
You got this error Make sure you use new
|
(The above is a blank line)
looks just like yours
I am using the example board provided by kikit in the doc/resources folder. Could it be the example file? Do you have a file you want to share to rule that out? |
Once you panelize, |
This is MacOS Standard security issue..... signature error... I do not know how to resolve it. (Long long time ago, I disabled lots of macos security options.) Hits: search google
|
I managed to get the SIP (System Integrity Protection) Mac issue solved, but I had to sign again the Python.app embedded with Kicad. If you don't have a Apple Developer code signing certificate you can simply create a Self Signed using Keychain like this... Then run
I was then able to run using the embedded python the example panelization command...
Technically I believe this should be solved by the Kicad Mac builder, they should probably add the "com.apple.security.cs.disable-library-validation=TRUE" entitlement the the Python.app. The problem is that the Kicad.app is code signed but the minute we run the embedded pip3, files are added that were not part of the original bundle so they cannot be loaded. The issue is solved by resigning the Python.app but ideally we'd like that validation to be disabled. Summarizing, install KiKit, code sign and then run kikit.
|
I forgot to mention that even though the panelize command runs and generates the panel, it also outputs some assertion issues:
|
I got same outputs too, but it seems not affect the panelize. It only the message for wxApp.
|
@conradopoole sweet! I will try this out this afternoon. Would this be mitigated if this package were installed through the new kicad plugin/package/theme manager? I know that isn't really how this tool works but would be cool and much easier for non-cl people. |
@a7hybnj2 I think you can prevent the error from showing up by passing all the required packages to pip on one line (this installs for me without any errors):
@conradopoole the code signing works for me too. I'm also getting the assertion errors, but it looks like the panelizer is working correctly.
@yaqwsx FYI, when I open pcbnew after installing the KiKit front end from PCM, I get the following error. What is it looking for to determine if there is a backend installed? |
@cdwilson On my side, the kicad kikit plugin work perfect. @yaqwsx For macos, when you enable the plugin, the script should in Following steps
PS: Fingers crossed and good luck |
@tywtyw2002 Did you do any additional code signs? For me the Panelize plugin does not work either from the GUI (it does not load with same message as @cdwilson ) unless a fully code sign the full Kicad.app (with --deep), then it loads
I figured out it was a signing issue again when from the Script console in Pcbnew I tried to run the same import the kikit_plugin.py does. Doing a :
Resulted in the same signing error about the Team ID blah blah blah .... Only way around it for me was to fully code sign the whole app like explained above. @cdwilson let me know if this works for you as well One side effect is that if I fully code sign Kicad.app then the kikit does not work for me from the command line.... But I rather have the GUI plugin working on my Mac and then if I want to run the CLI I just then a docker image instead. (@yaqwsx started pushing the M1 docker image as well to docker hub, if using an Intel Mac then the standard x64 image works). |
NO, I disabled SIP and other security features since day 1. I think that is called If you know what software you've running, disable security features make life easier. |
Oh! and there it is. Guess you can see my user name is "chimney". Forgot to replace it with a generic in one step. Hope the above helps. Robert AKA Robomaticii |
Je vous en prie 😉
John Pateman
…Sent from my iPhone
On 2 Feb 2022, at 03:09, Robomaticii ***@***.***> wrote:
Oh! and there it is. Guess you can see my user name is "chimney". Forgot to replace it with a generic in one step.
Hope the above helps.
Robert AKA Robomaticii
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
|
This was the missing secret sauce for me. |
Hi! I see that you made a progress with this issue. Would you mind writing a step-by-step guide and submitting it as a pull request to the documentation? PS: Is there anything we could ask from the KiCAD developers to make the whole process easier? I find the current situation on Mac really bad, however, since I am not a Mac use I am not sure if I fully understand what needs to change. |
Jan
I will put together a step-by-step guide and submit it as a pull request.
However, I wish I knew exactly why it works. I am more of a hardware guy
and an artificer (someone who just makes things work) - not a programmer.
I suspect it has something to do with how Mac OS handles certificates. I am
going to do some research to see if I can figure it out.
I will be in touch soon.
Robert
…On Wed, Feb 9, 2022 at 4:11 AM Jan Mrázek ***@***.***> wrote:
Hi! I see that you made a progress with this issue. Would you mind writing
a step-by-step guide and submitting it as a pull request to the
documentation?
PS: Is there anything we could ask from the KiCAD developers to make the
whole process easier? I find the current situation on Mac really bad,
however, since I am not a Mac use I am not sure if I fully understand what
needs to change.
—
Reply to this email directly, view it on GitHub
<#252 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AXNEI7UZAYE2E44LYMRE4Z3U2IVTBANCNFSM5KOAN3JQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID:
***@***.***>
|
Install the KiKit backend into a virtual environment. For example: python3 -m venv <path_to_kikit_PCM_directory> This installs a virtual environment in the KiKit plugin directory. Activate the environement and install the kikit backend. This commit tells the plugin to recognize the virtual environment.
I think it Is possible to solve this issue using a virtual environment. I did some investigation and it is possible to install the KiKit backend into a virtual environment that is created from the KiCad python. For example:
This installed a virtual environment in the KiKit plugin directory. I can now open a terminal and activate that python environment and run KiKit:
And I can confirm that KiKit is running properly:
The only remaining issue is to get the plugin to recognize the virtual environment. I did this by adding the path to the site directory in the plugin (kikit/plugins/init.py): And this appears to work without having to code sign the KiCad app in macOS. Of course, this is specific to my particular installation so the proposed solution here requires a little more work to extract the proper path from the virtual environment and add it to the site package search list. |
There is another way to accomplish the same thing without the change described above. Create a file "kicad.pth" with the following:
Use the path to the directory you created the virtual environment you installed KiKit to. Place the file in the following directory:
Viola. |
I repeated your steps, both with the fix for init.py or the kicad.pth file, and in my case it still does not work unless I resign the Kicad.app . It does install kikit in the virtual environment but the minute the app tries to load dependencies that load SO objects that were not in the original signature, it fails. Same issue as before, only that it now complains about paths in the virtual environment. An easy easy way to reproduce it is to launch the KyPython shell and run
It fails with the same error as always due to signatures... See below... Did you make any changes to your Notarization settings? |
@conradopoole What machine are you running? I found things a little different if you are running on Apple Silicon. The root cause is the numpy package. The numpy package has a few binary libraries that cause the problem as a result of gatekeeper Library Validation. Library Validation fails for any binaries that are not signed with the same Team ID unless Library Validation is disabled. This is strictly enforced on Apple Silicon macs but apparently not on Intel macs. This is why I noticed a difference in behaviour between the two architectures. Regarding recreating the problem it is even simpler to do, just attempt to import numpy. The solution to this problem requires that @yaqwsx include with KiKit the packages used by KiKit that are not included with the KiCad app bundle site-packages. So at a minimum, @yaqwsx will need to include numpy because numpy is not included in the KiCad python site-packages. Then, the KiKit plugin package, including the numpy package used by KiKit, needs to be signed by KiCad. Thus, when the package is installed, it will pass library validation since both the plugin libraries and the python binaries are signed by KiCad. I posted an issue on the KiCad gitlab repo and briefly discussed it with the KiCad team. I think the KiCad developers are likely reluctant to disable library validation. So, I think signing the plugin is the most appropriate solution. It is possible to work around this for the moment but it requires the manual steps generally described here. So, regarding your specific issue, are you running on Intel or Apple Silicon? I have it working on both. If running on Apple Silicon, you do need to re-sign the python binaries and the numpy libraries using your own certificate. I also found that the KiCad app bundle python creates cache files inside the app bundle. From the work I did, I found that using PYTHONPATH and PYTHONPYCACHEPREFIX environment settings configured the python environment properly so python could find the site-packages directory for kikit and not pollute the KiCad app bundle with the cache files. I installed kikit and the kikit dependencies in my own directory outside the KiCad app bundle. When I used these environment variables, I did not have to make the change to init.py and I did not require a .pth file. I will see if I can put together a step by step set of instructions of how to do all of this. |
Here is the script I use to sign the proper items in the KiCad app bundle:
I set the following environment variables in the "Preferences->Configure Paths" dialog:
Since the numpy libraries are signed ad-hoc they will run if the python binaries are signed by you. I don't think the PYTHONUSERBASE setting is required since I added the PYTHONPATH setting. |
Hi there, I have been experiencing the same difficulties while trying to install another tool (pcbdraw), which also uses numpy. Following the advice in this thread, I came up with the following plan (for reference).
I created the following script to perform steps 1-3:
One of the tricks is that each python environment references the other's site-packages to make things easier. Now I can use this virtualenv to install additional software:
And running python I can import everything successfully:
It remains to be seen if this strategy works in the medium run (e.g. facing KiCad updates). |
Just for reference - the related KiCAD issue: https://gitlab.com/kicad/code/kicad/-/issues/10943 |
@secolive I believe you are missing one of the python binaries:
Using a virtual environment is the proper way to ensure you can run kikit from the command line properly. One thing to remember though is that the python bundled with KiCad does not use the virtual environment when run from within KiCad. So I recommend using the environment variables I describe in my earlier post. These variables ensure that when the kikit plugin is run from pcbnew, it has the correct environment configuration. Fortunately, using the virtual environment will ensure the site-packages are retained across KiCad updates. However, in order to use the site packages not included with KiCad, the KiCad app and python binaries have to be resigned each time KiCad is updated. |
@secolive @sslupsky: Is the script fully automatic? If so, could I make it part of KiKit's repository and link to in the KiKit's instructions. I don't mind if KiKit would have to be installed after every KiCAD's update. At the moment, with the setup provided by KiCAD 6, I see this as the only viable solution. |
@yaqwsx I think it Is close. The user will have to set a couple environment variables in their Kicad configuration. |
Kind of - the variables V and KICAD_PYTHON have to match the details of the KiCad installation. CERTIFICATE has to be changed to the name of the certificate you'll use for codesigning. The python virtual env will be created as a subdirectory of where the script is located, meaning you have to decide on a proper location - I went for ~/Documents/KiCad/6.0, to be seen in practice if this is the right thing to do. Also, note that the actions being carried out are rather simple and could be part of a simple documentation. Still, I see this as a kind of workaround, and am not 100% sure it's the proper way to go. |
@sslupsky: If you need to override some variable, you can do so in the file |
I just want to confirm that the instructions from secolive work on Intel Big Sur. I didn't need any extra environment variables or to re-sign the python binary separately from Python.app. Here's what I did. This is pretty much exactly what secolive wrote, including a few more steps that might not be obvious to a non-MacOS-developer. (1) Create a code signing key if you don't have one To use kikit via the command line, you always need to first activate the virtual environment with: Since there's a whole lot of other stuff in this thread that's like "you should maybe do this" or "this worked for me"—just to be clear, I didn't do any of that other stuff. This is with a clean KiCad install and more or less the MacOS default set of environment variables. Of course, very possibly some of it is necessary with slightly different setups, ¯\_(ツ)_/¯. |
@yaqwsx 6.0.4 fixed one of the python problems and the PYTHONPYCACHEPREFIX variable is no longer required. |
I finally got access to a Mac (thanks, @JakubAndrysek!) and I made an installation guide: https://github.com/yaqwsx/KiKit/blob/master/doc/macosInstallation.md Please, give it a try. |
Just installed 6.0.5 and used the guide. Works for KiCad.app, but you need to also sign at least pcbnew.app for standalone use. |
If you can submit a PR for signing pcbnew, I will be happy to merge it. At the moment, I have no way to validate the changes at the moment as I don't have access to Mac. |
Hey @yaqwsx we just spoke in #kicad and the path is |
Works on 6.0.5 with the extra codesign of |
Does any of the Mac users here have any idea what might be wrong in #363? |
We have at least five successful installations on macOS using the new instructions. I consider this issue resolved. If you find new problems on mac, please, feel free to open a new issue. |
I just updated kicad and kikit. I am running
KiCad Version: (6.0.0-rc2-14-ga17a58203b), release build
andkikit, version 0.99-pre1.0+76.g2d499e0
although I tired this with 0.7 also. OnmacOS 12.0.1
The error I get is
This was referenced in #21 but this is indeed a different issue.
I was able to get past the initial error that was looking for
libwx_osx_cocoau_gl-3.1.5.dylib
by installingwxwidgets
usingbrew install wxwidgets
but now that I think about it that shouldn't have been necessary. It shouldn't be looking for the local libs...right? Shouldn't all of that be packaged into the kicad environment?I know yaqwsx doesn't have a mac at their disposal so I am just putting my notes here in case they or anyone else gets a similar error or figures how to progress past this point.
The text was updated successfully, but these errors were encountered: