Plugin and Content Manager - how to handle plugins with dependencies?

That’s fine! To those reading this thread, if we are to have some kind of better dependency situation for Python plugins, we need volunteer(s) with experience in C++ and Python and with Windows/Visual Studio/vcpkg to move this forward. If we can get a proof of concept working in Windows, the rest of the team can help with porting it to macOS. If anyone is interested in this project, please reach out on the developers’ mailing list.

This isn’t a vcpkg Windows/vcpkg/Visual Studio problem.

It’s this bit that is the problem. There is no way to override these. Yes there is a pip.ini file where you can try and override paths a little bit, and it works maybe 25% of the time, it’ll even print it loaded the paths from pip.ini…and then proceed to not use them at all.

I didn’t say it was. We just need someone who is comfortable in that environment to take on the project of patching pip and testing it there.

The problem of patching pip is pips constant hassling to update it to match pypi. At which you do it because the pypi changed their api or signing key or whatever and suddenly you have users with broken pip again that will run the auto update. It needs to be a upstream fix.

Unless we also patch out that update nag :slight_smile:

I’m trying to get more familiar with pip. I don’t understand yet what is actually needed and wanted, and what marekr has tried. Are we talking about activating pip from KiCad, or are we talking about just getting pip to work for Windows users so that they could themselves follow some instructions to install pip packages manually? Have you tried or considered different possibilities (which might or might not help) which are given in https://packaging.python.org/tutorials/installing-packages/ ? Virtual environments?

And what are the cases which must be taken care of, for example what should I install and do to trigger problems? Do you have some example plugin which tries to use a pip package which doesn’t work (one of those nonworking 30% cases)?

The python C API for venv has been abandoned since 3.6 and no longer functions for embedded python uses.

Either would be possible, but the blocker to either approach is to make pip work from the packaged Python in Windows (and macOS). Unfortunately as far as we can tell, the only path here is to patch pip to accept non-hard-coded paths, without using virtual environments or anything else like that.

Once that is accomplished, details like “can you run pip from inside KiCad, or do you have to open a terminal window” are smaller issues.

Just depend on any Python package that isn’t in the standard Python distribution and we don’t already ship with Windows (numpy, pillow, and six, I think)

You don’t even have to install anything: say you want to be able to use scipy. You should be able to open the KiCad Python console and type import scipy and have it work. Of course it won’t work until you find a way to have pip install prebuilt binaries of scipy into the right location.

Sigh, well I already know a plethora of solutions that’ll fix this without patching pip.

What I like right now. Create a “Launch kicad pip console” in the windows start menu and maybe elsewhere. This console will just be a bat file that sets all the environment variables to make pip use all the correct kicad directories, I can even shove a pip.ini down it’s throat by force at that point.

The question is, where will pip be told to installed packages? AppData, Documents/kicad//scripting? PRogramData (all users), etc, etc

I would think somewhere inside AppData is most appropriate? Does ProgramData require elevation?

ProgramData is actually the true path for C:\Users\Public\AppData which is an alias/symlink

Hmmm, I would want to add “Launch pip” to the kicad launcher…but it would most likely be windows specific…which I’m not sure offends the others ~~~

I must have misunderstood our earlier conversation, I thought you were saying that even with all the ini file and env var stuff, pip needed source patching to work properly

I think this kind of technique is needed on macOS as well

Ah, it might work, the problem is we can’t set a global environment variable in windows since it’s the generic python ones. And pip.ini is loaded based on working directory invocation of the shell. But it’s still buggy so it needs testing. I had cases where it was ignoring me anyway, and in other cases it was not.

11 posts were split to a new topic: PCM and color themes

Hi, one of the non-functional plugins on windows is KiKit. You can trigger the behavior by running .\python.exe -m pip install git+https://github.com/yaqwsx/KiKit@v6support. It will complain about not being able to compile the regex library.

EDIT: The library is a dependency of solidpython; however, in unreleased version the dependency is removed and you can install KiKit.

KiCad doesn’t support binary dependencies in plugins. This is a known limitation, relevant on Windows.

Edit: as you can see in the discussion above. But because it was the topic, I’m not sure why you responded to me saying that.

I was responding to your question “Do you have some example plugin which tries to use a pip package which doesn’t work (one of those nonworking 30% cases)?” - yes I have. It is KiKit. At least it was before we got rid of the problematic dependency.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.