Coder Social home page Coder Social logo

jsnjack / invenv Goto Github PK

View Code? Open in Web Editor NEW
19.0 2.0 0.0 45 KB

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

License: MIT License

Makefile 10.24% Go 86.63% Smarty 3.13%
python python-venv python-virtual-environment python-virtualenv

invenv's Introduction

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]

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

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_<script_name>.txt, <script_name>_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_<script_name>.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
    grm install jsnjack/invenv
  • Download binary from Release page
  • One liner:
    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.)
    dnf copr enable surfly/invenv
    dnf install invenv

Credits

  • qguv for the original idea

invenv's People

Contributors

jsnjack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.