Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate out virtualenv to its own sections #2551

Open
wants to merge 5 commits into
base: 8.1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/index.rst
Expand Up @@ -68,6 +68,7 @@ usage patterns.

why
quickstart
virtualenv
setuptools
parameters
options
Expand Down
61 changes: 4 additions & 57 deletions docs/quickstart.rst
Expand Up @@ -3,66 +3,13 @@ Quickstart

.. currentmodule:: click

You can get the library directly from PyPI::
Install
----------------------
Install from PyPI::

pip install click

The installation into a :ref:`virtualenv` is heavily recommended.

.. _virtualenv:

virtualenv
----------

Virtualenv is probably what you want to use for developing Click
applications.

What problem does virtualenv solve? Chances are that you want to use it
for other projects besides your Click script. But the more projects you
have, the more likely it is that you will be working with different
versions of Python itself, or at least different versions of Python
libraries. Let's face it: quite often libraries break backwards
compatibility, and it's unlikely that any serious application will have
zero dependencies. So what do you do if two or more of your projects have
conflicting dependencies?

Virtualenv to the rescue! Virtualenv enables multiple side-by-side
installations of Python, one for each project. It doesn't actually
install separate copies of Python, but it does provide a clever way to
keep different project environments isolated.

Create your project folder, then a virtualenv within it::

$ mkdir myproject
$ cd myproject
$ python3 -m venv .venv

Now, whenever you want to work on a project, you only have to activate the
corresponding environment. On OS X and Linux, do the following::

$ . .venv/bin/activate
(venv) $

If you are a Windows user, the following command is for you::

> .venv\scripts\activate
(venv) >

Either way, you should now be using your virtualenv (notice how the prompt of
your shell has changed to show the active environment).

And if you want to stop using the virtualenv, use the following command::

$ deactivate

After doing this, the prompt of your shell should be as familiar as before.

Now, let's move on. Enter the following command to get Click activated in your
virtualenv::

$ pip install click

A few seconds later and you are good to go.
Installing into a virtual environment is highly recommended. We suggest :ref:`virtualenv-heading`.

Screencast and Examples
-----------------------
Expand Down
45 changes: 45 additions & 0 deletions docs/virtualenv.rst
@@ -0,0 +1,45 @@
.. _virtualenv-heading:

Virtualenv
=========================

Why use virtualenv?
Rowlando13 marked this conversation as resolved.
Show resolved Hide resolved
-------------------------

You should use `Virtualenv <https://virtualenv.pypa.io/en/latest/>`_ because:

* It allows you to install multiple versions of the same dependency.

* If you have an operating system version of python, it prevents you from changing its dependencies and potentially messing up your os.
Rowlando13 marked this conversation as resolved.
Show resolved Hide resolved

How to use virtualenv
-----------------------------

Create your project folder, then a virtualenv within it::
Rowlando13 marked this conversation as resolved.
Show resolved Hide resolved

$ mkdir myproject
$ cd myproject
$ python3 -m venv .venv

Now, whenever you want to work on a project, you only have to activate the
corresponding environment. On OS X and Linux, do the following::

$ . .venv/bin/activate
(venv) $

On Windows, do the following::

> .venv\scripts\activate
(venv) >

You are now using your virtualenv (notice how the prompt of your shell has changed to show the active environment).

To install packages in the virtual environment::

$ pip install click

And if you want to stop using the virtualenv, use the following command::

$ deactivate

After doing this, the prompt of your shell should be as familiar as before.