turdusmerula / kipartman

Kicad parts manager and BOM extension tool
GNU General Public License v3.0
6 stars 2 forks source link

Au 17w45 a 1st integration #1

Closed auphofBSF closed 6 years ago

auphofBSF commented 6 years ago

This project by @turdusmerula shows great promise, but I have had difficulty getting kipartman up and running, kipartbase seemed to function correctly.

My Environment is Windows 10, With Kicad (fairly recent Nightly Build) version details below.

I have tested on an Ubuntu 16, with the current stable Kicad and found the same issues I initially found on Win10 so have progressed on Win10 instance to resolve some issues, such that I can evaluate.

With these modifications, I have some basic functionality working. Various errors still being thrown in console.

Execution Notes:

It is necessary to execute the Kicad Python instance for pcbnew interfacing to work. I tried by using a virtual env (Anaconda Conda-env) but unable to import pcbnew

Executing for testing from an working directory , Win10 CMD (Administrator Mode for Dependencies install)

"C:/Program Files/KiCad/bin/python.exe" -m pip install kipartman ( Installs all necessary dependencies) There may have been some manual installations of dependencies (I did not keep full notes)

Development/Debug environment setup

substitute your own directory where <local-kipartman.git-repo-dir>

git clone https://github.com/auphofBSF/kipartman.git  <local-kipartman.git-repo-dir>
cd <local-kipartman.git-repo-dir>
git checkout Au17w45A-1stintegration

In a second Win10 CMD window (launch kipartbase)

cd <local-kipartman.git-repo-dir>
"C:/Program Files/KiCad/bin/python.exe" -m kipartbase

in the first Win10CMD window (launch kipartman)

cd <local-kipartman.git-repo-dir>
"C:/Program Files/KiCad/bin/python.exe" -m kipartman

Changes are mostly relating to wxPython/wxWidget method calls.

Is there something I am missing in the Install of KiPartman to make it just work from the current base:master Branch

Kicad Version details--------------------------------------

Application: kicad Version: (2017-10-30 revision 6300041ce)-makepkg, release build Libraries: wxWidgets 3.0.3 libcurl/7.54.1 OpenSSL/1.0.2l zlib/1.2.11 libssh2/1.8.0 nghttp2/1.23.1 librtmp/2.3 Platform: Windows 8 (build 9200), 64-bit edition, 64 bit, Little endian, wxMSW Build Info: wxWidgets: 3.0.3 (wchar_t,wx containers,compatible with 2.8) Boost: 1.60.0 Curl: 7.54.1 Compiler: GCC 7.1.0 with C++ ABI 1011

Build settings: USE_WX_GRAPHICS_CONTEXT=OFF USE_WX_OVERLAY=OFF KICAD_SCRIPTING=ON KICAD_SCRIPTING_MODULES=ON KICAD_SCRIPTING_WXPYTHON=ON KICAD_SCRIPTING_ACTION_MENU=ON BUILD_GITHUB_PLUGIN=ON KICAD_USE_OCE=ON KICAD_SPICE=ON

turdusmerula commented 6 years ago

I tested it essentially on Ubuntu with last wxPython release (4.0.0b2). Most of errors I had until now were related to Wx itself and were not fatal so didn't took the time to look further. Edit: I have not yet made it compatible with python 3.x, it is only meant to be run with python 2.7 for now

I never had the occasion to run it on windows, did you eventually managed to run it with the proposed changes?

I'll have a look at your changes :)

turdusmerula commented 6 years ago

Tested it on a virtualenv and yes it can't find kicad. This is due to the fact that kicad is not installed by pip and does not have its libraries in the virtualenv, setting a right python path on kicad may solve the problem, to be tested.

The problems you found with WxPython are less obvious to me, I suspect a version problem but need some further investigation.

auphofBSF commented 6 years ago

Yes, it is working on Windows 10 with the a recent (31Oct) nightly build. I have completed further fixes to get a smoother operation, branch AU17W45B....... https://github.com/turdusmerula/kipartman/compare/master...auphofBSF:AU-17W45B-2nd-Fixes To make it work on windows have to execute in a command terminal, or configure the dev env. with the path to the kicad python.exe as detailed in the pull request. Kicad Python environment only has wxPython (wx.version == '3.0.2.0') with wxWidget 3.03

