Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jsnjack/invenv

A tool to automatically create and run your Python scripts in a virtual environment with installed dependencies
https://github.com/jsnjack/invenv

python python-venv python-virtual-environment python-virtualenv

Last synced: 16 days ago
JSON representation

A tool to automatically create and run your Python scripts in a virtual environment with installed dependencies

Awesome Lists containing this project

README

        

invenv
==============

`invenv` is a tool to run your Python scripts in an automatically created virtual
environment with installed dependencies.

It tries to simplify running Python scripts (or even applications!) by taking
from you the burden of creating and maintaining virtual environments.

### Description
```
Usage:
invenv [invenv-flags] -- [VAR=val] python-script.py [flags]
invenv [command]

Examples:
invenv -- somepath/myscript.py
invenv -n -- somepath/myscript.py --version
invenv -r req.txt -- DEBUG=1 somepath/myscript.py

Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
init initialize a virtual environment in the current directory

Flags:
-d, --debug enable debug mode with verbose output
-h, --help help for invenv
-n, --new-environment create a new virtual environment even if it already exists
-p, --python string use specified Python interpreter
-r, --requirements-file string use specified requirements file. If not provided, it
will try to guess the requirements file name:
requirements_.txt, _requirements.txt or
requirements.txt
-s, --silent silence progress output. --debug flag overrides this
-v, --version print version and exit
-w, --which print the location of virtual environment folder and exit. If
the virtual environment does not exist, it will be created with
installed requirements

```

### Details
When you run `invenv` the first time it will:
- detect python interpreter which should be used to run your script (by analyzing shebang)
- in case if python interpreter is not found in your `PATH`, it will try to use default python interpreter in your system
- it is possible to specify a custom interpreter with `-p` flag
- create a virtual environment in `~/.local/invenv/` folder
- try to automatically install all dependencies from `requirements_.txt`, `_requirements.txt` or
`requirements.txt` files (it is possible to specify a custom requirements file with `-r` flag)
- run your script with all the arguments you passed

Next time you run `invenv` it will try to use the existing virtual environment and install
dependencies only if they are changed.

### Installation
- Using [grm](https://github.com/jsnjack/grm)
```bash
grm install jsnjack/invenv
```
- Download binary from [Release](https://github.com/jsnjack/invenv/releases/latest/) page
- One liner:
```bash
curl -s https://api.github.com/repos/jsnjack/invenv/releases/latest | jq -r .assets[0].browser_download_url | xargs curl -LOs && chmod +x invenv && sudo mv invenv /usr/local/bin/
```
- From COPR repository (Fedora, CentOS, RHEL and etc.)
```bash
dnf copr enable surfly/invenv
dnf install invenv
```

### Credits
- [qguv](https://github.com/qguv) for the original idea