Feature proposal: Export all the KiCAD internals to the Python API and let the community build stable API
First of all, I would like to thank all of you, KiCAD's developers, for your work. KiCAD is amazing. What also makes KiCAD amazing is the broad community of power users, that use KICAD Python API to implement plugins. This is a really nice feature of KiCAD which makes it really powerful. However, the current Python API is somewhat messy:
- it is a 1:1 export of the internal KiCAD structure, thus it is not stable
- it is not complete - some parts of KiCAD are exposed, some of them are not. Currently, it is hard for me to tell what is the key to being exported.
There are "rumors" (in issues, on the IRC channel, on the KiCAD's Discourse, etc.) that the core developers would like to introduce a nice, stable Python API without these problems. I, as one of the people actively using the API, would welcome such an option. A lot of resources point that this is/was planned to v6. However, there is already a feature freeze and no such API is present.
I understand there are tasks with higher priority, thus there is not enough manpower for Python API. However, currently, the API is not in the best shape: e.g., compared to v5 some of the features gone missing (e.g., setting board parameters), or some of them have rather poor support (DRC).
Therefore, I would like to propose the following:
- would it be possible to provide SWIG export of all the KiCAD internals (including pcbnew, eeschema, project management) for v6?
- Then, the community could build a stable Python library on top of these exports. It could be a separate project, a sandbox to test and experiment. And maybe it can become a de-facto standard.
My proposal is similar to this one.
I am worried that if nothing happens with the API before v6 release, the API will be stuck in a "void" at least before v7 release (which will probably take several years). This could harm and discourage the power-user community around KiCAD which has formed in the last few years and thus KiCAD would lose one of its appealing aspects. Having a full or near-full export would give the community something to work with. Note that this proposal does not prevent from actually building a nice stable API guaranteed by the KiCAD developers for v7.
PS: I have never worked with SWIG, so I am not sure if my proposal is technically possible. (I have only experiences with PyBind11).
Steps to reproduce
This a feature proposal, there are no steps to reproduce
Application: Pcbnew Version: 5.99.0-unknown-2b9f7d6150~106~ubuntu20.04.1, release build Libraries: wxWidgets 3.0.4 libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3 Platform: Linux 5.4.0-59-generic x86_64, 64 bit, Little endian, wxGTK, regolith, x11 Build Info: Date: Jan 4 2021 10:19:33 wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24 Boost: 1.71.0 OCC: 7.3.0 Curl: 7.68.0 ngspice: 31 Compiler: GCC 9.3.0 with C++ ABI 1013 Build settings: KICAD_SCRIPTING=ON KICAD_SCRIPTING_MODULES=ON KICAD_SCRIPTING_PYTHON3=ON KICAD_SCRIPTING_WXPYTHON=ON KICAD_SCRIPTING_WXPYTHON_PHOENIX=ON KICAD_SCRIPTING_ACTION_MENU=ON KICAD_USE_OCC=ON KICAD_SPICE=ON