Skip to content

Commit 06f6565

Browse files
committed
PyPI deploy v0.4.0
1 parent 0836d12 commit 06f6565

File tree

4 files changed

+35
-25
lines changed

4 files changed

+35
-25
lines changed

README.md

+18-15
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ This package is a pythonic wrapper around the various `pcbnew` APIs. It implemen
1212

1313
This package has been fully tested with KiCAD 5, 6, 7 and partially tested with 7.99.
1414

15+
> [!CAUTION]
16+
> The atait fork is undergoing a refactor that will result in new package imports.
17+
> Instances of `from kicad.pcbnew.board import Board` must be replaced by `from kigadgets.board import Board` by version 0.5.0
18+
1519
### An excerpt
1620
A simple pythonic script might look like this
1721
```python
@@ -30,10 +34,8 @@ Don't be fooled though - `track` and `board` contain no state. They use properti
3034

3135
1.
3236
```
33-
git clone git@github.com:atait/kicad-python
34-
pip install kicad-python/.
37+
pip install kigadgets
3538
```
36-
<!-- pip install kigadgets -->
3739

3840
2. Open the pcbnew GUI application. Open its terminal ![](doc/pcbnew_terminal_icon.png) or ![](doc/pcbnew_terminal_icon2.png) and run these commands in kicad 6+
3941
```python
@@ -105,9 +107,7 @@ Third, it exposes KiCad's `pcbnew.py` to your external python environment. The p
105107
**Effect:** You can now use the full KiCad built-in SWIG wrapper, the `kicad-python` package, and any non-GUI plugins you are developing *outside of the pcbnew application*. It is useful for batch processing, remote computers, procedural layout, continuous integration, and use in other software such as FreeCAD and various autorouters.
106108

107109
## Snippet examples
108-
These snippets are run in the GUI terminal. They are common automations that don't need dedicated action plugins
109-
110-
There is no preceding context; the linking step above provides `pcb` to the terminal. These all should work in pcbnew 5, 6, or 7 on Mac, Windows, or Linux.
110+
These snippets are run in the GUI terminal. They are common automations that aren't worth making dedicated action plugins. There is no preceding context; the linking step above provides `pcb` to the terminal. These all should work in pcbnew 5, 6, or 7 on Mac, Windows, or Linux.
111111

112112
### Hide silkscreen labels of selected footprints
113113
```python
@@ -131,6 +131,7 @@ pcbnew.Refresh()
131131
```
132132

133133
### Select similar vias
134+
This snippet assumes you have selected one via
134135
```python
135136
og_via = next(pcb.selected_items)
136137
for via2 in pcb.vias:
@@ -140,7 +141,9 @@ for via2 in pcb.vias:
140141
og_via.select(False)
141142
pcbnew.Refresh()
142143
```
143-
There is some additional functionality for micro and blind vias.
144+
The function `next` is used because `pcb.items` is a generator, not a list. Turn it into a list using the `list` function if desired.
145+
146+
See `via.py` for additional functionality related to micro and blind vias.
144147

145148
### Change all drill diameters
146149
Because planning ahead doesn't always work
@@ -170,7 +173,7 @@ for mod in pcb.footprints:
170173
mod.select()
171174
```
172175

173-
### Import user library
176+
### Import user library for GUI/CLI
174177
Suppose you wrote a file located in $KICAD_SCRIPTING_DIR/my_lib.py
175178
```python
176179
# ~/.config/kicad/scripting/my_lib.py (Linux)
@@ -200,13 +203,13 @@ python my_lib.py some_file.kicad_pcb
200203
```python
201204
from kicad.pcbnew.drawing import Rectangle
202205
my_rect = Rectangle((0,0), (60, 40))
203-
print(my_rect.x, my_rect.contains((1,1))) # 30 True
204206
pcb.add(my_rect)
205207
pcbnew.Refresh()
208+
print(my_rect.x, my_rect.contains((1,1))) # 30 True
206209
# Go move the new rectangle in the editor
207-
print(my_rect.x) # 15.2 False
210+
print(my_rect.x, my_rect.contains((1,1))) # 15.2 False
208211
```
209-
`kicad-python` is a stateless wrapper of objects, not just an API wrapper. It stays synchronized with the state of the underlying native objects even when they are modified elsewhere.
212+
`kicad-python` stays synchronized with the state of the underlying native objects even when they are modified elsewhere because it is wrapping the C++ state rather than holding a Python state.
210213

