Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: Build

on:
push:
branches:
branches:
- main
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash
Expand Down Expand Up @@ -47,14 +47,14 @@ jobs:
libqt5quickwidgets5* \
qtmultimedia5-dev
apt-get clean

- name: Checkout PythonQt
uses: actions/checkout@v5

- name: Ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ runner.os }}-ubuntu-${{ matrix.container_version }}
key: ${{ runner.os }}-ubuntu-${{ matrix.container_version }}
evict-old-files: 'job'

- name: Build PythonQt (generator_only)
Expand Down Expand Up @@ -237,9 +237,9 @@ jobs:
- name: Ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ runner.os }}-${{ matrix.qt-version }}
key: ${{ runner.os }}-${{ matrix.qt-version }}
evict-old-files: 'job'

- name: Detect exact versions
id : versions
run : |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/build_latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: Check generated_cpp

on:
push:
branches:
branches:
- main
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash
Expand All @@ -20,11 +20,11 @@ jobs:
fail-fast: false
matrix:
os: ['ubuntu', 'windows']
qt-version: [ '5.12.*', '5.15.*', '6.10.*' ]
qt-version: [ '5.12.*', '5.15.*', '6.10.0' ]
python-version: [ '3.12' ]
runs-on: ${{ matrix.os }}-latest
steps:

- name: Install MSVC
if: ${{ matrix.os == 'windows' }}
uses: ilammy/msvc-dev-cmd@v1
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
key: ${{ runner.os }}-${{ matrix.qt-version }}
evict-old-files: 'job'
if: ${{ matrix.os == 'ubuntu' }}

- name: Set environment
id: setenv
run: |
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
PYTHONDEVMODE=1 PYTHONASYNCIODEBUG=1 PYTHONWARNINGS=error PYTHONMALLOC=malloc_debug \
UBSAN_OPTIONS="halt_on_error=1" ASAN_OPTIONS="detect_leaks=0:detect_stack_use_after_return=1:fast_unwind_on_malloc=0" \
make check TESTARGS="-platform offscreen"

- name: Build PythonQt Windows (exclude_generator)
shell: cmd
if: ${{ matrix.os == 'windows' }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/builddocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and Deploy Documentation

on:
push:
branches:
branches:
- main

defaults:
Expand All @@ -21,11 +21,11 @@ jobs:

- name: Build documentation
run: |
cd doxygen
cd doxygen
doxygen
touch html/.nojekyll
cd ..

- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
Expand Down
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: "v21.1.5"
hooks:
- id: clang-format


- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-case-conflict
- id: check-merge-conflict
- id: trailing-whitespace
- id: mixed-line-ending
20 changes: 10 additions & 10 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.

Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
Expand Down Expand Up @@ -111,7 +111,7 @@ modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.

GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

Expand Down Expand Up @@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.

1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
Expand All @@ -158,7 +158,7 @@ Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.

2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
Expand Down Expand Up @@ -216,7 +216,7 @@ instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.

Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
Expand Down Expand Up @@ -267,7 +267,7 @@ Library will still fall under Section 6.)
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.

6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
Expand Down Expand Up @@ -329,7 +329,7 @@ restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.

7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
Expand Down Expand Up @@ -370,7 +370,7 @@ subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.

11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
Expand Down Expand Up @@ -422,7 +422,7 @@ conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.

14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
Expand Down Expand Up @@ -456,7 +456,7 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Libraries

If you develop a new library, and you want it to be of the greatest
Expand Down
6 changes: 3 additions & 3 deletions build/PythonQt.prf
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# profile for non-mevis users to link to PythonQt

include ( python.prf )
include ( python.prf )

INCLUDEPATH += $$PWD/../src

# check if debug or release
CONFIG(debug, debug|release) {
DEBUG_EXT = _d
DEBUG_EXT = _d
} else {
DEBUG_EXT =
DEBUG_EXT =
}

PYTHONQT_LIB_NAME=PythonQt-Qt$${QT_MAJOR_VERSION}-Python$${PYTHON_VERSION}$${DEBUG_EXT}
Expand Down
4 changes: 2 additions & 2 deletions build/PythonQt_QtAll.prf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ INCLUDEPATH += $$PWD/../extensions/PythonQt_QtAll

# check if debug or release
CONFIG(debug, debug|release) {
DEBUG_EXT = _d
DEBUG_EXT = _d
} else {
DEBUG_EXT =
DEBUG_EXT =
}


Expand Down
2 changes: 1 addition & 1 deletion build/common.prf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# for all debug builds, add "_d" extension to target
CONFIG(debug, debug|release) {
TARGET = $${TARGET}_d
TARGET = $${TARGET}_d
}

