Skip to content

Commit 4f298bf

Browse files
authored
Inform potential devs of embedded python pitfalls
1 parent 21b7b2b commit 4f298bf

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

develop-py-plugins.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
Python plugins use the [JSON-RPC](https://flow-launcher.github.io/docs/#/json-rpc) protocol to communicate with Flow via JSON structured calls.
44

5-
When building a Python plugins there are several things to be mindful of. The most important thing is we do not expect users to have to manually install the dependencies in requirements.txt because we aim to provide a seamless experience for them. This can be achieved by adding the below three things to your project:
5+
When building a Python plugins there are several things to be mindful of:
66

7-
1. Add a GitHub workflow- use a GitHub workflow that will install all your plugin's depedencies including the Python flowlauncher module to a folder called Lib inside your plugin.
8-
2. Publish all as a zip- zip up your project including a lib directory that contains the modules and publish it to GitHub Releases page
9-
3. Point your module imports to the lib directory- reference all the modules to that directory where they are first imported.
7+
* The most important thing is we do not expect users to have to manually install the dependencies in requirements.txt because we aim to provide a seamless experience for them. This can be achieved by adding the following three things to your project:
8+
1. Add a GitHub workflow- use a GitHub workflow that will install all your plugin's depedencies including the Python flowlauncher module to a folder called Lib inside your plugin.
9+
2. Publish all as a zip- zip up your project including a lib directory that contains the modules and publish it to GitHub Releases page.
10+
3. Point your module imports to the lib directory- reference all the modules to that directory where they are first imported.
11+
12+
* The user can use their own system installed Python with Flow Launcher. But in most circumstances the user will most likely be using Flow Launcher's own embedded Python executable. [Embedded Python](https://docs.python.org/3/using/windows.html#the-embeddable-package) is isolated from the users system and does not prepend the scripts run directory to the system `PATH`.<sup>[ref](https://bugs.python.org/issue28245)</sup> If you need to import external files please follow the example below.
1013

1114
### Simple Example
1215
Have a look at this simple example plugin [here](https://github.com/Flow-Launcher/plugin-samples/tree/master/HelloWorldPython), notice it has a folder called '.github/workflows' and a file called 'Publish Release.yml'. This is the workflow file that GitHub Workflow uses to run the CICD for the project. Moving out of that folder you can go into the [main.py](https://github.com/Flow-Launcher/plugin-samples/blob/master/HelloWorldPython/plugin.json) file, this is the entry file for your plugin. Notice it has this code block:

0 commit comments

Comments
 (0)