211214
### Procedural layout
212215
Suppose you want to test various track width resistances.
@@ -224,7 +227,7 @@ for w in widths:
224227
y += 20
225228
pcbnew.Refresh()
226229
```
227-
Go ahead and try this out in the pcbnew terminal, although this type of thing is better to stick in a user library(see above). The sky is the limit when it comes to procedural layout!
230+
Go ahead and try this out in the pcbnew terminal, although this type of thing is better to stick in a user library (see above). The sky is the limit when it comes to procedural layout!
228231

229232
## Related packages
230233
KiCAD has a rich landscape of user-developed tools, libraries, and plugins. They have complementary approaches that are optimized for different use cases. It is worth understanding this landscape in order to use the right tool for the job. This is how `kicad-python` fits in.
@@ -236,13 +239,13 @@ KiCAD has a rich landscape of user-developed tools, libraries, and plugins. They
236239
| ----------------- | ------------ | ---------------------------- |
237240
| Primary audience | users | developers |
238241
| CAD logic/state | python | C++ |
239-
| Entry points | Plugin, CLI | API, examples |
242+
| Entry points | Plugin, CLI | API |
240243
| Dependencies | 8 | 0 |
241244
| Lines to maintain | 15k | 3k |
242245
| Python versions | 3.7+ | 2.\*/3.\* |
243-
| Documentation | extensive | "documents itself" (for now) |
246+
| Documentation | extensive | "documents itself" for now |
244247

245-
**Audiences:** While `KiKit` is directed primarily to end users, `kicad-python` is directed moreso to developers and coders. It is lean: <2,800 lines of code, no constraints on python version, and **zero dependencies** besides `pcbnew.py`. Out of the box, `kicad-python` offers very little to the end user who doesn't want to code. It has no entry points, meaning the user must do some coding to write 10-line snippets, action plugins, and/or batch entry points. In contrast, out of the box, `KiKit` exposes highly-configurable, advanced functionality through friendly entry points in CLI and GUI action plugins.
248+
**Audiences:** While `KiKit` is directed primarily to end users, `kicad-python` is directed moreso to developers and coders. It is lean: <2,800 lines of code, no constraints on python version, and **zero dependencies** besides `pcbnew.py`. Out of the box, `kicad-python` offers very little to the end user who doesn't want to code. It has no entry points, meaning the user must do some coding to write 10-line snippets, action plugins, and/or batch entry points. In contrast, `KiKit` comes with batteries included. It exposes highly-configurable, advanced functionality through friendly entry points in CLI and GUI action plugins.
246249

247250
**Internals:** `KiKit` performs a significant amount of internal state handling and CAD logic (via `shapely`). `kicad-python` does not store state; it is a thin wrapper around corresponding SWIG objects. While the first approach gives functionality beyond `pcbnew` built into KiKit, the second exposes the key functionality of underlying objects, leaving the state and logic to C++. It requires a coder to do things with those objects. If that dev wants to use `shapely` too, they are welcome to import it.
248251

kicad/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '0.3.0'
1+
__version__ = '0.4.0'
22

33
#: centralized import with fallback.
44
#: Necessary for documentation and environment patching outside of application

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# No requirements

setup.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@
66
except IOError:
77
reqs = []
88

9+
def readme():
10+
with open('README.md', 'r') as fx:
11+
return fx.read()
12+
913
setuptools.setup(
10-
name='kicad',
11-
version='0.3.0',
12-
description='KiCad python API',
13-
author='Piers Titus van der Torren, KiCad Developers, Hasan Yavuz Ozderya, Alex Tait',
14-
author_email='kicad-developers@lists.launchpad.net',
15-
url='https://github.com/kicad/kicad-python/',
16-
packages=setuptools.find_packages(exclude=['ez_setup']),
17-
zip_safe=False,
14+
name='kigadgets',
15+
version='0.4.0',
16+
description='Cross-version python wrapper for KiCAD pcbnew',
17+
long_description=readme(),
18+
long_description_content_type='text/markdown',
19+
author='Piers Titus van der Torren, Miguel Angel Ajo, Hasan Yavuz Ozderya, Alex Tait',
20+
author_email='atait@ieee.org',
21+
license='GPL v2',
22+
url='https://github.com/atait/kicad-python/',
23+
packages=setuptools.find_packages(exclude=['tests']),
1824
install_requires=reqs,
1925
entry_points={'console_scripts': 'link_kicad_python_to_pcbnew=kicad.environment:cl_main'},
20-
test_suite='kicad.test.unit')
26+
)

0 commit comments

Comments
 (0)