{ "info": { "author": "Radomir Stevanovic", "author_email": "radomir.stevanovic@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: POSIX", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Unix Shell", "Topic :: System :: Shells", "Topic :: Utilities" ], "description": "Navigate and manage Python virtual environments\n===============================================\n\n.. image:: https://img.shields.io/pypi/v/envie.svg\n :target: https://pypi.python.org/pypi/envie\n\n.. image:: https://img.shields.io/badge/platform-GNU/Linux,%20BSD,%20Darwin/OS%20X-red.svg\n :target: https://pypi.python.org/pypi/envie\n\n.. image:: https://img.shields.io/badge/shell-bash-blue.svg\n :target: https://pypi.python.org/pypi/envie\n\n.. image:: https://img.shields.io/pypi/pyversions/envie.svg\n :target: https://pypi.python.org/pypi/envie\n\n.. image:: https://api.travis-ci.org/randomir/envie.svg?branch=master\n :target: https://travis-ci.org/randomir/envie\n\n----\n\n*Envie* is a set of shell utilities (in ``bash``) aiming to increase your productivity\nwhen dealing with mundane Python virtual environment tasks, like creating, destroying,\nlisting/discovering, and switching/activating environments.\n\nWhere Envie really shines is auto-discovery, auto-activation and auto-creation of\nvirtual envs relevant to your project (or executable). It holds no assumptions on\nvirtual env dir location in relation to your code (or working directory),\nbut works best if they're near (nested, in level, or a few levels up).\n\n\nMotivation\n----------\n\nI like to keep my virtual environments close to source (especially in production).\nWith hundreds of projects on disk, this enables me to keep environment dir names short\nand project-relevant (since a project can have several environments, e.g. dev, prod, test).\nAlso, environments are easy to locate, update, or rebuild (maintain in general).\n\nIf you structure your files/projects in any of the ways depicted in Fig 1. below, you'll\nfind Envie particularly helpful.\n\n::\n\n work work /srv\n \u2502 \u2502 \u2502\n \u251c\u2500\u2500 plucky \u251c\u2500\u2500 jsonplus \u251c\u2500\u2500 production\n \u2502 \u251c\u2500\u2500 env <-- \u2502 \u251c\u2500\u2500 .git \u2502 \u251c\u2500\u2500 website\n \u2502 \u251c\u2500\u2500 plucky \u2502 \u251c\u2500\u2500 django \u2502 \u2502 \u251c\u2500\u2500 pythonenv <--\n \u2502 \u251c\u2500\u2500 tests \u2502 \u2502 \u251c\u2500\u2500 env \u2502 \u2502 \u251c\u2500\u2500 var\n \u2502 \u2514\u2500\u2500 ... \u2502 \u2502 \u2502 \u251c\u2500\u2500 dev <-- \u2502 \u2502 \u2514\u2500\u2500 src\n \u2502 \u2502 \u2502 \u2502 \u2514\u2500\u2500 prod <-- : : \u251c\u2500\u2500 .git\n \u251c\u2500\u2500 blog \u2502 \u2502 \u251c\u2500\u2500 tests : : \u2514\u2500\u2500 ...\n \u2502 \u251c\u2500\u2500 .env <-- \u2502 \u2502 \u2502 \u251c\u2500\u2500 env <-- . .\n : \u251c\u2500\u2500 .git : : : \u251c\u2500\u2500 test_1.py\n : \u251c\u2500\u2500 _posts : : : \u2514\u2500\u2500 ...\n . \u2514\u2500\u2500 ... . . .\n \n (a) env in level with src (b) env nested under src (c) env one level above src\n \n Figure 1. Several ways to keep your environments local to the code.\n\n\nEasy activation\n...............\n\nTo activate the closest virtual environment in vicinity, just type ``envie`` (Fig 1.a and 1.c):\n\n.. code-block:: bash\n\n ~/work/plucky$ envie\n Activated virtual environment at 'env'.\n\n /srv/production/website/src$ envie\n Activated virtual environment at '../pythonenv'.\n\nIf several equally close environments are found (Fig 1.b), you'll be prompted to select\nthe exact env. But, you can avoid it with a cunning use of fuzzy-filtering_, for example:\n\n.. code-block:: bash\n\n ~/work/jsonplus$ envie dev\n Activated virtual environment at 'django/env/dev'.\n\nDiscovery and filtering have no limits on depth, so you can activate your project environment like:\n\n.. code-block:: bash\n\n ~$ envie plus dev\n Activated virtual environment at 'work/jsonplus/django/env/dev'.\n\n\nImplicit activation\n...................\n\nSometimes you don't care about activating the relevant environment *in your shell*.\nYou just want your script to run in the correct env. Easy peasy (ref. Fig 1.b):\n\n.. code-block:: bash\n\n ~/work/jsonplus$ envie ./django/tests/test_1.py\n Activated virtual environment at 'django/tests/env'.\n # running test ...\n\nIt doesn't have to be a Python script:\n\n.. code-block:: bash\n\n ~/work/plucky$ envie run make test\n Activated virtual environment at 'env'.\n # running 'make' with python from env\n\nAnd it works from a hash bang too:\n\n.. code-block:: python\n\n #!/usr/bin/env envie\n\nYou can even activate the closest environment after the fact, from your Python program\n(changing the environment from whatever was current \u2014 to the closest, relative to the script):\n\n.. code-block:: python\n\n #!/usr/bin/python\n import envie.activate_closest\n\n\nTerse & pip-infused create\n..........................\n\nSure, you can use ``virtualenv --python=python3 env``, but isn't this simpler?\n\n.. code-block:: bash\n\n $ envie create -3\n \n # or, shorter:\n $ mkenv3\n\nAnd how about also **installing** your **pip requirements** in one go?\n\n.. code-block:: bash\n\n $ mkenv -r dev-requirements.txt env/dev\n\nOr, creating a **temporary/throw-away** environment **with** some **packages** installed, then\nhacking in an interactive Python session, and finally destroying the complete environment upon exit:\n\n.. code-block:: bash\n\n $ mkenv -t -p requests -p 'plucky>=0.4' && python && rmenv -f\n\nDetails and more examples are available in `envie create`_, `envie remove`_, and `envie-tmp`_ docs.\n\n\nExisting environments discovery\n...............................\n\nActivation of the closest environment is predicated on the discovery of the existing virtual\nenvironments below a certain directory with ``lsenv`` (`envie list`_), and on the up-the-tree\nsearch with ``findenv`` (`envie find`_):\n\n.. code-block:: bash\n\n ~/work$ lsenv\n plucky/env\n blog/.env\n jsonplus/django/env/dev\n ...\n\n\n.. _chenv: http://envie.readthedocs.io/en/latest/commands.html#chenv\n.. _fuzzy-filtering: http://envie.readthedocs.io/en/latest/commands.html#fuzzy-filtering\n.. _`envie create`: http://envie.readthedocs.io/en/latest/commands.html#mkenv\n.. _`envie remove`: http://envie.readthedocs.io/en/latest/commands.html#rmenv\n.. _`envie-tmp`: http://envie.readthedocs.io/en/latest/commands.html#envie-tmp\n.. _`envie list`: http://envie.readthedocs.io/en/latest/commands.html#lsenv\n.. _`envie find`: http://envie.readthedocs.io/en/latest/commands.html#findenv\n\n\nInstall & configure\n-------------------\n\nFor convenience, ``envie`` is packaged and distributed as a Python package.\nYou can install it system-wide (or user-local, see `Install`_ docs):\n\n.. code-block:: bash\n\n $ sudo pip install envie\n $ envie config\n\n # don't forget to source envie:\n $ . ~/.bashrc\n \n # or just open a new shell\n\nAfter install, be sure to run a (short and interactive) `configuration`_ procedure with ``envie config``.\nIf in doubt, go with the defaults. Running config is optional, but recommended.\nIt'll, for example, allow to you easily add Envie sourcing statement to your ``.bashrc``\n(enabling Bash completion and alias functions), and to activate environments indexing\n(enabling faster search with ``locate``).\n\n.. _Install: http://envie.readthedocs.io/en/latest/setup.html#install\n.. _configuration: http://envie.readthedocs.io/en/latest/setup.html#configure\n\n\nEnable index\n............\n\nBy default, ``envie`` uses the ``find`` command to search for environments. That\napproach is pretty fast when searching shallow trees. However, if you have\ndeeper directory trees, it's often faster to use a pre-built directory index\n(i.e. the ``locate`` command). To configure a combined ``locate/find`` approach to\nsearch, run ``envie config``.\n\nWhen index is enabled, the combined approach is used by default (if not overriden with\n``-f`` or ``-l`` switches). In the combined approach, ``find`` and ``locate`` start searching\nin parallel and vie for producing results first. However, ``find`` is given only 400ms to finish\nbefore being terminated, thusly producing ``locate``-based results for deeper trees faster\n(but potentially incomplete if index was stale).\n\n\nTesting\n.......\n\nRun all test suites locally with::\n\n $ make test\n\n(after cloning the repo.)\n\n\nUsage in short\n--------------\n\n``envie [-1] [-f|-l] [] []`` (alias ``chenv``)\n Interactively activate the closest environment (looking down, then up, with ``findenv``), optionally filtered by a list of ````. Start looking in ```` (defaults to ``.``).\n\n``envie create [-2|-3|-e ] [-r ] [-p ] [-a] [ | -t]`` (alias ``mkenv``)\n Create virtual environment in ```` (or in a temporary dir, ``-t``) based on a Python interpreter ````, optionally installing Pip requirements from ```` file, and/or ```` requirement specifier(s).\n\n``envie remove`` (alias ``rmenv``)\n Destroy the active environment.\n\n``envie list [-f|-l] [] []`` (alias ``lsenv``)\n List all environments below ```` directory, optionally filtered with a list of ````.\n\n``envie find [-f|-l] [] []`` (alias ``findenv``)\n Find the closest environments by first looking down and then dir-by-dir up the tree, starting in ````; optionally filtered with a list of ````.\n\n``envie