viv/docs/usage.md

2.5 KiB

Usage

In any python script with external dependencies you can add this line, to automate vivenv creation and installation of dependencies.

__import__("viv").use("click")

To remove all vivenvs you can use the below command:

viv cache remove $(viv list -q)

To remove viv all together you can use the included purge command:

python3 <(curl -fsSL viv.dayl.in/viv.py) manage purge

Equivalent commands from alternatives

pip-run

pip-run cowsay -- -m cowsay "moove over, pip-run"
python3 <(curl -fsSL viv.dayl.in/viv.py) run cowsay -- "moove over, pip-run"
python -m pip-run requests -- -c "import requests; print(requests.get('https://pypi.org/project/pip-run').status_code)"
python -m viv requests -b python -- -c "import requests; print(requests.get('https://pypi.org/project/viv').status_code)"

pipx

pipx install pycowsay
viv shim pycowsay
pipx run https://gist.githubusercontent.com/cs01/fa721a17a326e551ede048c5088f9e0f/raw/6bdfbb6e9c1132b1c38fdd2f195d4a24c540c324/pipx-demo.py
python3 <(curl -fsSL viv.dayl.in/viv.py) run \
  -s https://gist.githubusercontent.com/cs01/fa721a17a326e551ede048c5088f9e0f/raw/6bdfbb6e9c1132b1c38fdd2f195d4a24c540c324/pipx-demo.py

Bonus: use viv with just standalone snippet (37LOC)

--standalone will auto-generate a mini function version of viv to accomplish the same basic task as using a local copy of viv. After generating this standalone shim you can freely use this script across unix machines which have python>3.8. See examples/black for output of below command.

viv freeze also supports --standalone

python3 <(curl -fsSL viv.dayl.in/viv.py) shim black -o ./black --standalone --freeze