-</span></code></pre></div></div> <p>Next, skim through the <a href="https://github.com/albertlauncher/plugins/blob/main/python/albert.pyi">Python stub file</a>. For reference see the <a href="https://github.com/albertlauncher/albert-plugin-python/tree/main/plugins">official plugins</a>. In case of questions see the <a href="/reference/namespacealbert.html">C++ API</a>.</p> <!--## Tutorial--> <!-- ## Contributing Python plugins * [Fork the Python plugins repository](https://github.com/albertlauncher/python/fork). * Clone your fork into your Python user plugin location. ```shell git clone https://github.com/<your_username>/python.git "${USER_DATA_DIR}/python/plugins" ``` You can find the `${USER_DATA_DIR}` for your platform in [this table](https://albertlauncher.github.io/gettingstarted/faq/#where-are-cache-config-and-data-files-stored). * Open the directory in your favorite IDE (PyCharmCE is a good choice). * Write your plugin. * Make sure it is polished (No bugs, few to no warnings, efficient, readable, maintainable, …). * Commit, push, send a PR. --> <h2 id="plugin-directories"> <a href="#plugin-directories" class="anchor-heading" aria-labelledby="plugin-directories"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Plugin directories </h2> <p>Python plugin directories are the directories at <code class="language-plaintext highlighter-rouge">python/plugins</code> relative to the <a href="https://albertlauncher.github.io/gettingstarted/faq/#where-are-cache-config-and-data-files-stored">app data directories</a>.</p> <ul> <li><strong>xdg</strong>: <ul> <li><code class="language-plaintext highlighter-rouge">~/.local/share/albert/python/plugins</code></li> <li><code class="language-plaintext highlighter-rouge">/usr/local/share/albert/python/plugins</code></li> <li><code class="language-plaintext highlighter-rouge">/usr/share/albert/python/plugins</code></li> </ul> </li> <li><strong>macOS</strong>: <ul> <li><code class="language-plaintext highlighter-rouge">~/Library/Application Support/Albert/python/plugins</code></li> <li><code class="language-plaintext highlighter-rouge">/Library/Application Support/Albert/python/plugins</code></li> <li><code class="language-plaintext highlighter-rouge">$BUNDLE_PATH/Contents/PlugIns/python/plugins</code></li> </ul> </li> </ul> <h2 id="technical-notes-and-limitations"> <a href="#technical-notes-and-limitations" class="anchor-heading" aria-labelledby="technical-notes-and-limitations"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Technical notes and limitations </h2> <ul> <li>Due to the different type systems, <strong>multiple virtual inheritance of extension interfaces is not supported</strong>. However, multiple extensions can be added by reimplementing <code class="language-plaintext highlighter-rouge">albert.PluginInstance.extensions()</code>.</li> <li>Python plugin execution is subject to the <a href="https://en.wikipedia.org/wiki/Global_interpreter_lock">Python Global Interpreter Lock (GIL)</a>. This means that only one thread can execute Python code at a time. This can become a problem for parallelization of queries or multithreaded global queries. Long running handlers will introduce noticeable lags. <strong>Do not block</strong> execution in your query handlers, especially not in <code class="language-plaintext highlighter-rouge">handleGlobalQuery</code>. If you can, use <code class="language-plaintext highlighter-rouge">IndexQueryHandler</code> instead, which performs the handling in C++ space.</li> <li>PyBind11 <strong>method resolution does not support mixin behavior</strong>. Usually this should not be much of a problem, but there is one prevalent use case: Reusing <code class="language-plaintext highlighter-rouge">id</code>, <code class="language-plaintext highlighter-rouge">name</code> and <code class="language-plaintext highlighter-rouge">description</code> of the <code class="language-plaintext highlighter-rouge">PluginInstance</code> class for your <code class="language-plaintext highlighter-rouge">Extension</code>. For the sake of minimal boilerplate the mixin behavior is emulated for these methods. I.e. if you inherit <code class="language-plaintext highlighter-rouge">PluginInstance</code> and any <code class="language-plaintext highlighter-rouge">Extension</code>, you do not have to reimplement these methods.</li> </ul> </main> <hr> <footer> <div class="d-flex mt-2"> <p class="text-small mb-0"> <a href="https://github.com/albertlauncher/documentation/edit/master/src/gettingstarted/extension/python.md" id="edit-this-page">Edit this page on GitHub</a> </p> </div> <div class="d-xs-block d-md-none"> <footer class="site-footer"> <!-- intentionally empty to avois showing this: This site uses <a href="https://github.com/just-the-docs/just-the-docs">Just the Docs</a>, a documentation theme for Jekyll.--> </footer> </div> </footer> </div> </div> <div class="search-overlay"></div> </div> <script src="https://cdn.jsdelivr.net/npm/mermaid@9.1.3/dist/mermaid.min.js"></script> <script> var config = {} ; mermaid.initialize(config); window.mermaid.init(undefined, document.querySelectorAll('.language-mermaid')); </script> </body> </html>
0 commit comments