Open mikereape opened 2 years ago
@mikereape Could you please elaborate on binder always compllains when ri4w5 it encounters q file that I want excluded
? Ie what kind of error message have you got? Also, what is ri4w5
and q
here?
Also, to double check: is YY
is literally a name for namespace where all your objects located?
Also, does include files that you feed into Binder have any Qt directives aimed for QMake? It is important that input files are proper C++ files.
Thanks,
Hi Sergey
Sorry about the noise in my post. Where it said "binder always complains when ri4w5 it encounters q file that I want excluded" it should simply have said "binder always complains when it encounters a file that I want excluded". What I mean/meant by that is that I get an error like ths:
In file included from /home/mike/binder/all_headers.hpp:2:
/home/mike/X/repos/YY/src/MainUI/MainApplication.h:29:10: fatal error: 'QEvent' file not found
#include <QEvent>
^~~~~~~~
Generate bindings, pass 1...
Sorting Binders...
Sorting Binders... Done.
Writing code...
Writing code... Done.
1 error generated.
Error while processing /home/mike/binder/all_headers.hpp.
mike@gamer:~/X/repos/YY$
and then binder exits immediately without processing anything else. (QEvent is in fact a Qt5 class.)
As I said in my initial post all the stuff I don't want binder to generate bindings for are Qt5 classes that are already wrapped by (having bindings provided by) PyQt5. So just to be double-sure I've included -class directives of the form:
-class QAbstractButton
-class QAbstractItemModel
-class QAction
and changed the -namespace
directives so they look like this:
-namespace QAbstractButton
-namespace QAbstractItemModel
-namespace QAction
with the exact same results but shouldn't the -class
directives by themselves be enough?
I had no difficulties building binder but whenever I have tried to use the --suppress-errors
flag in the binder command it core dumps with no ouput but the core dump message. FYI, My dev machine has a 64 bit AMD processor running Ubuntu 21.10.
I didn't write the code I'm trying to generate bindings for. Someonen else did. I'm just trying to turn it into a full-fledge Python package since it's almost entirely just Python, Qt, PyQt5 and C++ (with a small amount of JS). There are no explcit namespace declarations using the namespace
keyword in the code and whether I include something like --bind=YY
where YY
is the name of the app (and it is an app I'm trying to "packagize") or leave --bind
out altogether the error message is the same.
To answer your question about qmake: no, all the C++ files I'm talking about are genuine C++ files. The codebase has a very clean division between the Qt5 and the C++ (and Python) code. There really isn't anything tricky going on at all. It's all very straightforward.
I have to confess that, relatively speaking, I'm a C++ newbie wannabe and much more a longtime C hacker (among many other things) so apologies in advance if my lack of C++ knowledge is letting me down. OTOH, I have, in fact, studied C++ and its relationship to C extensively.
I also have to say that I think that what you've done with binder is fantastic and amazing and I'm pretty clued up on the Rosetta Project and PyRosetta. (You wrapped 3M+ lines of code? That's almost supernatural!)
I really need to get this working ...
I hope I've answered all your questions. If not, please do just poke me some more.
Thanks very much in advance Mike
Hi sorry I forgot to mention something since it's been awhile since I built binder. If I use your build-and-run-tests.py
script I get this:
Encounter error while executing: cd /home/mike/X/repos/RosettaCommons/binder/test/build && clang++ -O3 -shared -std=c++11 -isystem /home/mike/X/repos/RosettaCommons/binder/build/pybind11/include -I/usr/include/python2.7 -I./.. -I./../.. -I./../../source T00_basic.cpp -o T00_basic.so -fPIC
Encounter error while executing: cd /home/mike/X/repos/RosettaCommons/binder/test/build && clang++ -O3 -shared -std=c++11 -isystem /home/mike/X/repos/RosettaCommons/binder/build/pybind11/include -I/usr/include/python2.7 -I./.. -I./../.. -I./../../source T00_basic.cpp -o T00_basic.so -fPIC
In file included from T00_basic.cpp:9:
In file included from /home/mike/X/repos/RosettaCommons/binder/build/pybind11/include/pybind11/pybind11.h:45:
In file included from /home/mike/X/repos/RosettaCommons/binder/build/pybind11/include/pybind11/attr.h:13:
In file included from /home/mike/X/repos/RosettaCommons/binder/build/pybind11/include/pybind11/cast.h:13:
In file included from /home/mike/X/repos/RosettaCommons/binder/build/pybind11/include/pybind11/pytypes.h:12:
/home/mike/X/repos/RosettaCommons/binder/build/pybind11/include/pybind11/detail/common.h:122:10: fatal error: 'Python.h' file not found
#include <Python.h>
^~~~~~~~~~
1 error generated.
otherwise it builds fine. However, if that could impact on what I wrote about previously could you please advise me on how to specify the location of that file to the build script, and if you know, where Python.h
might be located on Ubuntu please?
Thanks very much in advance Mike
In file included from /home/mike/binder/all_headers.hpp:2: /home/mike/X/repos/YY/src/MainUI/MainApplication.h:29:10: fatal error: 'QEvent' file not found #include <QEvent> -- this is expected behavior: in a way Binder is acting similar to C++ compiler so input files should be valid C++ files and all includes should be findable. Solution for this would be to add path to Qt headers when running Binder using `-I` directive. As I said in my initial post all the stuff I don't want binder to generate bindings for are Qt5 classes that are already wrapped by (having bindings provided by) PyQt5. So just to be double-sure I've included -class directives of the form:
-class QAbstractButton -class QAbstractItemModel -class QAction
Hm... this could be a bit tricky. I am not sure if Python bindings created for PyQt5 will be compatible with what Pybind11 expect: do you by any chance know what framework was used to generate them? Assuming that they are compatible then approach here would be not to exclude Qt classes (this will just disable bindings generation for all classes/functions that uses Qt types) but instead somehow generate "empty bindings". The later directly is not supported but i think could be emulated by creating "empty binder" template function and then use Binder config directive "+binder" (see here https://cppbinder.readthedocs.io/en/latest/config.html#config-file-options) to "bind" all Qt classes that needed. This might require a bit of bolier plate (after all one will need to list a lot(?) Qt classes in config) so i would recommend to first double check that this approach will indeed work on some very minimal example.
re errors in build-and-run-tests.py - this ok, error that you posted is just result of python headers was not founds, i would recommend to just ignore this and run without testing.
Hope this helps,
Hi Sergey I take your points very much in mind and will check out what you suggest. As it happens I was just in the process of putting together a "minimal" example using one of the subdirectories in the src dir. Thanks very much indeed for your reply and your enduring patience with me. We've all gotta start somewhere, right? When I have something to report I'll report back. It may be a few days. It doesn't mean I've gone away. Thanks very much, Mike
Hi I'm back (finally!) I can't find it now but somewhere along the way I'm sure you asked me if the codebase uses QML and I said no as I thought you had said that could be another complicating factor (or maybe I read it somewhere else in something else you wrote). Anyway, I was wrong. The codebase does in fact use QML. Any comment? On a tangential question, and I don't expect you to know the answer cause I suspect you're mostly a Fedora person, Can you think of any reason, given whatever knowledge you have of Debian and the deb package tools, why I wouldn't be able to do the equivalent of "debian install" as part of creating a Debian package. Reason is I pretty much build everything in Docker and then package it as a Debian package and then use dpkg to install it locally on my dev machine if in fact I want it running locally on my dev machine as opposed to running in docker. Of course, with Debian based docker images, it's very convenient to just install the deb package as well. Thanks very much in advance. Best, Mike
@mikereape re QML: best way around it would probably be to feed Binder source files after QML pre-processor was worked on then (i am assuming that there is point where Qt build tools convert QML sources into C++).
re Debian package: not sure if i fully understand your question but if you meant if it is possible to create Binder package on Debian then i do not see why not, - should work as far as a know...
Hi Sergey I'm sure I'm just overlooking somethnig obvious.
I (think) I'm haing problems gettnig binder to take the config file into account. The over all structure is very simple. I have a lot of entries that have this general pattern:
and this general pattern:
That is it's all Qt5 stuff that's wrappeed already by PyQ5 so I just want them excluded from Binder's consideration. However no matter what I do (it seems like) the config file seems to not be recognised and binder always compllains when ri4w5 it encounters q file that I want excluded.
My list of all the headers fille is just a long list of includes of this form:
I invoke binder with a command like this:
I'd be extremely gratefull for any suggestions_.
Thanks in advance Mike