1
0
mirror of https://github.com/thp/pyotherside.git synced 2025-01-28 23:52:55 +08:00

PyOtherSide 1.6.0

This commit is contained in:
Thomas Perl 2022-08-05 13:48:28 +02:00
parent 2a468b0ecc
commit 63eb5290d5
21 changed files with 25 additions and 198 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@
/qtquicktests/qtquicktests /qtquicktests/qtquicktests
/qtquicktests/target_wrapper.sh /qtquicktests/target_wrapper.sh
/examples/__pycache__ /examples/__pycache__
/docs/_build

View File

@ -2,7 +2,7 @@ PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6
ISC License ISC License
Copyright (c) 2011, 2013-2020, Thomas Perl <m@thp.io> Copyright (c) 2011, 2013-2022, Thomas Perl <m@thp.io>
Permission to use, copy, modify, and/or distribute this software for any Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above purpose with or without fee is hereby granted, provided that the above

View File

@ -41,16 +41,16 @@ master_doc = 'index'
# General information about the project. # General information about the project.
project = u'PyOtherSide' project = u'PyOtherSide'
copyright = u'2014-2020 Thomas Perl' copyright = u'2014-2022 Thomas Perl'
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '1.5' version = '1.6'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '1.5.9' release = '1.6.0'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.

View File

