viv isn't venv
Find a file
2024-07-12 12:33:22 -05:00
.github ci: use latest branch over tag 2024-07-12 11:43:52 -05:00
assets docs: update main help screenshot 2023-10-02 12:37:06 -05:00
docs docs: minor changes 2024-01-09 02:00:43 -06:00
examples fix(#23): add pip version check 2024-07-09 12:03:06 -05:00
scripts chore: bump packaging to v24 2024-04-18 15:02:00 -05:00
src/viv - 2024-07-12 12:33:22 -05:00
tests refactor: abstract _uses_viv + add tests 2024-01-04 15:53:04 -06:00
.gitignore feat: vendor packaging + add support for requires python check 2024-01-03 13:09:19 -06:00
.pre-commit-config.yaml feat: vendor packaging + add support for requires python check 2024-01-03 13:09:19 -06:00
LICENSE chore: add LICENSE 2022-12-26 08:03:58 -06:00
noxfile.py tests: add python v3.12 2024-07-12 11:40:33 -05:00
pdm.lock docs: actually document the things 2024-01-05 17:20:57 -06:00
pyproject.toml fix(#23): add pip version check 2024-07-09 12:03:06 -05:00
README.md docs: fix url 2024-06-18 14:07:12 -05:00
task chore: remove newlines 2024-01-19 10:20:51 -06: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 frogmouth -- gh daylinmorgan/viv

Viv is a standalone dependency-free venv creator (just needs python + pip). 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, only use the standard library and never exceed a single script.

See the documentation or the examples to get started.

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 its 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 its 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.

As a cli:

viv run frogmouth -- gh daylinmorgan/viv

As a python module:

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

As an app installer:

viv shim ruff

To remove all vivenvs you can use the below command:

viv env remove $(viv list -q)

To remove viv altogether 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 run 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 the below command.

viv freeze also supports --standalone.

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