[1.5.X] Fixed #19216 - Switched to user level installation in apps tutorial.

Thanks Nick Coghlan for the suggestion.

Backport of dd0d2c0be5 from master
This commit is contained in:
Tim Graham 2012-10-31 19:56:53 -04:00
parent f1be2c7a81
commit 958c1d12e5
1 changed files with 17 additions and 15 deletions

View File

@ -291,16 +291,19 @@ Using your own package
Since we moved the ``polls`` directory out of the project, it's no longer Since we moved the ``polls`` directory out of the project, it's no longer
working. We'll now fix this by installing our new ``django-polls`` package. working. We'll now fix this by installing our new ``django-polls`` package.
.. admonition:: Installing as a system library .. admonition:: Installing as a user library
The following steps install ``django-polls`` as a system library. In The following steps install ``django-polls`` as a user library. Per-user
general, it's best to avoid messing with your system libraries to avoid installs have a lot of advantages over installing the package system-wide,
breaking things. For this simple example though, the risk is low and it will such as being usable on systems where you don't have administrator access
help with understanding packaging. We'll explain how to uninstall in as well as preventing the package from affecting system services and other
step 4. users of the machine. Python 2.6 added support for user libraries, so if
you are using an older version this won't work, but Django 1.5 requires
Python 2.6 or newer anyway.
For experienced users, a neater way to manage your packages is to use Note that per-user installations can still affect the behavior of system
"virtualenv" (see below). tools that run as that user, so ``virtualenv`` is a more robust solution
(see below).
1. Inside ``django-polls/dist``, untar the new package 1. Inside ``django-polls/dist``, untar the new package
``django-polls-0.1.tar.gz`` (e.g. ``tar xzvf django-polls-0.1.tar.gz``). If ``django-polls-0.1.tar.gz`` (e.g. ``tar xzvf django-polls-0.1.tar.gz``). If
@ -310,9 +313,9 @@ working. We'll now fix this by installing our new ``django-polls`` package.
2. Change into the directory created in step 1 (e.g. ``cd django-polls-0.1``). 2. Change into the directory created in step 1 (e.g. ``cd django-polls-0.1``).
3. If you're using GNU/Linux, Mac OS X or some other flavor of Unix, enter the 3. If you're using GNU/Linux, Mac OS X or some other flavor of Unix, enter the
command ``sudo python setup.py install`` at the shell prompt. If you're command ``python setup.py install --user`` at the shell prompt. If you're
using Windows, start up a command shell with administrator privileges and using Windows, start up a command shell and run the command
run the command ``setup.py install``. ``setup.py install --user``.
With luck, your Django project should now work correctly again. Run the With luck, your Django project should now work correctly again. Run the
server again to confirm this. server again to confirm this.
@ -320,7 +323,7 @@ working. We'll now fix this by installing our new ``django-polls`` package.
4. To uninstall the package, use pip (you already :ref:`installed it 4. To uninstall the package, use pip (you already :ref:`installed it
<installing-reusable-apps-prerequisites>`, right?):: <installing-reusable-apps-prerequisites>`, right?)::
sudo pip uninstall django-polls pip uninstall django-polls
.. _bsdtar: http://gnuwin32.sourceforge.net/packages/bsdtar.htm .. _bsdtar: http://gnuwin32.sourceforge.net/packages/bsdtar.htm
.. _7-zip: http://www.7-zip.org/ .. _7-zip: http://www.7-zip.org/
@ -347,11 +350,10 @@ is choosing the license under which your code is distributed.
Installing Python packages with virtualenv Installing Python packages with virtualenv
========================================== ==========================================
Earlier, we installed the polls app as a system library. This has some Earlier, we installed the polls app as a user library. This has some
disadvantages: disadvantages:
* Modifying the system libraries can affect other Python software on your * Modifying the user libraries can affect other Python software on your system.
system.
* You won't be able to run multiple versions of this package (or others with * You won't be able to run multiple versions of this package (or others with
the same name). the same name).