Browse Source

Edited the installation guide.

pull/112/head
Matt Campbell 15 years ago committed by Armin Ronacher
parent
commit
f5e533076f
  1. 139
      docs/installation.rst

139
docs/installation.rst

@ -3,44 +3,41 @@
Installation Installation
============ ============
Flask is a microframework and yet it depends on external libraries. There Flask depends on two external libraries, `Werkzeug
are various ways how you can install that library and this explains each
way and why there are multiple ways.
Flask depends on two external libraries: `Werkzeug
<http://werkzeug.pocoo.org/>`_ and `Jinja2 <http://jinja.pocoo.org/2/>`_. <http://werkzeug.pocoo.org/>`_ and `Jinja2 <http://jinja.pocoo.org/2/>`_.
The first one is responsible for interfacing WSGI the latter for rendering Werkzeug is a toolkit for WSGI, the standard Python interface between web
templates. Now you are maybe asking, what is WSGI? WSGI is a standard applications and a variety of servers for both development and deployment.
in Python that is basically responsible for ensuring that your application Jinja2 renders templates.
is behaving in a specific way so that you can run it on different
environments (for example on a local development server, on an Apache2, on
lighttpd, on Google's App Engine or whatever you have in mind).
So how do you get all that on your computer in no time? The most kick-ass So how do you get all that on your computer quickly? There are many ways
method is virtualenv, so let's look at that first. which this section will explain, but the most kick-ass method is
virtualenv, so let's look at that first.
.. _virtualenv: .. _virtualenv:
virtualenv virtualenv
---------- ----------
Virtualenv is what you want to use during development and in production if Virtualenv is probably what you want to use during development, and in
you have shell access. So first: what does virtualenv do? If you are production too if you have shell access there.
like me and you like Python, chances are you want to use it for another
project as well. Now the more projects you have, the more likely it is What problem does virtualenv solve? If you like Python as I do,
that you will be working with different versions of Python itself or at chances are you want to use it for other projects besides Flask-based
least an individual library. Because let's face it: quite often libraries web applications. But the more projects you have, the more likely it is
break backwards compatibility and it's unlikely that your application will that you will be working with different versions of Python itself, or at
not have any dependencies, that just won't happen. So virtualenv to the least different versions of Python libraries. Let's face it; quite often
rescue! 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?
It basically makes it possible to have multiple side-by-side Virtualenv to the rescue! It basically enables multiple side-by-side
"installations" of Python, each for your own project. It's not actually installations of Python, one for each project. It doesn't actually
an installation but a clever way to keep things separated. install separate copies of Python, but it does provide a clever way
to keep different project environments isolated.
So let's see how that works! So let's see how virtualenv works!
If you are on OS X or Linux chances are that one of the following two If you are on Mac OS X or Linux, chances are that one of the following two
commands will work for you:: commands will work for you::
$ sudo easy_install virtualenv $ sudo easy_install virtualenv
@ -49,18 +46,19 @@ or even better::
$ sudo pip install virtualenv $ sudo pip install virtualenv
Chances are you have virtualenv installed on your system then. Maybe it's One of these will probably install virtualenv on your system. Maybe it's
even in your package manager (on ubuntu try ``sudo apt-get install even in your package manager. If you use Ubuntu, try::
python-virtualenv``).
$ sudo apt-get install python-virtualenv
If you are on Windows and missing the `easy_install` command you have to If you are on Windows and don't have the `easy_install` command, you must
install it first. Check the :ref:`windows-easy-install` section for more install it first. Check the :ref:`windows-easy-install` section for more
information about how to do that. Once you have it installed, run the information about how to do that. Once you have it installed, run the
same commands as above, but without the `sudo` part. same commands as above, but without the `sudo` prefix.
So now that you have virtualenv running just fire up a shell and create Once you have virtualenv installed, just fire up a shell and create
your own environment. I usually create a folder and a `env` folder your own environment. I usually create a project folder and an `env`
within:: folder within::
$ mkdir myproject $ mkdir myproject
$ cd myproject $ cd myproject
@ -68,14 +66,14 @@ within::
New python executable in env/bin/python New python executable in env/bin/python
Installing setuptools............done. Installing setuptools............done.
Now you only have to activate it, whenever you work with it. On OS X and Now, whenever you want to work on a project, you only have to activate
Linux do the following:: the corresponding environment. On OS X and Linux, do the following::
$ . env/bin/activate $ . env/bin/activate
(Note the whitespace between the dot and the script name. This means (Note the space between the dot and the script name. The dot means that
execute this file in context of the shell. If the dot does not work for this script should run in the context of the current shell. If this command
whatever reason in your shell, try substituting it with ``source``) does not work in your shell, try replacing the dot with ``source``)
If you are a Windows user, the following command is for you:: If you are a Windows user, the following command is for you::
@ -95,23 +93,22 @@ A few seconds later you are good to go.
System Wide Installation System Wide Installation
------------------------ ------------------------
This is possible as well, but I would not recommend it. Just run This is possible as well, but I do not recommend it. Just run
`easy_install` with root rights:: `easy_install` with root rights::
sudo easy_install Flask $ sudo easy_install Flask
(Run it in an Admin shell on Windows systems and without the `sudo`). (Run it in an Admin shell on Windows systems and without `sudo`).
Living on the Edge Living on the Edge
------------------ ------------------
You want to work with the latest version of Flask, there are two ways: you If you want to work with the latest version of Flask, there are two ways: you
can either let `easy_install` pull in the development version or tell it can either let `easy_install` pull in the development version, or tell it
to operate on a git checkout. Either way it's recommended to do that in a to operate on a git checkout. Either way, virtualenv is recommended.
virtualenv.
Get the git checkout in a new virtualenv and run in develop mode:: Get the git checkout in a new virtualenv and run in development mode::
$ git clone http://github.com/mitsuhiko/flask.git $ git clone http://github.com/mitsuhiko/flask.git
Initialized empty Git repository in ~/dev/flask/.git/ Initialized empty Git repository in ~/dev/flask/.git/
@ -124,9 +121,9 @@ Get the git checkout in a new virtualenv and run in develop mode::
... ...
Finished processing dependencies for Flask Finished processing dependencies for Flask
This will pull in the dependencies and activate the git head as current This will pull in the dependencies and activate the git head as the current
version. Then you just have to ``git pull origin`` to get the latest version inside the virtualenv. Then you just have to ``git pull origin``
version. to get the latest version.
To just get the development version without git, do this instead:: To just get the development version without git, do this instead::
@ -145,31 +142,29 @@ To just get the development version without git, do this instead::
`easy_install` on Windows `easy_install` on Windows
------------------------- -------------------------
On Windows installation of `easy_install` is a little bit tricker because On Windows, installation of `easy_install` is a little bit tricker because
on Windows slightly different rules apply, but it's not a biggy. The slightly different rules apply on Windows than on Unix-like systems, but
easiest way to accomplish that is downloading the `ez_setup.py`_ file and it's not difficult. The easiest way to do it is to download the
running it. (Double clicking should do the trick) `ez_setup.py`_ file and run it. The easiest way to run the file is to
open your downloads folder and double-click on the file.
Once you have done that it's important to add the `easy_install` command
and other Python scripts to the path. To do that you have to add the Next, add the `easy_install` command and other Python scripts to the
Python installation's Script folder to the `PATH` variable. command search path, by adding your Python installation's Scripts folder
to the `PATH` environment variable. To do that, right-click on the
To do that, right-click on your "Computer" desktop icon and click "Computer" icon on the Desktop or in the Start menu, and choose
"Properties". On Windows Vista and Windows 7 then click on "Advanced System "Properties". Then, on Windows Vista and Windows 7 click on "Advanced System
settings", on Windows XP click on the "Advanced" tab instead. Then click settings"; on Windows XP, click on the "Advanced" tab instead. Then click
on the "Environment variables" button and double click on the "Path" on the "Environment variables" button and double click on the "Path"
variable in the "System variables" section. variable in the "System variables" section. There append the path of your
Python interpreter's Scripts folder; make sure you delimit it from
There append the path of your Python interpreter's Script folder to the existing values with a semicolon. Assuming you are using Python 2.6 on
end of the last (make sure you delimit it from existing values with a the default path, add the following value::
semicolon). Assuming you are using Python 2.6 on the default path, add
the following value::
;C:\Python26\Scripts ;C:\Python26\Scripts
Then you are done. To check that it worked, open the cmd and execute Then you are done. To check that it worked, open the Command Prompt and
"easy_install". If you have UAC enabled it should prompt you for admin execute ``easy_install``. If you have User Account Control enabled on
privileges. Windows Vista or Windows 7, it should prompt you for admin privileges.
.. _ez_setup.py: http://peak.telecommunity.com/dist/ez_setup.py .. _ez_setup.py: http://peak.telecommunity.com/dist/ez_setup.py

Loading…
Cancel
Save