@ -17,7 +17,7 @@ and continuation-passing style function calls.
Qt 6 Support Qt 6 Support
============ ============
.. versionadded:: UNRELEASED .. versionadded:: 1.6.0
PyOtherSide now supports Qt 6 while retaining source compatibility with Qt 5. PyOtherSide now supports Qt 6 while retaining source compatibility with Qt 5.
@ -1192,186 +1192,11 @@ pass a suitable ``python-config`` to ``qmake`` at configure time:
Alternatively, you can edit ``python.pri`` manually and specify the compiler Alternatively, you can edit ``python.pri`` manually and specify the compiler
flags for compiling and linking against Python on your system. flags for compiling and linking against Python on your system.
Building for Android
--------------------
There is no Python or Qt present by default and both need to be shipped with the application.
The current solution can be summarized like this:
1. Statically cross-compile Python 3 for Android using the Android NDK
2. Statically compile PyOtherSide against the Android Python build and bundle the Python standard library inside the PyOtherSide binary
3. Use the Qt 5 SDK to make a QtQuick application - the SDK will handle bundling of your application file and of the PyOtherSide binary automatically
A more detailed guide follows. It describes how to get from the source code of the relevant components to being able to run an Android application
with a Qt Quick 2.0 GUI running on an Android device. The `gPodder` podcast aggregator serves as (full featured & fully functional!) example of such an application.
Performed in this environment:
* Fedora 20
* Qt 5.3.1 Android SDK
* latest Android SDK with API level 14 installed
* OpenJDK 1.7
* a few GB of harddrive space
* an Android 4.0+ device connected to the computer that is accessible over ``adb`` (eq. the debugging mode is enabled)
*This is just one example environment where these build instructions have been tested to work. Reasonably similar environments should work just as well.*
The build is going to be done in a folder called ``build`` in the users home directory,
lets say that the use is named ``user`` (replace accordingly for your environment).
We start in the home directory:
.. code-block:: sh
mkdir build
cd build
Now clone the needed projects, load submodules and switch to correct branches.
.. code-block:: sh
git clone --branch fixes https://github.com/thp/python3-android
git clone https://github.com/thp/pyotherside
git clone --recursive https://github.com/gpodder/gpodder-android
Next we will build Python 3 for Android. This will first download the Android NDK, then Python 3 source code, followed by crosscompiling the Python 3 code for Android on ARM.
*NOTE that this step alone can require multiple GB of harddisk space.*
.. code-block:: sh
cd python3-android
make all
As the next step we modify the ``python.pri.android`` file to point to our Python build. If should look like this as a result (remember to modify it for your environment):
.. code-block:: qmake
QMAKE_LIBS += -L/home/user/build/python3-android/build/9d-14-arm-linux-androideabi-4.8/lib -lpython3.3m -ldl -lm -lc -lssl -lcrypto
QMAKE_CXXFLAGS += -I/home/user/build/python3-android/build/9d-14-arm-linux-androideabi-4.8/include/python3.3m/
Then copy the file over the python.pri file in the PyOtherSide project directory:
.. code-block:: sh
cd ..
cp python3-android/python.pri.android pyotherside/python.pri
PyOtherSide can also help us ship & load the Python standard library if we can provide it a suitable zip bundle, which can be created like this:
.. code-block:: sh
cd python3-android/build/9d-14-arm-linux-androideabi-4.8/lib/python3.3/
zip -r pythonlib.zip *
cd ../../../../..
For PyOtherSide to include the packed Python standard library it needs to be placed in its src subfolder:
.. code-block:: sh
mv python3-android/build/9d-14-arm-linux-androideabi-4.8/lib/python3.3/pythonlib.zip pyotherside/src/
PyOtherSide will then use the qrc mechanism to compile the compressed standard library during inside it's own binary. This removes the need for us to handle its shipping & loading ourself.
Next you need to build PyOtherSide with QtCreator from the Qt 5.3 Android SDK, so make sure that the Qt 5.3 Android kit is using the exact same NDK that has been used to build Python 3 for Android. To do that go to *settings*, find the *kits* section, select the Android kit and make sure that the NDK path points to:
``/home/user/build/python3-android/sdk/android-ndk-r9d``
Next open the pyotherside/pyotherside.pro project file on QtCreator, select the Android kit and once the project loads go to the *project view* and make sure that under *run* the API level is set to 14 (this corresponds to Android 4.0 and later). The Android Python 3 build has been built for API level 14 and our PyOtherSide build should do the same to be compatible.
Also make sure that shadow build is disabled, just in case.
Once done with the configuration got to the *build* menu and select the *built pyotherside* option - this should build PyOtherSide for Android and statically compile in our Python build and also include the Python standard library zip file with qrc.
As the next step we need to move the PyOtherSide binary to the QML plugin folder for the Qt Android SDK, so that it can be fetched by the SDK when building gPodder.
Let's say we have the SDK installed in the ``/opt`` directory (default for the Qt SDK installer on Linux), giving us this path to the plugin folder:
``/opt/Qt5.3/5.3/android_armv7/qml``
First create the folder structure for the pyotherside plugin:
.. code-block:: sh
mkdir -p /opt/Qt5.3/5.3/android_armv7/qml/io/thp/pyotherside
Then copy the pyotherside binary and *qmldir* file to the folder:
.. code-block:: sh
cp pyotherside/src/libpyothersideplugin.so /opt/Qt5.3/5.3/android_armv7/qml/io/thp/pyotherside/
cp pyotherside/src/qmldir /opt/Qt5.3/5.3/android_armv7/qml/io/thp/pyotherside/
Next open the gPodder project in QtCreator (gpodder-android/gpodder-android.pro) and again make sure the Android kit is selected, that the API level 14 is used and that *shadow build* is disabled. Then just press the *Run* button and the SDK should build an Android APK that includes the libpyotherside binary (it fetched automatically from the plugins directory because is referenced in the gPodder QML source code) and deploy it to the device where gPodder should be started.
.. _gPodder: http://gpodder.org/
Building for Windows
--------------------
On Windows (tested versions: Windows 7), you need to download:
1. Qt 5 (VS 2010) from `qt-project.org downloads`_ (tested: 5.2.1)
2. `Visual C++ 2010 Express`_ with `SP1`_
3. Python 3 from `python.org Windows downloads`_ (tested: 3.3.4)
We use VS 2010 instead of MinGW, because the MinGW version of Qt depends on
working OpenGL driver, whereas the non-OpenGL version uses Direct3D via ANGLE.
Also, Python is built with Visual C++ 2010 Express (see `Compiling Python on
Windows`_), so using the same toolchain when linking all three components (Qt,
Python and PyOtherSide) together makes sense.
The necessary customizations for building PyOtherSide successfully on Windows
have been integrated recently, and are available since PyOtherSide 1.3.0.
.. _qt-project.org downloads: http://qt-project.org/downloads
.. _Visual C++ 2010 Express: http://www.visualstudio.com/en-us/downloads/download-visual-studio-vs#DownloadFamilies_4
.. _SP1: https://www.microsoft.com/en-US/download/details.aspx?id=23691
.. _python.org Windows downloads: http://python.org/downloads/windows/
.. _Compiling Python on Windows: http://docs.python.org/devguide/setup.html#windows-compiling
Once these pre-requisites are installed, you need to make some customizations
to the build setup:
1. In ``src/qmldir``: Change ``plugin pyothersideplugin`` to ``plugin
pyothersideplugin1``. This is needed, because on Windows, the library
version gets encoded into the library name.
2. In ``python.pri``: Modify it so that the Python 3 ``libs/`` folder is
added to the linker path, and link against ``-lpython33``. Also, modify
it so that the Python 3 ``include/`` folder is added to the compiler flags.
Example ``python.pri`` file for a standard Python 3.3 installation on Windows:
.. code-block:: qmake
QMAKE_LIBS += -LC:\Python33\libs -lpython33
QMAKE_CXXFLAGS += -IC:\Python33\include\
With the updated ``qmldir`` and ``python.pri`` files in place, simply open
the ``pyotherside.pro`` project file in Qt Creator, and build the project.
Configure a **Release Build**, and *disable* **Shadow Builds**.
To install PyOtherSide into your Qt installation, so that the QML import works
from other projects:
1. Make sure the PyOtherSide project is opened in Qt Creator
2. In the left column, select **Projects**
3. Make sure the **Run** tab (Run Settings) of your project is selected
4. In **Deployment**, click **Add Deploy Step** and select **Make**
5. In the **Make arguments:** field, type ``install``
6. Hit **Run** to install PyOtherSide in your local Qt folder
7. Dismiss the "Custom Executable" dialog that pops up
Known Problems:
* **Qt Resource System** importing might not fully work on Windows
ChangeLog ChangeLog
========= =========
Version UNRELEASED (YYYY-MM-DD) Version 1.6.0 (2022-08-05)
------------------------------- -------------------------------
* Support for **Qt 6** (Qt 5 is still supported for now) * Support for **Qt 6** (Qt 5 is still supported for now)
@ -1379,6 +1204,7 @@ Version UNRELEASED (YYYY-MM-DD)
from the converter are now valid as long as the ``PyObject`` is alive (previously from the converter are now valid as long as the ``PyObject`` is alive (previously
they were valid until the next string conversion or until converter was destroyed) they were valid until the next string conversion or until converter was destroyed)
* Fixed ``image_loader`` and ``imageprovider_svg_data`` examples * Fixed ``image_loader`` and ``imageprovider_svg_data`` examples
* Removed outdated build instructions for Android and Windows
Version 1.5.9 (2020-01-17) Version 1.5.9 (2020-01-17)
-------------------------- --------------------------

