MitjaNemec / Kicad_action_plugins

Kicad action plugins
414 stars 62 forks source link

Open issues with python3 #36

Closed T0jan closed 4 years ago

T0jan commented 5 years ago

As mentioned in the kicad forum thread, there are open issues with the scripts on python3 systems. only swap_pins, swap_units and Pad2Pad_Distance plugin appear in the external plugin list after refreshing, every other plugin is missing.

Pad2Pad_distance raises an AttributeError: module 'pad2pad_track_distance' hads no attribute 'Distance' for code line 95 for action_pad2pad_track_distance.py

swap_pins raises an AttributeError: module 'wx' has no attribute 'wx' for line 49 in action_swap_pins.py

swap_units raises an AttributeError: module 'wx' has no attribute 'wx' for line 49 in action_swap_units.py

Kicad info:

Application: kicad
Version: 5.1.0-060a0da~80~ubuntu18.04.1, release build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.58.0 OpenSSL/1.1.0g zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3
Platform: Linux 4.15.0-46-generic x86_64, 64 bit, Little endian, wxGTK
Build Info:
    wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.22
    Boost: 1.65.1
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.58.0
    Compiler: GCC 7.3.0 with C++ ABI 1011

Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=ON
    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
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=ON
MitjaNemec commented 5 years ago

Are you sure that the snippets are from before and after, as there is no difference between them. Also could you paste a section where log says for unit 2

Regarding the logging, I should have fixed this by now and it should work also under python3. Delete selected does not generate the log, and I'll probably delete this plugin as the same functionality can be achieved with selection filtering, that is natively present in KiCad.

T0jan commented 5 years ago

Are you sure that the snippets are from before and after, as there is no difference between them.

