viv isn't venv
Find a file
2023-09-27 15:53:27 -05:00
.github feat: add experimental support for windows 2023-09-27 15:53:27 -05:00
assets docs: remove old svgs 2023-08-21 10:03:15 -05:00
examples fix: accept args with -s to make shebangs work better 2023-09-27 12:42:32 -05:00
scripts build: fix release regex 2023-09-21 14:50:46 -05:00
src/viv feat: add experimental support for windows 2023-09-27 15:53:27 -05:00
tests tests: add some basic integration tests for python api 2023-09-27 13:34:10 -05:00
.gitignore tests: add some basic integration tests for python api 2023-09-27 13:34:10 -05:00
.pre-commit-config.yaml chore: remove scripts/bump-dev.sh from .pre-commit-config.yaml 2023-08-29 11:19:54 -05:00
.task.cfg.mk chore: change makefile style 2023-05-29 12:48:07 -05:00
LICENSE chore: add LICENSE 2022-12-26 08:03:58 -06:00
Makefile build: new release workflow 2023-08-23 15:18:57 -05:00
mkdocs.yml docs: add badges 2023-08-21 15:16:18 -05:00
noxfile.py tests: add some basic integration tests for python api 2023-09-27 13:34:10 -05:00
pdm.lock tests: add some basic integration tests for python api 2023-09-27 13:34:10 -05:00
pyproject.toml tests: add some basic integration tests for python api 2023-09-27 13:34:10 -05:00
README.md docs: add conda shield 2023-08-29 11:47:44 -05:00
todo.md chore: update todos 2023-08-09 11:27:54 -05:00

Stargazers Issues MIT License PYPI Ruff Black pre-commit Conda

Logo

viv isn't venv

cli screenshot

Documentation

Try before you buy!

python3 <(curl -fsSL viv.dayl.in/viv.py) run pycowsay -- "viv isn't venv\!"

Viv is a standalone dependency-free venv creator 1. Viv helps you ignore silly things like managing temporary or rarely used virtual environments, while still unleashing the full power of python scripting with it's entire ecosystem at your disposal.

Viv's uncompromising insistence on portability means that it will always:

  1. only use the standard library
  2. never exceed a single script.

For that reason any usage of the cli can be accomplished using a remote copy as seen in the below install command.

Setup

Run the below command to install viv.

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

To access viv from within scripts you should add it's location to your PYTHONPATH. By default viv will be installed to $XDG_DATA_HOME/viv or ~/.local/share/viv you can customize this with --src.

export PYTHONPATH="$PYTHONPATH:$HOME/.local/share/viv"
pip install viv

Why is this not recommended? Mainly, because viv is all about hacking your sys.path. Placing it in it's own virtual environment or installing in a user site directory may complicate this endeavor.

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

  1. You do need to have pip but surely you have pip already. ↩︎