-
Notifications
You must be signed in to change notification settings - Fork 115
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
major rewrite to work with current Go versions #180
Conversation
…ncodes type name along with counter and does type-safe checks so it won't fail on the conversion. bind command builds using pybindgen.
…e working. build side is good.
… always need to convert back and forth to / from pointer for handle
…and now can switch to int64 instead of string keys as py wrapper makes string less important.
… multiple packages easily in python -- look into install etc
…y; interface methods don't create symbols, but turns out nil obj is ok..
…ipped. e.g., channels.
… figured out how to navigate python packages finally..
…le registry being diff for each .so compiled library: need to now make mega-libraries.
… -- computed simply. everything always scoped by pkg name in prep for integrated multi-package output.
…ent mostly working.
…std library packages too
…go.nil. all working for emergent/leabra python script.
…d in order, so now need to sort the pywrap struct output so embedded are always earlier..
…ild. use Embed method on all struct method calls to get proper virtual function calling.
I guess I can look into this -- some issues with the environment on travis: # pkg-config --cflags -- /opt/pyenv/lib/pkgconfig/python3.pc
320 Failed to open '/opt/pyenv/lib/pkgconfig/python3.pc': No such file or directory
321 No package '/opt/pyenv/lib/pkgconfig/python3.pc' found
322 pkg-config: exit status 1 this does not look promising: travis-ci/travis-ci#8217 I'm currently moving so may not be able to do this for a few days. |
yeah, that's why (and also b/c of Windows) there's this perhaps it would need to be refactored into its own package so it could be used from
no worries. (I've just emerged from my email backlog of a 3 weeks holidays...) |
Umm.. it looks like it is now just working!? |
that's this is my latest attempt: https://travis-ci.org/go-python/gopy/builds/566516723 |
now that this is all in a branch (pr-180) I don't seem to have push access.. In testing on my linux VM, I was able to replicate the error, and fixed it by setting the # ld needs to look in current directory to load the _go.so library
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. we presumably need to add this to the README.md as well, for anyone running on linux without this set. somehow mac defaults to using . automatically, so it didn't come up there. |
thanks for tackling this (and your persistance). it's better: but there are still a couple of failures (some are what seems to be the eg:
hth, |
ok. we will need different "want" outputs for py2 vs. py3 :( |
I have no idea what this conflict thing is about -- I just edited .travis.yml trivially to resolve, but now it is causing merge problems -- must have been some kind of whitespace? hopefully you can resolve at final merge? also, it looks like mac vs. linux has different output -- tests all pass (except v2 vs. v3 diffs) on my mac but not on linux -- I don't suppose you have any experience with that? should we just target linux given that is what runs on travis? |
…o later -- will file ticket
I verified that "go test" passes all tests on linux when only using py3, and filed an issue for adding separate want target for py2. If this works on travis, then it would be great to just merge this thing and do additional work from there. It looks like something bad is happening with this conflict (or something else) that is now preventing travis from running: https://travis-ci.org/go-python/gopy/requests there is also a possibility that the environment on travis works differently than my "go test" run on my linux vm, in which case we have another problem.. |
I've been tracking the activity in this pr-180 branch and decided to give the current state a test in my project. My project currently has been using a hand-rolled combination of Building using python-2.7, with It seems a bit fiddly with regards to modules vs $GOPATH. I had to disable GO111MODULE and make sure gopy and my project were in $GOPATH so it could find everything. The LDFLAGS don't seems to include something like My project defines quite a lot of packages and the cmds/gopytest/main.go has quite a big import chain, so I was pretty impressed to find that I was able to make a successful call through the generated module right off the bat:
Now my question is about the fields that are part of the result. type Result struct {
Things []*api.Thing
} I found that my Also I found that the Really interested in this branch, and thanks for all the work! |
@justinfx -- you can specify multiple packages to process (edit: directly in the gopy args), and you might get better results by including the api package directly -- that might cause it to properly interpret the handles as I'm pretty sure most of my current real-world use cases are slices of interface types and those all seem to be working properly without any bare handles being exposed. Also, adding an additional LDFLAGS would be a good idea. I'm not sure if the current cgo versions of those env vars might already work? look that up and give it a try if you didn't already. |
I ended up creating a small test project and submitting #191 to illustrate the problem with the multiple packages and slice of structs.
Per #191 I tried interfaces but still saw handles :-/
Setting |
oops, I tried to fixup the merge conflicts using the github web editor but it seems it committed my changes into your |
This is a major rewrite, using the idea of int64 handles instead of passing pointers around in cgo / python. It all works, and along the way lots of additional functionality added to be able to handle full multi-package systems, and even generate a standalone python executable as was needed for my GoGi gui system where the main thread is taken up by the gui event loop.
tests all pass for py3 but py2 has some different output sequencing so produces diff outputs sometimes.
I also switched over to using pybindgen for speed on cpython (and ease of use) -- cffi should be possible and not too hard (hopefully just changing the generating of the build.py script). It handles all the lower-level glue so the cgo wrappers and .py wrappers all look very straightforward. Switched to more go-standard camel-case, shorter naming style instead of all the kebab-case cgo names that I found hard to parse.. generated code seems pretty readable to me now.
.py wrappers support full container features on maps and slices. constants are just directly declared in .py wrapper -- no going through go. arrays are treated as go-generated only given their fixed size -- use slices for any py-side created lists.
overall, the translation for a given .go file to python do the same thing with the wrapped code is remarkably similar and illustrates the great fit between the two languages -- go is a nice subset of python and using go for fast backend computation makes a lot of sense. see the GoGi demo case linked on the updated README.md for an example.