# Allow override (e.g., qmake PYTHONQT_GENERATED_PATH=/abs/path)
Expand Down
6 changes: 3 additions & 3 deletions build/python.prf
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ contains(PKGCONFIG, "python.*"){

# check if debug or release
CONFIG(debug, debug|release) {
DEBUG_EXT = _d
DEBUG_EXT = _d
} else {
DEBUG_EXT =
DEBUG_EXT =
}

isEmpty(PYTHON_PATH):PYTHON_PATH=$(PYTHON_PATH)
Expand All @@ -79,7 +79,7 @@ contains(PKGCONFIG, "python.*"){
} else:unix {
# on linux, python-config is used to autodetect Python.
# make sure that you have installed a matching python-dev package.

PYTHON_CONFIG = $${PYTHON_DIR}/bin/python$${PYTHON_VERSION}-config
PYTHON_CONFIG_OPTIONS_LIBS = --libs
equals(PYTHON_VERSION_MAJOR, 3):!lessThan(PYTHON_VERSION_MINOR, 8) {
Expand Down
83 changes: 42 additions & 41 deletions examples/CPPPyWrapperExample/CPPPyWrapperExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,46 @@
#include <QtGui>
#include <QApplication>

int main (int argc, char* argv[]) {
QApplication app(argc, argv);
PythonQt::init();
PythonQtObjectPtr mainModule = PythonQt::self()->getMainModule();
mainModule.evalScript(QString("import sys\n"));
Q_ASSERT(!mainModule.isNull());
{
// evaluate a python file embedded in executable as resource:
mainModule.evalFile(":eyed3tagger.py");
// create an object, hold onto its reference
PythonQtObjectPtr tag = mainModule.evalScript("EyeD3Tagger()\n", Py_eval_input);
Q_ASSERT(!tag.isNull());
tag.call("setFileName", QVariantList() << "t.mp3");
QVariant fn = tag.call("fileName", QVariantList());
Q_ASSERT(fn.toString() == QString("t.mp3"));
// tag goes out of scope, reference count decremented.
}
{
// Allow the python system path to recognize QFile paths in the sys.path
PythonQt::self()->setImporter(NULL);
// append the Qt resource root directory to the sys.path
mainModule.evalScript("sys.path.append(':')\n");
mainModule.evalScript("import eyed3tagger\n");
PythonQtObjectPtr tag = mainModule.evalScript("eyed3tagger.EyeD3Tagger()\n", Py_eval_input);
Q_ASSERT(!tag.isNull());
tag.call("setFileName", QVariantList() << "t.mp3");
QVariant fn = tag.call("fileName", QVariantList());
Q_ASSERT(fn.toString() == QString("t.mp3"));
}
{ // alternative using import and loading it as a real module from sys.path
// import sys first
mainModule.evalScript(QString("sys.path.append('%1')\n").arg(QDir::currentPath()));
mainModule.evalScript("import eyed3tagger\n");
PythonQtObjectPtr tag = mainModule.evalScript("eyed3tagger.EyeD3Tagger()\n", Py_eval_input);
Q_ASSERT(!tag.isNull());
tag.call("setFileName", QVariantList() << "t.mp3");
QVariant fn = tag.call("fileName", QVariantList());
Q_ASSERT(fn.toString() == QString("t.mp3"));
}
qDebug() << "finished";
return 0;
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
PythonQt::init();
PythonQtObjectPtr mainModule = PythonQt::self()->getMainModule();
mainModule.evalScript(QString("import sys\n"));
Q_ASSERT(!mainModule.isNull());
{
// evaluate a python file embedded in executable as resource:
mainModule.evalFile(":eyed3tagger.py");
// create an object, hold onto its reference
PythonQtObjectPtr tag = mainModule.evalScript("EyeD3Tagger()\n", Py_eval_input);
Q_ASSERT(!tag.isNull());
tag.call("setFileName", QVariantList() << "t.mp3");
QVariant fn = tag.call("fileName", QVariantList());
Q_ASSERT(fn.toString() == QString("t.mp3"));
// tag goes out of scope, reference count decremented.
}
{
// Allow the python system path to recognize QFile paths in the sys.path
PythonQt::self()->setImporter(NULL);
// append the Qt resource root directory to the sys.path
mainModule.evalScript("sys.path.append(':')\n");
mainModule.evalScript("import eyed3tagger\n");
PythonQtObjectPtr tag = mainModule.evalScript("eyed3tagger.EyeD3Tagger()\n", Py_eval_input);
Q_ASSERT(!tag.isNull());
tag.call("setFileName", QVariantList() << "t.mp3");
QVariant fn = tag.call("fileName", QVariantList());
Q_ASSERT(fn.toString() == QString("t.mp3"));
}
{ // alternative using import and loading it as a real module from sys.path
// import sys first
mainModule.evalScript(QString("sys.path.append('%1')\n").arg(QDir::currentPath()));
mainModule.evalScript("import eyed3tagger\n");
PythonQtObjectPtr tag = mainModule.evalScript("eyed3tagger.EyeD3Tagger()\n", Py_eval_input);
Q_ASSERT(!tag.isNull());
tag.call("setFileName", QVariantList() << "t.mp3");
QVariant fn = tag.call("fileName", QVariantList());
Q_ASSERT(fn.toString() == QString("t.mp3"));
}
qDebug() << "finished";
return 0;
}
6 changes: 3 additions & 3 deletions examples/CPPPyWrapperExample/CPPPyWrapperExample.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ mac:CONFIG -= app_bundle

DESTDIR = ../../lib

include ( ../../build/common.prf )
include ( ../../build/PythonQt.prf )
include ( ../../build/common.prf )
include ( ../../build/PythonQt.prf )

QT += widgets

SOURCES += \
CPPPyWrapperExample.cpp
CPPPyWrapperExample.cpp

RESOURCES += CPPPyWrapperExample.qrc
2 changes: 1 addition & 1 deletion examples/CPPPyWrapperExample/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ This example shows how to add user defined Python classes
to the embedded Python mainModule.

It also shows how to create objects in Python,
hold onto reference counted smart pointers to them from
hold onto reference counted smart pointers to them from
a Qt application, and invoke methods on them via
the PythonQtObjectPtr interface.
Loading