aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2018-09-12 15:01:46 +0200
committerEike Ziller <eike.ziller@qt.io>2018-09-14 09:46:29 +0000
commit876ff8853f42b4ea6fae60adf994f531898cba57 (patch)
treee0a7e9fc9d6694b1d8a4660a89d4478e5c0caf36 /README.md
parent6452612845d7edebbef26a0d2b483c129ab3a073 (diff)
Fix encapsulation of plugins
Fixes that triggering "About Python Extensions" action resulted in python runtime error "TypeError: must be type, not None" when referencing PySide2.QtWidgets. To improve encapsulation of plugins, all modules that they loaded were deleted after their main.py finished running. This breaks if these modules were accessed later e.g. triggered by actions. Instead of this hack, ensure encapsulation of plugins by making them actual Python packages. Qt Creator's python extension path is added to python's module search path, and extensions are simply imported as packages. The python extension's main.py simply becomes a standard python module __init__.py. This also means that python extensions can depend on, and use other python extensions' functionality by importing them with "import". Change-Id: Ibe74c24e337b321007f5fa19c97bd35a5c1f0375 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'README.md')
-rw-r--r--README.md30
1 files changed, 14 insertions, 16 deletions
diff --git a/README.md b/README.md
index fd2252c..2cc6722 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,10 @@
# Python Extensions for QtCreator
This plugin for QtCreator makes it possible to extend the QtCreator by
-writing Python extensions. These extensions consist of a directory
-containing a `main.py` and any other Python files necessary. They can
-be shared as zip archives, installed and managed through the included
-extension manager (which is a Python extension itself) and thus allow
-the QtCreator to be easily extended with custom functionality.
+writing Python extensions. These extensions are simply Python packages,
+so they are directories containing a `__init__.py` and any other Python
+files necessary. They can be shared as zip archives, installed and managed
+through the included extension manager (which is a Python extension itself) and thus allow the QtCreator to be easily extended with custom functionality.
**WARNING:** This is a first draft / proof of concept and only offers
very limited functionality. There will still be many bugs and so far
@@ -129,21 +128,20 @@ The following process allows the plugin to work:
2. When QtCreator is executed, the C++ plugin searches the standard
QtCreator plugin directories for a directory named `python`, the
first directory found is the Python extension directory.
- - Now, each subdirectory represents it's own Python extension. For each
- subdirectory the C++ plugin checks whether it contains a `setup.py`.
- If it does, this setup script is executed.
- - After all the setup scripts have been executed, each subdirectory is
- checked for a file named `main.py`. This file is the extensions entry
- point and is executed by the C++ plugin.
+ - Now, each package in this directory represents it's own Python extension.
+ For each package the C++ plugin checks whether it
+ contains a `setup.py`. If it does, this setup script is executed.
+ - After all the setup scripts have been executed, each package is loaded
+ with `import`, which executes the initialization code in its
+ `__init__.py`.
3. Now all Python extensions have registered their actions / menus / etc.,
which can be triggered from the QtCreator interface.
When executed, the Python extensions can import any modules / packages
-installed for the system Python or found in their own directory. While
-the C++ plugin takes some precautions to isolate the Python extensions
-when executed, they are still all run in the same Python instance,
-which means that they are not completely isolated. However, so far
-this did not turn out to be a problem.
+installed for the system Python, in Qt Creator's extensions directory, or
+found in their own directory.
+Python extensions are all run in the same Python instance,
+which means that they are not completely isolated.
For a more detailed description, please refer to the documentation in
`docs`.