Hey there,
I'm writing a python project, "Onepass" which is a password manager, and I want to setup https for the web-ui. This is logical as usernames and passwords are passed through the api to- and from the web-ui so I want to make those secure.
This is the folder structure of the project:
Onepass
| > backend/
| > frontend/
| > libs/
\ > Onepass.py
All the dependencies are installed in the libs folder using the following:
python3 -m pip install [dep] --target=./libs
Then in Onepass.py
, I insert the folder path in the sys path so that the project can import dependencies from this libs
folder. This way the user doesn't have to manually install all the dependencies and instead I already provide them ("Dependabot" will be used in the repo to keep the dependencies updated).
I discovered the python version of certbot and made a plan on how to integrate it into my project so that it's as easy as possible for the user:
-
certbot
andcertbot-apache
are installed in the libs folder - Make user run
sudo apt-get install apache2 libaugeas0 -y
- Then install Onepass from github
- On first run, import the
main
function from certbot, usingfrom certbot.main import main
, and runmain('--apache')
to setup https.
However, doing from certbot.main import main
doesn't work: I get the error
ModuleNotFoundError: No module named 'zope.component'
Is there some way to fix this? For testing purposes, I've done what the documentation says (setup venv and bind /opt/cerbot/bin/certbot
to /usr/bin/certbot
) and that works. I can even go inside the venv and do the import myself (from certbot.main import main
) and that works.
However, when I want to import the main function, where certbot is not installed in a venv but in the libs
folder, it fails as seen above. Keep in mind that inside /opt/certbot/bin/certbot
, they also just import the main function exactly as I want to do above.
My conclusion is that you can import the main function of certbot when it's inside a venv but not when it's just in a folder installed.
Is there any way to make this work? Otherwise I would need to setup a venv for my complete project just for this or let the user manually install certbot using the venv and then do some weird stuff inside my project to interact with it.
Anyhow, thanks in advance.