View File

@ -1,2 +1,2 @@
PROJECTNAME = pyotherside PROJECTNAME = pyotherside
VERSION = 1.5.9 VERSION = 1.6.0

View File

@ -1,7 +1,7 @@
/** /**
* PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6 * PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6
* Copyright (c) 2011, 2013-2020, Thomas Perl <m@thp.io> * Copyright (c) 2011, 2013-2022, Thomas Perl <m@thp.io>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above

View File

@ -1,7 +1,7 @@
/** /**
* PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6 * PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6
* Copyright (c) 2011, 2013-2020, Thomas Perl <m@thp.io> * Copyright (c) 2011, 2013-2022, Thomas Perl <m@thp.io>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above

View File

@ -1,7 +1,7 @@
/** /**
* PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6 * PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6
* Copyright (c) 2011, 2013-2020, Thomas Perl <m@thp.io> * Copyright (c) 2011, 2013-2022, Thomas Perl <m@thp.io>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above

View File

@ -1,7 +1,7 @@
/** /**
* PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6 * PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6
* Copyright (c) 2011, 2013-2020, Thomas Perl <m@thp.io> * Copyright (c) 2011, 2013-2022, Thomas Perl <m@thp.io>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above

View File

@ -1,7 +1,7 @@
/** /**
* PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6 * PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6
* Copyright (c) 2011, 2013-2020, Thomas Perl <m@thp.io> * Copyright (c) 2011, 2013-2022, Thomas Perl <m@thp.io>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above

View File

@ -1,7 +1,7 @@
/** /**
* PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6 * PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6
* Copyright (c) 2011, 2013-2020, Thomas Perl <m@thp.io> * Copyright (c) 2011, 2013-2022, Thomas Perl <m@thp.io>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above

View File

@ -1,7 +1,7 @@
/** /**
* PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6 * PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6
* Copyright (c) 2011, 2013-2020, Thomas Perl <m@thp.io> * Copyright (c) 2011, 2013-2022, Thomas Perl <m@thp.io>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above

View File

@ -1,7 +1,7 @@
/** /**
* PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6 * PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6
* Copyright (c) 2011, 2013-2020, Thomas Perl <m@thp.io> * Copyright (c) 2011, 2013-2022, Thomas Perl <m@thp.io>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above

View File

@ -1,7 +1,7 @@
/** /**
* PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6 * PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6
* Copyright (c) 2011, 2013-2020, Thomas Perl <m@thp.io> * Copyright (c) 2011, 2013-2022, Thomas Perl <m@thp.io>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above

View File

@ -1,7 +1,7 @@
/** /**
* PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6 * PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6
* Copyright (c) 2011, 2013-2020, Thomas Perl <m@thp.io> * Copyright (c) 2011, 2013-2022, Thomas Perl <m@thp.io>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above

View File

@ -1,7 +1,7 @@
/** /**
* PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6 * PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6
* Copyright (c) 2011, 2013-2020, Thomas Perl <m@thp.io> * Copyright (c) 2011, 2013-2022, Thomas Perl <m@thp.io>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above

View File

@ -1,7 +1,7 @@
/** /**
* PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6 * PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6
* Copyright (c) 2011, 2013-2020, Thomas Perl <m@thp.io> * Copyright (c) 2011, 2013-2022, Thomas Perl <m@thp.io>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above

View File

@ -1,7 +1,7 @@
/** /**
* PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6 * PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6
* Copyright (c) 2011, 2013-2020, Thomas Perl <m@thp.io> * Copyright (c) 2011, 2013-2022, Thomas Perl <m@thp.io>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above

View File

@ -1,7 +1,7 @@
/** /**
* PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6 * PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6
* Copyright (c) 2011, 2013-2020, Thomas Perl <m@thp.io> * Copyright (c) 2011, 2013-2022, Thomas Perl <m@thp.io>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above

View File

@ -1,7 +1,7 @@
/** /**
* PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6 * PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6
* Copyright (c) 2011, 2013-2020, Thomas Perl <m@thp.io> * Copyright (c) 2011, 2013-2022, Thomas Perl <m@thp.io>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above

View File

@ -1,7 +1,7 @@
/** /**
* PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6 * PyOtherSide: Asynchronous Python 3 Bindings for Qt 5 and Qt 6
* Copyright (c) 2011, 2013-2020, Thomas Perl <m@thp.io> * Copyright (c) 2011, 2013-2022, Thomas Perl <m@thp.io>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above