From f485375abfed4ee13e0d66cdab6ab3723b8102cc Mon Sep 17 00:00:00 2001 From: daniel Date: Sun, 25 Nov 2018 18:28:17 +0100 Subject: [PATCH 1/4] rst format fix, ~~~ was being used instead of --- under subsections causing the document not to render properly --- docs/dev/virtualenvs.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/dev/virtualenvs.rst b/docs/dev/virtualenvs.rst index 11f924882..79f26bcc8 100644 --- a/docs/dev/virtualenvs.rst +++ b/docs/dev/virtualenvs.rst @@ -219,7 +219,7 @@ Test your installation $ virtualenv --version Basic Usage -~~~~~~~~~~~ +----------- 1. Create a virtual environment for a project: @@ -285,7 +285,7 @@ littered across your system, and its possible you'll forget their names or where they were placed. Other Notes -~~~~~~~~~~~ +----------- Running ``virtualenv`` with the option ``--no-site-packages`` will not include the packages that are installed globally. This can be useful @@ -346,7 +346,7 @@ To install (make sure **virtualenv** is already installed): In Windows, the default path for WORKON_HOME is %USERPROFILE%\Envs Basic Usage -~~~~~~~~~~~ +----------- 1. Create a virtual environment: @@ -390,7 +390,7 @@ can quickly switch between environments. $ rmvirtualenv venv Other useful commands -~~~~~~~~~~~~~~~~~~~~~ +--------------------- ``lsvirtualenv`` List all of the environments. From 62fa79dcbbd2098ddf0eef7742ef47704312cf30 Mon Sep 17 00:00:00 2001 From: daniel Date: Sun, 25 Nov 2018 19:00:40 +0100 Subject: [PATCH 2/4] image path fixed --- docs/dev/virtualenvs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev/virtualenvs.rst b/docs/dev/virtualenvs.rst index 79f26bcc8..53fcfeab6 100644 --- a/docs/dev/virtualenvs.rst +++ b/docs/dev/virtualenvs.rst @@ -3,7 +3,7 @@ Pipenv & Virtual Environments ============================= -.. image:: /_static/photos/35294660055_42c02b2316_k_d.jpg +.. image:: ../_static/photos/35294660055_42c02b2316_k_d.jpg This tutorial walks you through installing and using Python packages. From 42846b0ac98b0bdc7b2c61931339657aec3c0bf9 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 26 Nov 2018 01:15:16 +0100 Subject: [PATCH 3/4] headings fix and img path revert --- docs/dev/virtualenvs.rst | 93 ++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 42 deletions(-) diff --git a/docs/dev/virtualenvs.rst b/docs/dev/virtualenvs.rst index 53fcfeab6..7805ff689 100644 --- a/docs/dev/virtualenvs.rst +++ b/docs/dev/virtualenvs.rst @@ -1,9 +1,10 @@ .. _virtualenvironments-ref: +############################# Pipenv & Virtual Environments -============================= +############################# -.. image:: ../_static/photos/35294660055_42c02b2316_k_d.jpg +.. image:: /_static/photos/35294660055_42c02b2316_k_d.jpg This tutorial walks you through installing and using Python packages. @@ -19,8 +20,9 @@ managing development and testing environments for any kind of project. should work fine on Python 2.7—if you are still using it, for some reason. +********************************* Make sure you've got Python & pip ---------------------------------- +********************************* Before you go any further, make sure you have Python and that it's available from your command line. You can check this by simply running: @@ -39,7 +41,7 @@ install the latest 3.x version from `python.org`_ or refer to the >>> python Traceback (most recent call last): - File "", line 1, in + File "", line 1, in NameError: name 'python' is not defined It's because this command is intended to be run in a *shell* (also called @@ -65,8 +67,9 @@ using your OS package manager, you may have to `install pip =2.5 (from requests) - Using cached idna-2.6-py2.py3-none-any.whl + Using cached idna-2.6-py2.py3-none-any.whl Collecting urllib3<1.23,>=1.21.1 (from requests) - Using cached urllib3-1.22-py2.py3-none-any.whl + Using cached urllib3-1.22-py2.py3-none-any.whl Collecting chardet<3.1.0,>=3.0.2 (from requests) - Using cached chardet-3.0.4-py2.py3-none-any.whl + Using cached chardet-3.0.4-py2.py3-none-any.whl Collecting certifi>=2017.4.17 (from requests) - Using cached certifi-2017.7.27.1-py2.py3-none-any.whl + Using cached certifi-2017.7.27.1-py2.py3-none-any.whl Installing collected packages: idna, urllib3, chardet, certifi, requests Successfully installed certifi-2017.7.27.1 chardet-3.0.4 idna-2.6 requests-2.18.4 urllib3-1.22 @@ -160,7 +164,7 @@ when you share your project with others. You should get output similar to this Using installed packages ------------------------- +======================== Now that Requests is installed you can create a simple ``main.py`` file to use it: @@ -191,14 +195,14 @@ have access to your installed packages with ``$ pipenv shell``. Next steps ----------- +========== Congratulations, you now know how to install and use Python packages! ✨ 🍰 ✨ - +*********************** Lower level: virtualenv -======================= +*********************** `virtualenv `_ is a tool to create isolated Python environments. virtualenv creates a folder which contains all the @@ -210,23 +214,23 @@ Install virtualenv via pip: .. code-block:: console - $ pip install virtualenv + $ pip install virtualenv Test your installation .. code-block:: console - $ virtualenv --version + $ virtualenv --version Basic Usage ------------ +=========== 1. Create a virtual environment for a project: .. code-block:: console - $ cd my_project_folder - $ virtualenv my_project + $ cd my_project_folder + $ virtualenv my_project ``virtualenv my_project`` will create a folder in the current directory which will contain the Python executable files, and a copy of the ``pip`` library which you @@ -242,19 +246,19 @@ You can also use the Python interpreter of your choice (like .. code-block:: console - $ virtualenv -p /usr/bin/python2.7 my_project + $ virtualenv -p /usr/bin/python2.7 my_project or change the interpreter globally with an env variable in ``~/.bashrc``: .. code-block:: console - $ export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.7 + $ export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.7 2. To begin using the virtual environment, it needs to be activated: .. code-block:: console - $ source my_project/bin/activate + $ source my_project/bin/activate The name of the current virtual environment will now appear on the left of the prompt (e.g. ``(my_project)Your-Computer:your_project UserName$)`` to let you know @@ -272,7 +276,7 @@ Install packages as usual, for example: .. code-block:: console - $ deactivate + $ deactivate This puts you back to the system's default Python interpreter with all its installed libraries. @@ -285,7 +289,7 @@ littered across your system, and its possible you'll forget their names or where they were placed. Other Notes ------------ +=========== Running ``virtualenv`` with the option ``--no-site-packages`` will not include the packages that are installed globally. This can be useful @@ -318,8 +322,9 @@ control by adding it to the ignore list (see :ref:`Version Control Ignores`_ provides a set of commands which makes working with virtual environments much @@ -329,9 +334,9 @@ To install (make sure **virtualenv** is already installed): .. code-block:: console - $ pip install virtualenvwrapper - $ export WORKON_HOME=~/Envs - $ source /usr/local/bin/virtualenvwrapper.sh + $ pip install virtualenvwrapper + $ export WORKON_HOME=~/Envs + $ source /usr/local/bin/virtualenvwrapper.sh (`Full virtualenvwrapper install instructions `_.) @@ -341,18 +346,19 @@ To install (make sure **virtualenv** is already installed): .. code-block:: console - $ pip install virtualenvwrapper-win + $ pip install virtualenvwrapper-win In Windows, the default path for WORKON_HOME is %USERPROFILE%\Envs + Basic Usage ------------ +=========== 1. Create a virtual environment: .. code-block:: console - $ mkvirtualenv my_project + $ mkvirtualenv my_project This creates the :file:`my_project` folder inside :file:`~/Envs`. @@ -360,7 +366,7 @@ This creates the :file:`my_project` folder inside :file:`~/Envs`. .. code-block:: console - $ workon my_project + $ workon my_project Alternatively, you can make a project, which creates the virtual environment, and also a project directory inside ``$WORKON_HOME``, which is ``cd`` -ed into @@ -368,7 +374,7 @@ when you ``workon myproject``. .. code-block:: console - $ mkproject myproject + $ mkproject myproject **virtualenvwrapper** provides tab-completion on environment names. It really helps when you have a lot of environments and have trouble remembering their @@ -381,16 +387,16 @@ can quickly switch between environments. .. code-block:: console - $ deactivate + $ deactivate 4. To delete: .. code-block:: console - $ rmvirtualenv venv + $ rmvirtualenv venv Other useful commands ---------------------- +===================== ``lsvirtualenv`` List all of the environments. @@ -407,14 +413,17 @@ Other useful commands `Full list of virtualenvwrapper commands `_. +****************** virtualenv-burrito ------------------- +****************** With `virtualenv-burrito `_, you can have a working virtualenv + virtualenvwrapper environment in a single command. + autoenv -------- +======= + When you ``cd`` into a directory containing a :file:`.env`, `autoenv `_ automagically activates the environment. @@ -422,11 +431,11 @@ Install it on Mac OS X using ``brew``: .. code-block:: console - $ brew install autoenv + $ brew install autoenv And on Linux: .. code-block:: console - $ git clone git://github.com/kennethreitz/autoenv.git ~/.autoenv - $ echo 'source ~/.autoenv/activate.sh' >> ~/.bashrc + $ git clone git://github.com/kennethreitz/autoenv.git ~/.autoenv + $ echo 'source ~/.autoenv/activate.sh' >> ~/.bashrc From ac7ea52fae4aa680b9c227050d28f3359bc04f0b Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 27 Nov 2018 06:59:58 +0100 Subject: [PATCH 4/4] autoenv hierarchy change / style applied to document --- docs/dev/virtualenvs.rst | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/dev/virtualenvs.rst b/docs/dev/virtualenvs.rst index 7805ff689..344f56971 100644 --- a/docs/dev/virtualenvs.rst +++ b/docs/dev/virtualenvs.rst @@ -16,7 +16,7 @@ presented here is most directly applicable to the development and deployment of network services (including web applications), but is also very well suited to managing development and testing environments for any kind of project. -.. Note:: This guide is written for Python 3, however, these instructions +.. note:: This guide is written for Python 3, however, these instructions should work fine on Python 2.7—if you are still using it, for some reason. @@ -35,7 +35,8 @@ You should get some output like ``3.6.2``. If you do not have Python, please install the latest 3.x version from `python.org`_ or refer to the `Installing Python`_ section of this guide. -.. Note:: If you're newcomer and you get an error like this: +.. note:: + If you're newcomer and you get an error like this: .. code-block:: python @@ -84,7 +85,8 @@ Use ``pip`` to install Pipenv: $ pip install --user pipenv -.. Note:: This does a `user installation`_ to prevent breaking any system-wide +.. note:: + This does a `user installation`_ to prevent breaking any system-wide packages. If ``pipenv`` isn't available in your shell after installation, you'll need to add the `user base`_'s binary directory to your ``PATH``. @@ -112,7 +114,6 @@ Use ``pip`` to install Pipenv: .. _modifying ~/.profile: https://stackoverflow.com/a/14638025 .. _Control Panel: https://msdn.microsoft.com/en-us/library/windows/desktop/bb776899(v=vs.85).aspx - Installing packages for your project ==================================== @@ -162,7 +163,6 @@ when you share your project with others. You should get output similar to this .. _Requests: https://python-requests.org - Using installed packages ======================== @@ -193,7 +193,6 @@ Using ``$ pipenv run`` ensures that your installed packages are available to your script. It's also possible to spawn a new shell that ensures all commands have access to your installed packages with ``$ pipenv shell``. - Next steps ========== @@ -322,6 +321,7 @@ control by adding it to the ignore list (see :ref:`Version Control Ignores`_. + ****************** virtualenv-burrito ****************** @@ -421,8 +421,9 @@ With `virtualenv-burrito `_, you can have a working virtualenv + virtualenvwrapper environment in a single command. +******* autoenv -======= +******* When you ``cd`` into a directory containing a :file:`.env`, `autoenv `_ automagically activates the environment.