|
| 1 | +# venv support |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +How to set up a virtual environment for the Iris IOP framework. |
| 6 | + |
| 7 | +>! Note: This is a proof-of-concept and not a production-ready solution. |
| 8 | +
|
| 9 | +## How everything is set up |
| 10 | + |
| 11 | +The source code are migrated to iris thanks to the `iop --migrate` command. |
| 12 | + |
| 13 | +Both virtual environments are created using the vanilla `python -m venv` command. |
| 14 | + |
| 15 | +The `iop` command is used to run the source code **in the virtual environments.** |
| 16 | + |
| 17 | +```bash |
| 18 | +# activate the secondary virtual environment |
| 19 | +source /opt/irisapp/.venv3.11/bin/activate |
| 20 | + |
| 21 | +# migrate the source code |
| 22 | +iop -m /irisdev/app/src/python/other/settings.py |
| 23 | + |
| 24 | +# deactivate the secondary virtual environment |
| 25 | +deactivate |
| 26 | + |
| 27 | +# activate the main virtual environment |
| 28 | +source /opt/irisapp/.venv/bin/activate |
| 29 | + |
| 30 | +# migrate the source code |
| 31 | +iop -m /irisdev/app/src/python/reddit/settings.py |
| 32 | + |
| 33 | +# start production |
| 34 | +iop --start dc.Python.Production |
| 35 | +``` |
| 36 | + |
| 37 | +>! Note: if deploying code in a non-venv environment, the parameters `%PythonPath` won't be set, and the code will run in the default python environment. |
| 38 | +
|
| 39 | +## Virtual Manual configuration |
| 40 | + |
| 41 | +The parameters : |
| 42 | + |
| 43 | +- `%PythonPath` : the path to the python lib in the virtual environment |
| 44 | +- `%PythonRuntimeLibraryVersion` : the version of python used in the virtual environment |
| 45 | +- `%PythonRuntimeLibrary` : the path to the lib python in the virtual environment |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +## Full example |
| 50 | + |
| 51 | +See the full example in the [iris-venv-demo](https://github.com/grongierisc/iris-venv-test). |
| 52 | + |
| 53 | +### How it works |
| 54 | + |
| 55 | +As the interoperability framework works with independent processes, it's manageable to run each process in its own virtual environment. |
| 56 | + |
| 57 | +This allows for easy management of dependencies and versions. |
| 58 | + |
| 59 | +For this demo, we will be using two virtual environments: |
| 60 | + |
| 61 | +- `.venv` |
| 62 | + - This is the main virtual environment that will run source code in `./src/python/reddit` |
| 63 | + - It will use it's own dependencies in `./src/python/reddit/requirements.txt` |
| 64 | + - `requests` |
| 65 | + - `dataclasses-json` |
| 66 | + - The version of python will be `3.12` |
| 67 | + - The venv folder will be in `/opt/irisapp/.venv/` |
| 68 | +- `.venv3.11` |
| 69 | + - This is a secondary virtual environment that will run source code in `./src/python/other` |
| 70 | + - It will use it's own dependencies in `./src/python/other/requirements.txt` |
| 71 | + - `deepdiff` |
| 72 | + - The version of python will be `3.11` |
| 73 | + - The venv folder will be in `/opt/irisapp/.venv3.11/` |
| 74 | + |
| 75 | +### Screenshots |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
0 commit comments