[PyQt] Deploying PyQt in a C++ Application

Ferguson, Eric W (397B) Eric.W.Ferguson at jpl.nasa.gov
Thu Aug 6 23:22:58 BST 2015


Thanks for answering my questions so quickly. Again, pardon my ignorance
since I am new to python deployment.

Since you said using pydeployqt was possible, I had a few additional
questions regarding that tool:

1.The first tab of the pydeployqt GUI is for your application source.
Since I am embedding python into my C++ application, I don¹t really think
I have an application source. It seems like something has to be specified
on this tab though and I am not sure what to include.

2. I definitely know which PyQt modules and standard library modules I
want to include, so those tabs were easy. However, the location tab is a
bit confusing for me as well. I want to use python2.7 as the interpreter.
The next tab requests the source location for python. Python 2.7 came
preinstalled on my mac - does that include the python source code or do I
need to get a tarballed source from python.org?

3. For the target python locations, I know where to find the python
include directory for 2.7 on my machine. In the tutorial for the python
library, it looks like you are pointing to a static library (.a). Does
this mean I need to statically build the python library before using this
tool, or will the tool do that for me? Do I give it the path to a library
that already exists or is this a path to the library that will be built?

I also noticed your static build section after the pyqtdeploy tutorial
using the command line interface tool. Perhaps I shouldn¹t be using the
pydeployqt GUI and instead should be using that tool instead? If so, how
can I include more than a small sub-set of the standard libraries in my
static build of python?


On 8/6/15, 2:30 AM, "Phil Thompson" <phil at riverbankcomputing.com> wrote:

>On 06/08/2015 5:03 am, Ferguson, Eric W (397B) wrote:
>> Currently, I am developing a C++ GUI application using the Qt
>> framework with OpenGL. Typically this application is driven by user
>> mouse/keyboard input. However, we have recently built a python
>> interface using PyQt so users can  drive the application with simple
>> python scripts. This means that we have an embedded python within our
>> C++ application, and whenever a user loads in a python script, that
>> script imports another script which makes PyQt calls to access certain
>> Qt C++ methods in the application.
>> All of this functionality works in my development environment, but now
>> I would like to deploy my application without requiring users to have
>> PyQt since they will not need to use it directly within their scripts.
>> Ultimately I would like to deploy the application on Mac, Windows and
>> Linux environments. Since I am completely new to python deployment, I
>> did some reading and it seems like I need to include the following in
>> my deployment:
>>   1.  Python interpreter
>>   2.  Python standard libraries ­ Ideally, we want users to have
>> access to all of the standard libraries modules in case they want to
>> do complex python programming within their scripts.
>>   3.  PyQt
>> As a note, right now, I dynamically link in Qt libraries to my
>> application and include those DLLs within the application bundle.
>> So now for my questions:
>>   1.  I read through the pyqtdeploy documentation and it looks like
>> this tool has the capability to statically build all three of the
>> dependencies listed above. However, that tool seems geared towards
>> making complete application binaries. In my case, I would simply want
>> these statically built, and then I would go about linking the
>> dependencies to my application. Would it be feasible to use the
>> pyqtdeploy tool to accomplish my objective?
>Yes. The support for building static versions of dependencies is both
>optional and separate. Pick and choose what you need and how you use the
>pyqtdeploy turns your Python code into C++ source code and a qmake .pro
>file so that you can subsequently turn it into an executable
>application. However there is nothing to stop you doing something
>different - say by changing the .pro file to create a shared library
>that you can link into another application.
>>   2.  I don¹t completely understand the implications of statically
>> building the python interpreter on Windows. It sounds like if I build
>> python statically, I won¹t be able to dynamically import C/C++
>> extension modules. Since I want to include most if not all of the
>> python standard libraries, and the standard library includes C
>> extension modules, then will I have to use a dynamic build of Python
>> on windows?
>>   3.  Let¹s say I did not want to build PyQt statically, but instead
>> wanted to include it as a set of dynamic libraries. When I installed
>> PyQt, it built .so files for each Qt module (QtGui, QtCore, etc.),
>> however, those libraries have Qt dependencies that are dependent on
>> the location of the Qt C++ libraries on my machine. How can I remove
>> the dependencies in those .so files so that they point at a relative
>> path, or is that even possible?
>Those are issues for Qt and qmake in particular - check out qmake
>support for RPATH and also qt.conf.

More information about the PyQt mailing list