Updated contributing tutorial's virtual environment instructions.

This commit is contained in:
Thomas Grainger 2018-09-19 10:41:22 +01:00 committed by Tim Graham
parent a0d63b02c3
commit c99d379f53
2 changed files with 20 additions and 33 deletions

View File

@ -320,6 +320,8 @@ class ConsoleDirective(CodeBlock):
return 'runtests.py ' + args_to_win(line[15:]) return 'runtests.py ' + args_to_win(line[15:])
if line.startswith('$ ./'): if line.startswith('$ ./'):
return args_to_win(line[4:]) return args_to_win(line[4:])
if line.startswith('$ python3'):
return 'py ' + args_to_win(line[9:])
if line.startswith('$ python'): if line.startswith('$ python'):
return 'py ' + args_to_win(line[8:]) return 'py ' + args_to_win(line[8:])
if line.startswith('$ '): if line.startswith('$ '):

View File

@ -117,38 +117,22 @@ Download the Django source code repository using the following command:
Now that you have a local copy of Django, you can install it just like you would Now that you have a local copy of Django, you can install it just like you would
install any package using ``pip``. The most convenient way to do so is by using install any package using ``pip``. The most convenient way to do so is by using
a *virtual environment* (or virtualenv) which is a feature built into Python a *virtual environment*, which is a feature built into Python that allows you
that allows you to keep a separate directory of installed packages for each of to keep a separate directory of installed packages for each of your projects so
your projects so that they don't interfere with each other. that they don't interfere with each other.
It's a good idea to keep all your virtualenvs in one place, for example in It's a good idea to keep all your virtual environments in one place, for
``.virtualenvs/`` in your home directory. Create it if it doesn't exist yet: example in ``.virtualenvs/`` in your home directory.
Create a new virtual environment by running:
.. console:: .. console::
$ mkdir ~/.virtualenvs $ python3 -m venv ~/.virtualenvs/djangodev
Now create a new virtualenv by running:
.. console::
$ python -m venv ~/.virtualenvs/djangodev
The path is where the new environment will be saved on your computer. The path is where the new environment will be saved on your computer.
.. admonition:: For Ubuntu users The final step in setting up your virtual environment is to activate it:
On some versions of Ubuntu the above command might fail. Use the
``virtualenv`` package instead, first making sure you have ``pip3``:
.. code-block:: console
$ sudo apt-get install python3-pip
$ # Prefix the next command with sudo if it gives a permission denied error
$ pip3 install virtualenv
$ virtualenv --python=`which python3` ~/.virtualenvs/djangodev
The final step in setting up your virtualenv is to activate it:
.. code-block:: console .. code-block:: console
@ -162,22 +146,23 @@ If the ``source`` command is not available, you can try using a dot instead:
.. admonition:: For Windows users .. admonition:: For Windows users
To activate your virtualenv on Windows, run: To activate your virtual environment on Windows, run:
.. code-block:: doscon .. code-block:: doscon
...\> %HOMEPATH%\.virtualenvs\djangodev\Scripts\activate.bat ...\> %HOMEPATH%\.virtualenvs\djangodev\Scripts\activate.bat
You have to activate the virtualenv whenever you open a new terminal window. You have to activate the virtual environment whenever you open a new
virtualenvwrapper__ is a useful tool for making this more convenient. terminal window. virtualenvwrapper__ is a useful tool for making this
more convenient.
__ https://virtualenvwrapper.readthedocs.io/en/latest/ __ https://virtualenvwrapper.readthedocs.io/en/latest/
Anything you install through ``pip`` from now on will be installed in your new The name of the currently activated virtual environment is displayed on the
virtualenv, isolated from other environments and system-wide packages. Also, the command line to help you keep track of which one you are using. Anything you
name of the currently activated virtualenv is displayed on the command line to install through ``pip`` while this name is displayed will be installed in that
help you keep track of which one you are using. Go ahead and install the virtual environment, isolated from other environments and system-wide packages.
previously cloned copy of Django: Go ahead and install the previously cloned copy of Django:
.. console:: .. console::