root/docs/intro/install.txt @ 648:80458a875eac

Revision 648:80458a875eac, 10.7 KB (checked in by Ioannis Gakos <gakos.ioannis@…>, 15 months ago)

Documentation added for python dependencies

Line 
1.. _intro-install:
2
3Quick install guide
4===================
5
6Before you can use Transifex, you'll need to get it installed. This guide
7will guide you to a simple, minimal installation that'll work while you
8walk through the introduction.
9
10Installing Python
11-----------------
12
13Being a Python Web tool, Transifex requires Python. We recommend
14installing Python 2.5 or later.
15
16Get Python at http://www.python.org. If you're running Linux or Mac OS X,
17you probably already have it installed.
18
19You can verify that Python's installed by typing ``python`` from your
20shell; you should see something like::
21
22    Python 2.5.1 (r251:54863, Jun 15 2008, 18:24:51)
23    [GCC 4.3.0 20080428 (Red Hat 4.3.0-8)] on linux2
24    Type "help", "copyright", "credits" or "license" for more information.
25    >>>
26
27
28Installing the Version Control Systems - VCS
29--------------------------------------------
30
31To run Transifex you need some VCS. Depending of which ones you want
32to use, you will need to install some of the following packages:
33
34* Bazaar (bzr)
35* CVS (cvs)
36* Git (git)
37* Mercurial (hg)
38* Subversion (svn)
39
40On Fedora you can run the following command to install all those VCS::
41
42    yum install cvs subversion pysvn mercurial git bzr bzrtools
43
44If you're enabling the tarball support, you also need urlgrabber::
45
46    yum install python-urlgrabber
47
48
49Installing Django
50-----------------
51
52Transifex is developed on top of a Python Web Framework called Django. We
53recommend installing Django 1.0. You can get more information about how
54to install Django in your system from the official Django documentation.
55
56Usually you can use the package your distribution provides you, or you can
57even use `easy_install` to setup the package. On Fedora you can just run::
58
59    yum install Django
60
61.. _install-django-deps:
62
63
64Installing Python dependencies
65------------------------------
66
67This is the generic method for creating a development environment for
68Transifex. We strongly suggest running those commands inside a virtualenv
69environment instead of running them as root. For an example of a Virtualenv
70setup, take a look at the `Virtualenv example`_ wiki page. You can also
71install some of these dependencies as packages in your distribution, if they
72are available.
73
74.. code-block:: bash
75
76    easy_install Markdown httplib2 pygments polib
77    easy_install Django python-openid django-authopenid django-pagination
78    easy_install django-notification
79    easy_install -f http://transifex.org/files/deps/ contact_form tagging django_evolution userprofile
80
81
82Installing translation-specific packages
83----------------------------------------
84
85Transifex requires a couple of standard packages to support translations.
86Currently these are the following.:
87
88* gettext (standard Internationalization library)
89* intltool (for dynamic ``POT``-file generation)
90
91On Fedora you can just run::
92
93    yum install gettext intltool
94
95
96A note on ``PythonPath``
97~~~~~~~~~~~~~~~~~~~~~~~~
98
99These applications can be installed anywhere on your system, as long as Python
100can find them. Python uses the ``PythonPath`` environment variable for this.
101The value you use for ``PythonPath`` should include the parent directories of
102all the modules you are going to import in your application. It should also
103include the parent directory of Transifex itself.
104This is exactly the same situation as
105setting the Python path for interactive usage. Whenever you try to import
106something, Python will run through all the directories in ``sys.path`` in turn,
107from first to last, and try to import from each directory until one succeeds.
108
109An example might make this clearer. Suppose you have some applications under
110``/usr/local/django-apps/`` (for example, ``/usr/local/django-apps/weblog/`` and
111so forth), your settings file is at ``/var/www/mysite/settings.py`` and you have
112specified DJANGO_SETTINGS_MODULE_ as in the above
113example. In this case, you would need to write your ``PythonPath`` directive
114as::
115
116    PythonPath "['/usr/local/django-apps/', '/var/www'] + sys.path"
117
118With this path, ``import weblog`` and ``import mysite.settings`` will both
119work. If you had ``import blogroll`` in your code somewhere and ``blogroll``
120lived under the ``weblog/`` directory, you would *also* need to add
121``/usr/local/django-apps/weblog/`` to your ``PythonPath``. Remember: the
122**parent directories** of anything you import directly must be on the Python
123path.
124
125.. _DJANGO_SETTINGS_MODULE: http://docs.djangoproject.com/en/dev/topics/settings/#django-settings-module
126
127
128Installing Transifex
129--------------------
130
131You'll need to get Transifex, initialize its database and optionally import
132some sample data.
133
134Get Transifex
135~~~~~~~~~~~~~
136
137You can get the source code in a number of ways.
138
139Stable releases are available from the following location(s):
140
141- http://transifex.org/files/
142- http://pypi.python.org/pypi/transifex
143
144Soon, Tx will land in a yum repo near you, and you'll be able to
145install it with something like ``yum install transifex``. See also the
146README file in the root of your source.
147
148Development version
149+++++++++++++++++++
150
151The current development version of Transifex can be fetched by cloning the
152development repo::
153
154    hg clone http://code.transifex.org/mainline
155
156From here you can also switch to stable versions, which are tagged
157appropriately.::
158
159    hg tags
160    hg update <tag>
161
162To grab a branched development version of Transifex, you can navigate to
163http://code.transifex.org/ to see the active branches.
164
165Initialize the database
166~~~~~~~~~~~~~~~~~~~~~~~
167
168After you have all dependencies and packages installed, the Transifex
169installation should be very simple. Customize ``settings/*.conf`` and
170``urls.py`` to accommodate your server's needs.
171
172To enable Transifex's notifications you'll need to switch the relevant setting
173called ENABLE_NOTICES to ``True``.
174
175Once you're done configuring, run inside the project directory::
176
177    ./manage.py syncdb
178    ./manage.py txcreatedirs
179    ./manage.py runserver 8088
180
181The first command will create the necessary database tables. It will also ask
182you to create an admin user (superuser), who will have access to the admin panel
183(by default accessible through ``/admin/``).
184
185Fire up your browser at ``http://localhost:8088/`` and grab a cup of coffee.
186
187.. warning::
188 
189    Make sure you have created in your system all the directories configured
190    in your ``settings.py`` file, like the ``REPO_PATH`` for example.
191    Without those paths created, the checkout for these VCS, among others will
192    fail.
193
194Import some data
195~~~~~~~~~~~~~~~~
196
197Transifex uses the fixtures feature of Django to load some initial datas
198in the database. The following commands require you having run
199``./manage.py syncdb`` at least once before in order for the database tables
200to exist.
201
202The following commands loads a bunch of sample data to play around with.
203
204.. code-block:: bash
205
206    ./manage.py loaddata txcommon/fixtures/sample_data.json
207    ./manage.py loaddata txcommon/fixtures/sample_users.json
208
209The last command created two users: 'guest' and 'editor'. The 'guest' has the
210basic rights of a logged-in user of the site, while the 'editor' account has
211more advanced privileges like modifying projects, etc. Together with the 'admin'
212user created with the 'syncdb' step above, you should have 3 accounts now, each
213with its own access level.
214
215You can now fire up your browser to check out the newly imported data.
216
217Note that the registered projects have not been actually checked out by
218Transifex yet. To have translation files downloaded and fresh statistics
219produced, run a fresh checkout::
220
221    ./manage.py txstatsrefresh
222
223This command is usually used in a cronjob to refresh Transifex's cache and
224translation statistics every once in a while for translators.
225
226Internationalization (i18n) support
227~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
228
229To be able to use Transifex with a localized interface, it is necessary to
230create the translations objects files (.mo) using one of the following commands,
231for example:
232   
233.. code-block:: bash
234
235    ./manage.py compilemessages -l pt_BR
236    or
237    ./manage.py compilemessages --all
238
239
240Customizing your Transifex instance
241-----------------------------------
242
243Site Domain and Name
244~~~~~~~~~~~~~~~~~~~~
245
246Transifex leverages the power of Django's Sites_ framework to make it easy
247to have instances of Transifex on differnet domains using the same models
248and database.
249
250Upon installation, a single website is created in the database called
251'example.com'. This value is used in a number of places, including emails sent
252by the system. You can customize this value in two ways:
253
254* Using the `Django admin panel`_: By default Transifex comes with a handy
255  admin panel. This is mounted by default at ``/admin/`` (this value can be
256  changed from your settings file.
257 
258  Login to the admin panel using the credentials you created during the
259  database creation step. You'll find the 'example.com' entry in the ``Sites``
260  model, which you can edit to your needs.
261
262* Using the command line::
263
264    from django.contrib.sites.models import Site
265    current_site = Site.objects.get_current()
266    current_site.name = 'Transifex'
267    current_site.domain = 'mydomain.com'
268    current_site.save()
269
270User Interface
271~~~~~~~~~~~~~~
272
273The default Transifex interface lives in the ``templates`` directory and can
274be customized at will.
275
276You can also customize the theme by copying this directory to a differnet
277location and updating the ``TEMPLATE_DIR`` setting with this new location.
278
279Finally, Django supports multiple locations of template source files, which it
280searches in order. Instead of copying the entire template directory, you can
281simply copy particular files you'd like to override and define the
282``TEMPLATE_DIR`` setting as a tuple in the order you'd like the directories
283to be searched (first entry takes preference over second, etc). 
284
285
286Debugging
287---------
288
289Debugging is enabled through a separete ``SETTINGS`` file, which enables some
290additional applications and features. Some of these additional applications
291might require installation using ``easy_install``, but you can enable any
292number you want by editing the ``settings_debug.py`` file.
293
294Some of these applications define their own models, so the first time you'll
295use the file, a 'syncdb' using that file will be needed to have the respective
296database tables created::
297 
298    ./manage.py syncdb --settings settings_debug
299
300From that point on, you can run the debug server as follows::
301
302    ./manage.py runserver --settings settings_debug
303   
304
305Testing
306-------
307
308For testing the whole project you can run::
309
310    ./manage.py test
311
312For testing a specific application inside Transifex you can run::
313 
314    ./manage.py test projects
315
316
317.. _Sites: http://docs.djangoproject.com/en/dev/ref/contrib/sites
318.. _`Django admin panel`: http://www.djangobook.com/en/1.0/chapter06/
319.. _`Virtualenv example`: http://transifex.org/wiki/Development/InstallationOnCentOS_VirtaualEnv
Note: See TracBrowser for help on using the browser.