mirror of
https://github.com/daylinmorgan/viv.git
synced 2024-12-22 18:50:43 -06:00
docs: add more full fledged documentation
This commit is contained in:
parent
e548487918
commit
b9100ca2a1
2 changed files with 36 additions and 6 deletions
40
README.md
40
README.md
|
@ -13,6 +13,22 @@
|
||||||
|
|
||||||
See [usage](https://github.com/daylinmorgan/viv/blob/main/docs/usage.md) for more demo gifs.
|
See [usage](https://github.com/daylinmorgan/viv/blob/main/docs/usage.md) for more demo gifs.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Python is a great choice to quickly prototype or accomplish small tasks in scripts.
|
||||||
|
However, leveraging it's vast ecosystem can be tedious for one-off or rarely used scripts.
|
||||||
|
This is were `viv` comes in handy.
|
||||||
|
|
||||||
|
`Viv` is a standalone dependency-free `venv` creator.
|
||||||
|
It is meant to be invoked in any script that has third-party dependencies,
|
||||||
|
prior to loading of any of the external modules.
|
||||||
|
|
||||||
|
These `venvs` can be identified by name or by their specification.
|
||||||
|
In any case they will be re-used across scripts (and generated on-demand, if needed).
|
||||||
|
|
||||||
|
**Importantly**, `viv` will remove your user site directory (`python -m 'import site;print(site.USER_SITE)'`),
|
||||||
|
to ensure the script isn't using anything outside the standard library and the `viv`-managed `venv`.
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
### Manual (Recommended)
|
### Manual (Recommended)
|
||||||
|
@ -33,35 +49,47 @@ Place this directory on the python path in your rc file.
|
||||||
export PYTHONPATH="$PYTHONPATH:$HOME/.viv/src"
|
export PYTHONPATH="$PYTHONPATH:$HOME/.viv/src"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Advanced users may recognize that principally,
|
||||||
|
the module just needs to be recognized at run time
|
||||||
|
and the single script at `./src/viv/viv.py` can be invoked directly for the CLI.
|
||||||
|
How you accomplish these options is ultimately up to you but the above instructions can get you started.
|
||||||
|
|
||||||
### Pypi (Not Recommended)
|
### Pypi (Not Recommended)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pip install 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
|
## Usage
|
||||||
|
|
||||||
Then in any python script with external dependencies you can add this line,
|
In any python script with external dependencies you can add this line,
|
||||||
to automate env creation and installation of dependencies.
|
to automate `vivenv` creation and installation of dependencies.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
__import__("viv").activate("click")
|
__import__("viv").activate("click")
|
||||||
```
|
```
|
||||||
|
|
||||||
To remove all `vivenvs`:
|
To remove all `vivenvs`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
viv remove $(viv list -q)
|
viv remove $(viv list -q)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Standalone Function
|
# Standalone Viv
|
||||||
|
|
||||||
|
Supposing you want to increase the portability of your script while still employing `viv`.
|
||||||
|
|
||||||
The below function can be freely pasted at the top of your scripts and requires
|
The below function can be freely pasted at the top of your scripts and requires
|
||||||
no modification of your PYTHONPATH or import of additional modules.
|
no modification of your PYTHONPATH or import of additional modules (including downloading/installing `viv`).
|
||||||
|
|
||||||
It can be auto-generated with for example: `viv freeze rich --standalone`.
|
It can be auto-generated with for example: `viv freeze <spec> --standalone`.
|
||||||
|
|
||||||
The only part necessary to modify if copied verbatim from here is the call to `_viv_activate`.
|
The only part necessary to modify if copied verbatim from below is the call to `_viv_activate`.
|
||||||
|
|
||||||
|
output of `viv freeze rich --standalone`:
|
||||||
```python
|
```python
|
||||||
# <<<<< auto-generated by daylinmorgan/viv (v.22.12a3)
|
# <<<<< auto-generated by daylinmorgan/viv (v.22.12a3)
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
|
2
todo.md
2
todo.md
|
@ -5,3 +5,5 @@
|
||||||
- [ ] use config file (probably ini or toml for python>=3.11)
|
- [ ] use config file (probably ini or toml for python>=3.11)
|
||||||
- [ ] enable a garbage collection based on time or file existence (configurable)
|
- [ ] enable a garbage collection based on time or file existence (configurable)
|
||||||
- [ ] unit tests (v important)
|
- [ ] unit tests (v important)
|
||||||
|
|
||||||
|
- [ ] add more options to filter `viv list`
|
||||||
|
|
Loading…
Reference in a new issue