| 1 |
.. _installation: |
| 2 |
|
| 3 |
Installation |
| 4 |
============ |
| 5 |
|
| 6 |
Babel is distributed as a standard Python package fully set up with all |
| 7 |
the dependencies it needs. On Python versions where the standard library |
| 8 |
`zoneinfo`_ module is not available, `pytz`_ needs to be installed for |
| 9 |
timezone support. If `pytz`_ is installed, it is preferred over the |
| 10 |
standard library `zoneinfo`_ module where possible. |
| 11 |
|
| 12 |
.. _pytz: https://pythonhosted.org/pytz/ |
| 13 |
|
| 14 |
.. _zoneinfo: https://docs.python.org/3/library/zoneinfo.html |
| 15 |
|
| 16 |
.. _virtualenv: |
| 17 |
|
| 18 |
virtualenv |
| 19 |
---------- |
| 20 |
|
| 21 |
Virtualenv is probably what you want to use during development, and if you |
| 22 |
have shell access to your production machines, you'll probably want to use |
| 23 |
it there, too. Use ``pip`` to install it:: |
| 24 |
|
| 25 |
$ sudo pip install virtualenv |
| 26 |
|
| 27 |
If you're on Windows, run it in a command-prompt window with administrator |
| 28 |
privileges, and leave out ``sudo``. |
| 29 |
|
| 30 |
Once you have virtualenv installed, just fire up a shell and create |
| 31 |
your own environment. I usually create a project folder and a `venv` |
| 32 |
folder within:: |
| 33 |
|
| 34 |
$ mkdir myproject |
| 35 |
$ cd myproject |
| 36 |
$ virtualenv venv |
| 37 |
New python executable in venv/bin/python |
| 38 |
Installing distribute............done. |
| 39 |
|
| 40 |
Now, whenever you want to work on a project, you only have to activate the |
| 41 |
corresponding environment. On OS X and Linux, do the following:: |
| 42 |
|
| 43 |
$ . venv/bin/activate |
| 44 |
|
| 45 |
If you are a Windows user, the following command is for you:: |
| 46 |
|
| 47 |
$ venv\scripts\activate |
| 48 |
|
| 49 |
Either way, you should now be using your virtualenv (notice how the prompt of |
| 50 |
your shell has changed to show the active environment). |
| 51 |
|
| 52 |
Now you can just enter the following command to get Babel installed in your |
| 53 |
virtualenv:: |
| 54 |
|
| 55 |
$ pip install Babel |
| 56 |
|
| 57 |
A few seconds later and you are good to go. |
| 58 |
|
| 59 |
System-Wide Installation |
| 60 |
------------------------ |
| 61 |
|
| 62 |
This is possible as well, though I do not recommend it. Just run `pip` |
| 63 |
with root privileges:: |
| 64 |
|
| 65 |
$ sudo pip install Babel |
| 66 |
|
| 67 |
(On Windows systems, run it in a command-prompt window with administrator |
| 68 |
privileges, and leave out `sudo`.) |
| 69 |
|
| 70 |
|
| 71 |
Living on the Edge |
| 72 |
------------------ |
| 73 |
|
| 74 |
If you want to work with the latest version of Babel, you will need to |
| 75 |
use a git checkout. |
| 76 |
|
| 77 |
Get the git checkout in a new virtualenv and run in development mode:: |
| 78 |
|
| 79 |
$ git clone https://github.com/python-babel/babel |
| 80 |
Initialized empty Git repository in ~/dev/babel/.git/ |
| 81 |
$ cd babel |
| 82 |
$ virtualenv venv |
| 83 |
New python executable in venv/bin/python |
| 84 |
Installing distribute............done. |
| 85 |
$ . venv/bin/activate |
| 86 |
$ python setup.py import_cldr |
| 87 |
$ pip install --editable . |
| 88 |
... |
| 89 |
Finished processing dependencies for Babel |
| 90 |
|
| 91 |
Make sure to not forget about the ``import_cldr`` step because otherwise |
| 92 |
you will be missing the locale data. |
| 93 |
The custom setup command will download the most appropriate CLDR release from the |
| 94 |
official website and convert it for Babel. |
| 95 |
|
| 96 |
This will pull also in the dependencies and activate the git head as the |
| 97 |
current version inside the virtualenv. Then all you have to do is run |
| 98 |
``git pull origin`` to update to the latest version. If the CLDR data |
| 99 |
changes you will have to re-run ``python setup.py import_cldr``. |