Yeah I checked it again. the difference is in the unit I posted a few days ago (https://github.com/MitjaNemec/Kicad_action_plugins/issues/36#issuecomment-494064435)

Also could you paste a section where log says for unit 2

the log points for unit 2 to the first component of the schematic independent from what a component this is.

Regarding the logging, I should have fixed this by now and it should work also under python3

Jep works now for all plugins.

MitjaNemec commented 5 years ago

the log points for unit 2 to the first component of the schematic independent from what a component this is. Aaaaaa. So just to confirm, for example if you want to swap units 2 and 3 in IC4201, the log points to the unit 3 of the IC201 and IC201 is the first one in the .sch file? Obviously your design is more complex than my test cases, and I'll need to update my test suite. Is there a way you could share your project with me? You don't need to attach it here, you can look me up on google and you should find my email and send it over email. If you can't, I understand, but it will likely take a bit more time.

BTW, I'll be offline from tomorrow till 10th of June

T0jan commented 5 years ago

Aaaaaa. So just to confirm, for example if you want to swap units 2 and 3 in IC4201, the log points to the unit 3 of the IC201 and IC201 is the first one in the .sch file?

no I wanted to switch unit 1 and 2 of IC4201. IC4201 is the same as IC201 but in a different sheet. the log points for the second unit every time to the first symbol in the schematic, in my case this is a resistor. the other two units I presented you above I searched for myself in the schematic.

Is there a way you could share your project with me?

I will setup a demo-project which covers this issue. May take a while.

MitjaNemec commented 5 years ago

in my case this is a resistor.

Can you paste in a description block from the .sch file for this resistor.

T0jan commented 5 years ago

sorry it is a capacitor but here it is:

$Comp
L some_lib:100n@50V[0603] C?
U 1 1 5C8ABC3B
P 2850 2300
AR Path="/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C173F2E/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C249527/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C301C11/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C310E33/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C320055/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C37F005/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C3906DA/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C39066B/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C390607/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C32F277/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5BFE0C05/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5BFE0C17/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5BFE0C29/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C8AB945/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C903BD2/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C925F8C/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C938119/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C941E60/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C9466A8/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C9898F2/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C94EE49/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C965B42/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5C965B98/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5CB5FA73/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5CB5FA92/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5CB5FAB1/5C8ABC3B" Ref="C?"  Part="2" 
AR Path="/5CAC71BF/5C8ABC3B" Ref="C201"  Part="1" 
AR Path="/5CB3E342/5C8ABC3B" Ref="C1201"  Part="1" 
AR Path="/5CB582E3/5C8ABC3B" Ref="C2201"  Part="1" 
AR Path="/5CA3C508/5C8ABC3B" Ref="C3201"  Part="1" 
AR Path="/5CA43896/5C8ABC3B" Ref="C4201"  Part="1" 
AR Path="/5CA4FBFD/5C8ABC3B" Ref="C5201"  Part="1" 
F 0 "C201" H 2550 2350 50  0000 L CNN
F 1 "100n@50V[0603]" V 3000 1850 50  0000 L CNN
F 2 "some_lib:C0603" H 2880 2450 50  0001 C CNN
F 3 "" H 3060 2615 50  0001 C CNN
F 4 "C0603C104K5RACTU" H 2110 2715 50  0001 C CNN "MPN"
    1    2850 2300
    1    0    0    -1  
$EndComp
MitjaNemec commented 5 years ago

Thanks. It looks like I am just looking for the reference number (4201 from the C4201). I'll have to confirm it

T0jan commented 5 years ago

here the promised test project, once before and once after using the switch_units plugin:

test_before_switch.zip test_after_switch.zip

MitjaNemec commented 5 years ago

Thanks. I'll attack this when I come back

MitjaNemec commented 5 years ago

Ok I am back on it and for the life of me, I can not recreate it with the test project. Can you please rerun on the test project and attach the .log file?

T0jan commented 5 years ago

the log is in test_after_switch.zip

MitjaNemec commented 5 years ago

Sorry, my mistake. It did not occurred to me that I would look for it there. I'll dig in.

MitjaNemec commented 5 years ago

Ok, I definitely cannot recreate it, so I've added a bit of instrumentation and I'd like you to run the plugin on the test project again, and send me .log and project after the plugin finishes.

I suspect it is python2/python3 issue.

T0jan commented 5 years ago

sorry I had some other stuff to cover but here is the requested updated project (the issue is still there):

test.zip

MitjaNemec commented 5 years ago

It is not a problem, I am also having a slow tempo. Anyhow I've managed to get windows python3 build and I can not recreate the issue so it will take some additional testing. To this end, I've fixed a bug how is the location of the symbols within .sch file logged and I've changed the criteria how are the symbols located (from filter to list comprehension)

So I'd appreciate if you could test the latest version again. Thank you

T0jan commented 5 years ago

still kills the B unit

swap_units.log

MitjaNemec commented 5 years ago

From the log, I can see that you tried the old version (24). The newest has the version number 32. So I'd like you to try again with the latest version. Thanks.

T0jan commented 5 years ago

are you sure you pushed the changes? I tried again a few moments ago after I checked if I have the latest master version (I did) and it states again v24 in the log

MitjaNemec commented 5 years ago

Yup, this it the version.txt file opened via GitHub web interface. Maybe a cache issue? Untitled

T0jan commented 5 years ago

yeah sorry was a stupid layer 8 problem ^^

nevertheless, swap units now raises an exception:

swap_units.log

MitjaNemec commented 5 years ago

Sorry bout that, it was a stupid mistake. I really should implement pre-commit hook which would run all the automated test to spot this kin of mistakes.

T0jan commented 5 years ago

ok seems to be fixed, at least for the test project it works now. but the logging seems to be broken:

swap_units.log

but after your recent changes net2net distance crashes:

net2et_distance.log

MitjaNemec commented 5 years ago

Whoa, finally. As for the logging issue, I'll have to ask @qu1ck as this is his solution to the wxpython3/4 compatibility issue. Obviously it hijacks the log.

as for the net2net issue, I assume the you did not have any tracks on either of the nets, and I didn't handled the case properly, I've added a quick fix for it, but I'll have to let the user know when this happens.

qu1ck commented 5 years ago

Regarding logging, the only thing broken there is wxpython printing stuff to stderr when it's not asked to do so. That's questionable practice but it is library dev's decision.

I guess we can swap the order of calls and try SetSizeHints() before SetSizeHintsSz() to avoid that warning.

MitjaNemec commented 5 years ago

Thanks for the info, I was thinking in the same way. But now that I've had a chance to sleep on it I think I might have an underlying issue. The swap_units plugin opens the log, but the actual log message comes from delete_selected plugin. I suspect the the delete_selected was called (executed) after the swap_units was called. And as swap_units closed the log, the log is opened again and rewritten. I'll have to check this.

nickoe commented 5 years ago

@MitjaNemec do you still need a windows build with python3?

MitjaNemec commented 5 years ago

@nickoe Yes please.

I've tried [the one] (https://kicad-downloads.s3.cern.ch/windows/testing/patched/kicad-patched-390-5.1.2-148-gf0ac61a8f-x86_64.exe) you prepared for me to at the end of June (21st) but even though the version information shows KICAD_SCRIPTING_PYTHON3=ON, it has python 2.7. Given the workload you guys are dealing with, I restrained myself to bug you about it.

I do remember having and successfully trying out the first release offered by you on 14.8.2018 (kicad-patched-88-review-8244-gef7a2fcc3-x86_64.exe) but I've deleted the installer short after I've tested it.

nickoe commented 5 years ago

@MitjaNemec pleade check if python3 is properly enabled in https://kicad-downloads.s3.cern.ch/windows/testing/patched/kicad-patched-491-8f583008e-x86_64.exe This is the master branch.

MitjaNemec commented 5 years ago

While the KiCad build information states KICAD_SCRIPTING_PYTHON3=ON the python.exe interpreter within the \bin subfolder states that it is 2.7.15.

Also it gladly executes print statement without round brackets, which should cause an exception under python3

print "Hello"
MitjaNemec commented 4 years ago

@nickoe Any progress with windows build with python3 enabled

nickoe commented 4 years ago

@MitjaNemec I didn't really do much, I guess I didn't see your previous reply.

I don't remember the state of it, but now I triggered a build with the packaging scripts of the branch name python3 and the lastest kicad master.

It is building on https://jenkins.simonrichter.eu/job/windows-kicad-msys2-patch/501/

If it succeeds, can you please check it again?

MitjaNemec commented 4 years ago

@nickoe don't worry about it the fault is on my side, as I didn't consider that you will not be notified of my message without mention you in it. I've still have to learn how all the details of GitHub. As for the build, thanks for trying but the build failed.

nickoe commented 4 years ago

@MitjaNemec ok, that was a hiccup in upstream code. I triggered a rebuild and the binary should be available at https://kicad-downloads.s3.cern.ch/windows/testing/patched/kicad-patched-502-8c2ee6c02-x86_64.exe

MitjaNemec commented 4 years ago

@nickoe Still the same, KiCad reports KICAD_SCRIPTING_PYTHON3=ON, while the python.exe interpreter within the \bin subfolder states that it is 2.7.15. If I would venture a guess, I'd say that there is something wrong with the build pipeline. BTW, should we move this discussion elsewhere?

nickoe commented 4 years ago

@MitjaNemec Please create an issue on https://github.com/KiCad/kicad-winbuilder/issues