I'm developing a modular Electron-based application with a JavaScript frontend/UI and a Python backend. Both components establish REST servers, effectively serving as makeshift inter-process communication (IPC).
Neither this core app, nor the modules have any knowledge of each other. The modules are installed by the user and integrate into the process via dynamic imports.
For deployment, the Python backend is compiled into a standalone executable (.exe) using PyInstaller. Just like the core, the modules have separate JavaScript and Python components. The Python part of each module is compiled into a .pyd file.
A key issue arises when importing these .pyd files, especially if the modules have Python dependencies that aren't included in the core backend. To manage this, each shipped module comes bundled with its own requirements.txt file listing these additional dependencies.
However, when attempting to programmatically install these dependencies at runtime using an internal instance of pip (packaged with the core backend executable via hiddeninstalls), I consistently encounter errors. This installation step currently fails, blocking seamless module integration.
I'm building the backend core using
pyinstaller --onedir --noconfirm --name=paige_backend_server \
--hidden-import=pip \
--hidden-import=pip._internal \
src/core/rest_server.py
although I've had as much as 25 more lines to try to get this to work.
In the app I then have pip._internal.main(["install", "--target", userDir, "-r", tmp.name]) (with tmp.name being the requriements.txt file)
This then leads to a "ModuleNotFoundError: No module named 'pip._internal.commands.install' error. This is changed by adding pip._internal.commands.install to the --hidden-import but again, even after adding 25 additional --hidden-imports, I get errors like'FileNotFoundError: [Errno 2] No such file or directory