Skip to content
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

kikit panelize fails on edge cut in footprint: Board rotation has to be passed as EDA_ANGLE, not a number #663

Open
3 tasks done
idank opened this issue Mar 13, 2024 · 10 comments

Comments

@idank
Copy link

idank commented Mar 13, 2024

Prerequisites

  • I have read FAQ
  • I have searched existing issues (including closed ones)
  • I use KiKit at least version 1.5.0 (older version are not supported)

KiKit version

python -m kikit.ui, version 1.5.0

KiCAD version

8.0

Operating system

Mac

Description

kikit seems to have an issue when it sees an edge cut inside of a footprint. I went over #189 but it seems there's something different here.

To simplify things I used one of the example commands and I've dumbed down my PCB to just the faulty footprint (an LED) surrounded by a rectangle:

image
% kikit panelize \
    --layout 'grid; rows: 2; cols: 2; space: 2mm' \
    --tabs 'fixed; width: 3mm' \
    --cuts 'mousebites; drill: 0.5mm; spacing: 1mm; offset: 0.2mm; prolong: 0.5mm' \
    --post 'millradius: 1mm' --debug 'trace: true;' \
test2.kicad_pcb panel.kicad_pcb
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'VECTOR2< int > *', no destructor found.
swig/python detected a memory leak of type 'VECTOR2< int > *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
An error occurred: Board rotation has to be passed as EDA_ANGLE, not a number
No output files produced
Traceback (most recent call last):
  File "/Applications/KiCad/KiCad.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kikit/panelize_ui.py", line 217, in panelize
    doPanelization(input, output, preset, plugin)
  File "/Applications/KiCad/KiCad.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kikit/panelize_ui.py", line 267, in doPanelization
    ki.buildLayout(preset, panel, input, sourceArea)
  File "/Applications/KiCad/KiCad.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kikit/panelize_ui_impl.py", line 255, in buildLayout
    substrates = panel.makeGrid(
  File "/Applications/KiCad/KiCad.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kikit/panelize.py", line 1277, in makeGrid
    boardSize = self.appendBoard(
  File "/Applications/KiCad/KiCad.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kikit/panelize.py", line 950, in appendBoard
    raise RuntimeError("Board rotation has to be passed as EDA_ANGLE, not a number")
RuntimeError: Board rotation has to be passed as EDA_ANGLE, not a number
swig/python detected a memory leak of type 'VECTOR2< int > *', no destructor found.
swig/python detected a memory leak of type 'BOX2< VECTOR2< int > > *', no destructor found.
swig/python detected a memory leak of type 'BOX2< VECTOR2< int > > *', no destructor found.
swig/python detected a memory leak of type 'VECTOR2< int > *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'BOX2< VECTOR2< int > > *', no destructor found.
swig/python detected a memory leak of type 'VECTOR2< int > *', no destructor found.
swig/python detected a memory leak of type 'VECTOR2< int > *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'VECTOR2< int > *', no destructor found.
swig/python detected a memory leak of type 'VECTOR2< int > *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'std::vector< ZONE * > *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.

Thank you for this great piece of software.

Steps to Reproduce

See example file at https://gist.github.com/idank/4b257632136e5c33a13bcc4352e76e5b.

@yaqwsx
Copy link
Owner

yaqwsx commented Mar 13, 2024

I think this is fixed in the upstream version (49363ea). Could you try it?

@idank
Copy link
Author

idank commented Mar 14, 2024

Still failing:

% kikit --version
python -m kikit.ui, version 1.5.0+10.g49363ea
%  kikit panelize \
    --layout 'grid; rows: 2; cols: 2; space: 2mm' \
    --tabs 'fixed; width: 3mm' \
    --cuts 'mousebites; drill: 0.5mm; spacing: 1mm; offset: 0.2mm; prolong: 0.5mm' \
    --post 'millradius: 1mm' --debug 'trace: true;' \
test2.kicad_pcb panel.kicad_pcb
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'VECTOR2< int > *', no destructor found.
swig/python detected a memory leak of type 'VECTOR2< int > *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
An error occurred: Board rotation has to be passed as EDA_ANGLE, not a number
No output files produced
Traceback (most recent call last):
  File "/Applications/KiCad/KiCad.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kikit/panelize_ui.py", line 217, in panelize
    doPanelization(input, output, preset, plugin)
  File "/Applications/KiCad/KiCad.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kikit/panelize_ui.py", line 267, in doPanelization
    ki.buildLayout(preset, panel, input, sourceArea)
  File "/Applications/KiCad/KiCad.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kikit/panelize_ui_impl.py", line 255, in buildLayout
    substrates = panel.makeGrid(
  File "/Applications/KiCad/KiCad.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kikit/panelize.py", line 1275, in makeGrid
    boardSize = self.appendBoard(
  File "/Applications/KiCad/KiCad.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kikit/panelize.py", line 948, in appendBoard
    raise RuntimeError("Board rotation has to be passed as EDA_ANGLE, not a number")
RuntimeError: Board rotation has to be passed as EDA_ANGLE, not a number
swig/python detected a memory leak of type 'VECTOR2< int > *', no destructor found.
swig/python detected a memory leak of type 'BOX2< VECTOR2< int > > *', no destructor found.
swig/python detected a memory leak of type 'BOX2< VECTOR2< int > > *', no destructor found.
swig/python detected a memory leak of type 'VECTOR2< int > *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'BOX2< VECTOR2< int > > *', no destructor found.
swig/python detected a memory leak of type 'VECTOR2< int > *', no destructor found.
swig/python detected a memory leak of type 'VECTOR2< int > *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'VECTOR2< int > *', no destructor found.
swig/python detected a memory leak of type 'VECTOR2< int > *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'std::vector< ZONE * > *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.
swig/python detected a memory leak of type 'EDA_ANGLE *', no destructor found.

@yaqwsx
Copy link
Owner

yaqwsx commented Mar 15, 2024

Unfortunately, I struggle to reproduce the issue on Linux. And I don't own a Mac. I assume this might be related to the numerous warnings from the SWIG wrapper in KiCAD API.

I will try to find a way of reproducing it, however, it might take a while.

@idank
Copy link
Author

idank commented Mar 15, 2024

I'd love to use kikit on Linux, but Kicad 8 botched Python's packaging and installing the nightly version didn't help.

@yaqwsx
Copy link
Owner

yaqwsx commented Mar 15, 2024

If you are on Debian-based distribution, the packaging is already fixed in testing builds of v8 (this how we use it for CI):

'v8-testing')
sudo add-apt-repository --yes ppa:kicad/kicad-8.0-nightly
sudo apt-get update
sudo apt-get install --yes --no-install-recommends kicad
# The Pcbnew module is located in
# - /usr/lib/kicad/lib/python3/dist-packages
# - instead of /usr/lib/python3/dist-packages/pcbnew.py
# Let's add it to PYTHONPATH and also set LD_LIBRARY_PATH
echo "PYTHONPATH=/usr/lib/kicad/lib/python3/dist-packages:${PYTHONPATH}" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=/usr/lib/kicad/lib/x86_64-linux-gnu/:${LD_LIBRARY_PATH}" >> $GITHUB_ENV
echo "PYTHONPATH=/usr/lib/kicad/lib/python3/dist-packages/:/usr/lib/kicad/local/lib/python3.10/dist-packages:/usr/lib/kicad/local/lib/python3.11/dist-packages:/usr/lib/kicad/local/lib/python3.12/dist-packages" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=/usr/lib/kicad/lib/x86_64-linux-gnu:/usr/lib/kicad/lib/" >> $GITHUB_ENV
;;

@idank
Copy link
Author

idank commented Mar 15, 2024

Yeah I tried that, for some reason I'm not getting the /usr/lib/kicad directory.

As a matter of fact, I do have the file at /usr/lib/python3/dist-packages/pcbnew.py, but I didn't want to install kikit system wide as the instructions suggest, so I used pipx and that installed pcbnew in a virtual environment and got the file at /home/idank/.local/pipx/venvs/kikit/lib/python3.11/site-packages/pcbnewTransition/pcbnew.py as well.

I'm not sure how kikit is supposed to be installed as simply doing pip3 install kikit doesn't work anymore.

@yaqwsx
Copy link
Owner

yaqwsx commented Mar 15, 2024

pip3 install kikit works on Ubuntu 22.04 with KiCAD 7 and KiCAD 8.0.1-rc2 installed from repositories. There are no extra steps needed.

@idank
Copy link
Author

idank commented Mar 15, 2024

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 23.10
Release:	23.10
Codename:	mantic
$ which pip3
/usr/bin/pip3
$ pip3 install kikit
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
    
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
    
    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

@yaqwsx
Copy link
Owner

yaqwsx commented Mar 16, 2024

Ah, you mean this change in recent pip. Due to the way KiCAD handles Python plugins, the recommended way is --break-system-packages (it is the same as what pip did before this warning appeared).

I have plans for other installation methods, but it is laborious to get working properly (as it has to work on Linux, Flatpak, Windows, and mac), which makes it annoying to test properly.

@idank
Copy link
Author

idank commented Mar 17, 2024

That does work but I hope you'll figure this part out in the future!

Also, I'm not getting the crashes on Linux so your suspicion that it's Mac related seem correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants