Closed ukd1 closed 10 months ago
The file not found errors are due to a breaking change to python's __file__
dunder method. After python 3.9+, the basename is returned with the full path rather than the base filename without path. All example scripts now use os.path.basename(__file__)[:-3]
to return a simple basename as expected. In realty, your scripts will use your own filename reference anyway--the use of __file__
was a convenience for the sample scripts to self name.
Lastly, the sample.py
script did not work because you do not have a sparkfun.lbr
Eagle PCB library in the path of the script. Unless you use Eagle PCB, it is not a relevant test.
Modifications have been made to the repo example scripts and committed. Other changes have been made to support new versions of dependancy libraries.
Nevermind about the comments with respect to the __file__
dunder methods! That was referring to the bugs I was received whilst trying to replicate your error!
The NoneType
buffers are likely due to the version of the shapely
library. PCBflow was initially released supporting v.1.8.0+. Breaking changes were made v.2.0.0+ and therefore PCBflow was just changed to support them. Pull the most recent PCBflow and try again?
Thanks for the quick reply! Just pulled, still getting this error:
% python basic/blank.py
Traceback (most recent call last):
File "/Users/russ/Sites/pcbflow/examples/basic/blank.py", line 11, in <module>
brd.fill_layer("GTL", "GND")
File "/Users/russ/.asdf/installs/python/3.10.6/lib/python3.10/site-packages/pcbflow-0.2.0-py3.10.egg/pcbflow/board.py", line 247, in fill_layer
lyr.fill_poly = g.difference(exclusions.buffer(self.drc.clearance))
AttributeError: 'NoneType' object has no attribute 'buffer'
BTW, if it needs another version of Python, or some other requirements - I'm happy to install, just no sure where to get them (e.g. sparkfun.lbr
).
Side/background: I am a total beginner at designing boards, but like programming. For CAD, I decided to learn OpenSCAD first - this seems similar! So, I have near-zero context for fixing outside of reading your README.
The first thing to try is to update the shapely
package:
$ pip install --upgrade shapely
FYI, my platform has v.2.0.2 of shapely
Examining your execution dump above, I see that your installation uses shapely 2.0a1
. When reviewing the changelogs from the shapely
library repo, it appears that there was a very important fix made to version 2.0b1+ which would very much explain the AttributeError: 'NoneType' object has no attribute 'buffer'
messages above. The object which is declared as a NoneType
should in theory never be of this type. This object is the result of a call to the shapely.unary_union
method which (as of 2.0b1+) should always return an object of type GeometryCollection
(even if empty).
Therefore, I would strongly suggest updating your shapely
library as described above to any version 2.0b1+, preferably v.2.0.2 (latest as of now).
I've enforced the version of the shapely
package in the pcbflow
installer. Therefore, you can git pull and attempt a new pip install .
Thanks - I just pulled, python setup.py install
, and tried the basic example, but still get this error:
python examples/basic/blank.py
Traceback (most recent call last):
File "/Users/russ/Sites/pcbflow/examples/basic/blank.py", line 11, in <module>
brd.fill_layer("GTL", "GND")
File "/Users/russ/.asdf/installs/python/3.10.6/lib/python3.10/site-packages/pcbflow-0.2.0-py3.10.egg/pcbflow/board.py", line 247, in fill_layer
lyr.fill_poly = g.difference(exclusions.buffer(self.drc.clearance))
AttributeError: 'NoneType' object has no attribute 'buffer'
Any idea what am I missing / doing wrong?
Can try pip list
at your terminal and report back which version of shapely
is shown?
pcbflow % pip list | grep shapely
shapely 2.0a1
So, looks like the change didn't force it to update on install?
Try this pip install --upgrade shapely
and pip list
to check the version
I did the dumber version before seeing your comment:
pcbflow % pip uninstall shapely
...
pcbflow % python setup.py install
...
pcbflow % pip list | grep shapely
shapely 2.0.2
pcbflow % python examples/basic/blank.py
Rendering Gerber GTD...
Rendering Gerber GTP...
Rendering Gerber GTO...
Rendering Gerber GTS...
Rendering Gerber GTL...
Rendering Gerber GBL...
Rendering Gerber GBS...
Rendering Gerber GBO...
Rendering Gerber GBP...
Rendering Gerber GBD...
Rendering Gerber GML...
Rendering excellon drill files...
Rendering preview_top.['pdf']...
Rendering preview_top_docu.['pdf']...
Rendering preview_bot.['pdf']...
Rendering preview_bot_docu.['pdf']...
Rendering preview_all.['pdf']...
So, looks like it's working!!
I'm a rubyist, so not really sure why the change to your requirements.txt and pull + re-setup didn't force that dependency update (will this affect others?) -- but thanks so much for helping fix this with me!
Glad its working. I'm not a pip expert, so I'm not sure what to blame for ignoring the requirements spec! On the to do list is to make a package for PyPI to make installation that much easier.
One more question - where / how can I install the sparkfun.lbr
stuff?
The sparkfun.lbr is just an Eagle parts library I use for testing. Unless you need to use parts from existing Eagle part libraries, then its not something you really require. I think there might be a copy in the scripts
folder, but I'm not sure. In any case, it is simply a test file for verifying that pcbflow can read/import parts.
Is it this one - https://github.com/sparkfun/Old-SparkFun-Eagle-Library - the "current" one seems to not have that individual file in. I'm setting up some github actions test running, and sample running for this, and trying to find the library you use for this.
I tried using https://github.com/sparkfun/Old-SparkFun-Eagle-Library/tree/master but it doesn't like it:
python examples/sample/sample.py
WARNING: fanout for R3 requires at least one net name to match against pad names
Traceback (most recent call last):
File "/Users/russ/Sites/pcbflow/examples/sample/sample.py", line 39, in <module>
usb_con = EaglePart(
File "/Users/russ/.asdf/installs/python/3.10.6/lib/python3.10/site-packages/pcbflow-0.2.0-py3.10.egg/pcbflow/eagle.py", line 90, in __init__
tree = ET.parse(self.libraryfile)
File "/Users/russ/.asdf/installs/python/3.10.6/lib/python3.10/xml/etree/ElementTree.py", line 1222, in parse
tree.parse(source, parser)
File "/Users/russ/.asdf/installs/python/3.10.6/lib/python3.10/xml/etree/ElementTree.py", line 580, in parse
self._root = parser._parse_whole(source)
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0
The file appears to be binary, but your code is expecting xml; I guess the one I found is 13 year old lol, so prolly wrong. Could you point me to the right github for this? Or, should I try update to the current eagle libs from them - which I think is https://github.com/sparkfun/SparkFun-Eagle-Libraries
USB-B-SMT
I can only find in https://github.com/sparkfun/SparkFun-Eagle-Libraries/blob/main/SparkFun-Retired.lbr - but no idea if it's the same one
could it be replaced with USB-B-MICRO-SMD
from https://github.com/sparkfun/SparkFun-Eagle-Libraries/blob/main/SparkFun-Connectors.lbr? (It runs / outputs something, but, I'm a noob - so no idea if it's actually "bad" output)
The sparkfun.lbr is just an Eagle parts library I use for testing. Unless you need to use parts from existing Eagle part libraries, then its not something you really require. I think there might be a copy in the
scripts
folder, but I'm not sure. In any case, it is simply a test file for verifying that pcbflow can read/import parts.
Just re-read this - I guess I didn't see the scripts part! thanks.
@ukd1 I presume I can close this issue unless there are any comments?