turdusmerula commented 6 years ago

Never tested it with such an old version of wxWidgets, and your idea to use the kicad python environment is legitimate, had to admit I never did it. I directly used version of wxPython provided by pip, wich integrates well with kicad when it is installed in the system with ubuntu.

I use wxFormBuilder to generate python files from fbp files, it seems the generated code is not well compliant with 3.0.2.0.

The need for kicad is only to provide a way to convert mod footprints to pretty format, maybe this could be turned to an optional dependency with a warning splash.

turdusmerula commented 6 years ago

Question: what is the difference between SetSizeHints and SetSizeHintsSz?

auphofBSF commented 6 years ago

from what I understand (this is all new stuff for me) wxPython(phonix) has overloads for different arguments (the arguments generated by WxFormBuilder) match the method SetSizeHintsSz(Classic)

Phoenix(Docs: SetsizeHints) Phoenix vs Classic

I cant find the WxPython(3) documents that led me to the understanding but WxPython(3/Classic) has 2 methods SetSizeHints and SetSizeHintsSz instead of overloads.
I will try and think/research/learn a way we can stick with the current wxFormBuilder (SetSizeHints) and have back support for wxPython(3/Classic)

-------- Additionally -------

I tried not to modify the wxFormBuilder generated code, but had to for 1 instance kipartman/dialogs/panel_edit_model.py my commit -https://github.com/auphofBSF/kipartman/commit/42c98ae737f1d836f132e1e6634bd710139dadb0

turdusmerula commented 6 years ago

Maybe a simple patch on generated code would be enough to make it compliant, it doesn't seem to require a lot of changes.

During merge with your changes I've seen some path work around for windows: url = url.replace('\','/') #Work around for running on Windows Isn't it the role of path.join to take care of the right path separator?

auphofBSF commented 6 years ago

Yes, the changes are minimal, but things like the Img.IsOk() issue a bit more complex. I am trying to think of an elegant way.

The url.replace was due to the url.path.join doing the right thing for windows but we don't want a windows url for a web lookup from kipartbase

example: line 57: kipartman\frames\edit_model_frame.py url = os.path.join(configuration.kipartbase, 'file', self.model.image.storage_path) returns: u'http://localhost:8200\\file\\37/ed/f9/37edf9788c37e9248d3618934f6b8952/ATTINY45-20SU.ATTINY45-20SU.png'

Note the double slash around file

i think line 57 and and all other instances should just be a standard concatenation with '/' separators something like url = '{}/{}/{}'.format(configuration.kipartbase, 'file', self.model.image.storage_path) compliant with Python 2.7 -> 3.x

turdusmerula commented 6 years ago

I pushed your changes from branch AU17W45A-1stIntegration on the master. With wxWidgets 4 it causes some new warnings about usage of obsolete class members but this is not an issue. Only thing I didn't pushed is the default value for currency, I have to take some time to make it configurable from the GUI tool.

I propose to close this pull request and open specific issues for remaining problems.

auphofBSF commented 6 years ago

Sebastian, that sounds great, perfectly understand about the currency, no priority for this feature. I am working on a few other features. I will take a look at the your master branch, I have a few other fixes under the my 2nd-Fixers Branch

https://github.com/auphofBSF/kipartman/compare/AU17W45A-1stIntegration...auphofBSF:AU-17W45B-2nd-Fixes

They all fix issues with functionality across 7 files. Should I create a 2nd Pull request for these ?

As I said I am also working on some new features. What is the best way to discuss/show. I was thinking I will create issues/Feature requests for them and publish working code achieved as Pull requests. Does that work for you?

Your Kipartman is a great start to improving the workflow of component selection and management for the kicad and opensource community.

turdusmerula commented 6 years ago

Best is to open an issue or pull request per bug / feature when possible, then it's easier to discuss each specific point and track its state. I will do the same with my TODO list, tried to make a working starting point but there is still work to do and some nasty parts in this first shot. It should be seen as a proof of concept for now.