Shiv
For some reason I want to separate out the dependencies from my python script, think the reasoning is that I want to be able to scan over what the python script does, i.e. still be a script and not compleatly compiled. And I dont wanna fuzz around with creating a venv and running pip install on all the requirements every time I want to run my overcomplicated python script.
So I found this too shiv, not sure I'm actually using it as intended, find the documentation not really supporting my desires.
This is for me to remember how to do this.
Installation
First install shiv, this if only for the production of the dependencies
python -m venv venv . venv/bin/activate pip install shiv
Creating deps file
Then to produce a dependencies blob with all required dependencies run:
shiv requests==2.27.1 configobj urllib3 -o deps.pyz
Usage
You can then start your python scripts with:
./deps.pyz script.py
Testing
One can start an interactive shell, like with python by just running the dependencie blob, and get the dependencies, also a way to test that it all works:
# ./deps.pyz Python 3.12.0 (main, Oct 2 2023, 00:00:00) [GCC 13.2.1 20230918 (Red Hat 13.2.1-3)] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> import configobj >>>