| Prerequisite | Version |
|---|---|
| Python | 2.5 [1] |
| PostgreSQL | 8.3 [2] |
| PostGIS | 1.4 [3] |
| psycopg2 | 2.2 [9] |
| setuptools | 0.6 [5] |
| Django | 1.2 [4] |
| django-profiles | 0.2 [4] |
| django-registration | 0.7 [4] |
| django-pagination | 1.0 [4] |
| django-extensions | 0.6 [8] |
| django-piston | 0.2 [4] |
| south | 0.7 [4] |
| django-notify | 1.1 [4] |
| django-ajax-selects | 1.1 [4] |
| grapelli | 2.2 [7] |
| json [10] | |
| Mercurial [11] | |
| python-markdown |
Note for production installations
These prerequisites are for development installations. For production installations you also need a web server.
[1] Enhydris runs on Python 2.5, 2.6 and 2.7. It should also run on any later 2.x version. Python 2.5 support will be dropped soon (after Debian 6 is released). Enhydris does not run on Python 3.
[2] Enhydris is known to run on PostgreSQL 8.4 and 9.0, and it should also run without problem on PostgreSQL 8.3. In order to avoid possible incompatibilities with psycopg2, it is better to use the version prepackaged by your operating system when running on GNU/Linux, and to use the latest PostgreSQL version when running on Windows. If there is a problem with your version of PostgreSQL, email us and we’ll try to check if it is easy to fix.
[3] Except for PostGIS, more libraries, namely geos and proj, are needed; however, you probably not need to worry about that, because in most GNU/Linux distributions PostGIS has a dependency on them and therefore they will be installed automatically, whereas in Windows the installation file of PostGIS includes them. Enhydris is known to run on PostGIS 1.4 and 1.5. It probably can run on later versions as well. It is not known whether it can run on earlier versions.
[4] The table indicates the versions of various Python and Django modules on which Enhydris is known to run. Usually it can run on later versions as well.
[5] setuptools is needed in order to install the rest of the Python modules; Enhydris does not actually need it.
[6] Enhydris requires Django 1.2. In theory, Django 1.x versions are backwards compatible, but in practice this is not always the case. If you try to run it in a later Django 1.x version and find out that there is a problem, email us and we’ll try to check if it is easy to fix.
[7] Enhydris currently does not run on grappelli versions later than 2.2. Since there are no means to download grappelli other than using subversion, we have made an easy_install-able grappelli available for download at http://openmeteo.org/downloads/.
[8] Enhydris is also known to run on earlier django-extensions; however, some tests fail in that case.
[9] Because of a Django bug which is present in Django versions up to and including 1.3, tests fail on psycopg2 2.4.2 or later. Therefore you should either use Django 1.4 or later, or psycopg2 no later than 2.4.1, or not expect the tests to run.
Note for maintainers
To create the easy_install-able grappelli, do this:
cd /tmp
svn co http://django-grappelli.googlecode.com/svn/tags/releases/2.2/ grappelli-2.2
cd grappelli-2.2
cat >setup.py <<EOF1
#!/usr/bin/python
from setuptools import setup, find_packages
setup(
name = "grappelli",
version = "2.2",
license = "BSD",
description = "A jazzy skin for the Django admin",
author = "sehmaschine et al.",
packages = find_packages(),
)
EOF1
chmod 755 setup.py
./setup.py bdist_egg
scp dist/* root@openmeteo.org:/var/www/openmeteo.org/downloads/
[10] json is included in Python 2.6 or later.
[11] Mercurial is needed in order to download openmeteo software, not for running it.
Example: Installing prerequisites on Ubuntu
These instructions are for Ubuntu 10.10. For earlier versions you need to install django and its modules using easy_install, as the operating system packages are too old:
aptitude install python postgresql postgis postgresql-8.4-postgis \
python-psycopg2 python-setuptools python-django-registration \
python-django-south mercurial python-markdown
easy_install django-extensions
easy_install django-profiles
easy_install django-pagination
easy_install django-piston
easy_install django-notify
easy_install django-ajax-selects
easy_install --no-deps https://openmeteo.org/downloads/grappelli-2.2-py2.6.egg
Tip
If you want to install a specific version of a package, use something like this:
easy_install "django==1.2.3"
You can do this even if you have another version installed, and it will automatically remove the installed version and replace it with the version you specified.
Example: Installing prerequisites on Windows
Download and install the latest Python 2.x version from http://python.org/ (use the Windows Installer package).
Add the Python installation directory (such as C:\Python27) and its Scripts subdirectory (such as C:\Python27\Scripts) to the system path (right-click on My Computer, Properties, Advanced, Environment variables, under “System variables” double-click on Path, and add the two new directory names at the end, using semicolon to delimit them).
Download and install an appropriate PostgreSQL version (8.4 and 9.0 are known to work) from http://postgresql.org/ (use a binary Windows installer). Important: at some time the installer will create an operating system user and ask you to define a password for that user; keep the password; you will need it later.
Note for 64-bit Windows
At the time of this writing, a 64-bit version of PostGIS for Windows is not available; therefore you may be unable to proceed with the next step. In that case, you need to either install 32-bit PostgreSQL, or compile PostGIS yourself.
Go to Start, All programs, PostgreSQL, Application Stack Builder, select your PostgreSQL installation on the first screen, then, on the application selection screen, select Spatial Extensions, PostGIS. Allow it to install (you don’t need to create a spatial database at this stage).
Download and install the appropriate PostGIS version from http://www.postgis.org/download/windows/. Note that only 32-bit versions are currently available.
Download and install psycopg2 for Windows from http://www.stickpeople.com/projects/python/win-psycopg/.
Download and install setuptools from http://pypi.python.org/pypi/setuptools (you probably need to go to http://pypi.python.org/pypi/setuptools#files and pick the .exe file that corresponds to your Python version).
Note for 64-bit Python
There is no 64-bit .exe file for setuptools, and the 32-bit file will not work. In that case, instead of the Windows Installer file, download the “source” file, and extract its contents into a directory. Open a Command Prompt, go inside that directory, and run python setup.py install.
If you want to verify that the installation worked, run the command easy_install –help at a command prompt; it should give you a long usage message.
Download and install the Windows Installer package of TortoiseHg with Mercurial from http://mercurial.selenic.com/downloads/.
Finally, open a Command Prompt and give the following commands:
easy_install django
easy_install django-profiles
easy_install django-registration
easy_install django-pagination
easy_install django-extensions
easy_install django-piston
easy_install south
easy_install django-notify
easy_install django-ajax-selects
easy_install --no-deps https://openmeteo.org/downloads/grappelli-2.2-py2.6.egg
You need to create a database user and a database (we use enhydris_user and enhydris_db in the examples below). Enhydris will be connecting to the database as that user. The user should not be a super user, not be allowed to create databases, and not be allowed to create more users.
GNU example
sudo -u postgres -s
createuser --pwprompt enhydris_user
createdb --owner enhydris_user enhydris_db
exit
You may also need to edit your pg_hba.conf file as needed (under /var/lib/pgsql/data/ or /etc/postgresql/8.x/main/, depending on your system). The chapter on client authentication of the PostgreSQL manual explains this in detail. A simple setup is to authenticate with username and password, in which case you should add or modify the following lines in pg_hba.conf:
local all all md5
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
Restart the server to read the new pg_hba.conf configuration. For example, in Ubuntu:
service postgresql restart
Windows example
Assuming PostgreSQL is installed at the default location, run these at a command prompt:
cd C:\Program Files\PostgreSQL\9.0\bin
createuser -U postgres --pwprompt enhydris_user
createdb -U postgres --owner enhydris_user enhydris_db
At some point, these commands will ask you for the password of the operating system user.
Assuming the database is called “enhydris_db” and the user is “enhydris_user”, run the following:
createlang -U postgres plpgsql enhydris_db
psql -d enhydris_db -U postgres -f postgis.sql
psql -d enhydris_db -U postgres -f postgis_comments.sql
psql -d enhydris_db -U postgres -f spatial_ref_sys.sql
psql -U postgres enhydris_db
grant select on spatial_ref_sys to enhydris_user;
grant all on geometry_columns to enhydris_user;
\q
The location of the files postgis.sql, postgis_comments.sql and spatial_ref_sys.sql depends on your installation. In Ubuntu 10.10 they are at /usr/share/postgresql/8.4/contrib/. In Windows, they are somewhere like C:\Program Files\PostgreSQL\9.0\share\contrib\postgis-1.5; also note that for these commands to run you must be in the PostgreSQL bin directory, or have it in the path.
Clone the Mercurial repository http://openmeteo.org/openmeteo.
GNU example
hg clone http://openmeteo.org/openmeteo
This will create a openmeteo directory inside the current directory, which should be somewhere inside your home directory for a development instance, or /usr/local for a production instance.
Windows example
Go to the folder in which you want to download the software, right-click on the empty space, and choose TortoiseHg, Clone (if these options do not appear, it may be that you did not restart the machine after installing TortoiseHg). In the Source path field, specify http://openmeteo.org/openmeteo. Hit the Clone button.
Dickinson is a shared library (a DLL in Windows parlance) which you need to compile and install. Instructions for that are in the downloaded openmeteo/dickinson/README file.
Note for Windows users who want to avoid compiling
We occasionally compile the DLL and make the compiled version available at http://openmeteo.org/downloads/. The file is named something like dickinson-x86-rXXX.dll. This means that it is the compiled file that corresponds to repository revision XXX. Right-click on your openmeteo directory and select “Hg Repository Explorer”; the current revision of your directory will be at the top of the list. If there is a difference, the compiled version we provide may still work; this will be the case when there has been no change in pthelma or dickinson between the two revisions. If at all in doubt, go ahead and compile it. Otherwise, download dickinson-x86-rXXX.dll, rename it to dickinson.dll, and put it somewhere where the system can find it, such as C:\Windows\System32.
Pthelma is a Python library. You can install it system wide by running python setup.py install inside the openmeteo/pthelma directory, but it is recommended to not install it, and instead to use it directly from the openmeteo/pthelma directory. To do this, set the PYTHONPATH environment variable to the openmeteo/pthelma directory.
Bash example
Assuming the openmeteo directory is in your home directory:
export PYTHONPATH=~/openmeteo/pthelma
Instead of the above, what I actually do is prefix commands with the environment variable; for example, to run the Django development server:
PYTHONPATH=~/openmeteo/pthelma ./manage.py runserver
This has the added benefit that it works even if there are many openmeteo instances on my system.
Windows example
Assuming the openmeteo directory is on your Desktop:
set PYTHONPATH=C:\Documents and settings\%USERNAME%\Desktop\openmeteo\pthelma
In the directory openmeteo/enhydris, copy the file settings-example.py to settings.py, and copy the file urls-example.py to urls.py. Open settings.py in an editor and make the following changes:
In order to initialize your database and create the necessary database tables for Enhydris to run, run the following commands inside the openmeteo/enhydris directory:
python manage.py syncdb --noinput
python manage.py migrate dbsync
python manage.py migrate hcore
python manage.py createsuperuser
The above commands will also ask you to create a Enhydris superuser.
Confused by users?
There are operating system users, database users, and Enhydris users. PostgreSQL runs as an operating system user, and so does the web server, and so does Django and therefore Enhydris. Now the application (i.e. Enhydris/Django) needs a database connection to work, and for this connection it connects to the database as a database user. For the end users, that is, for the actual people who use Enhydris, Enhydris/Django keeps a list of usernames and passwords in the database, which have nothing to do with operating system users or database users. The Enhydris superuser created by the ./manage.py createsuperuser command is such an Enhydris user, and is intended to represent a human.
Advanced Django administrators can also use alternative authentication backends, such as LDAP, for storing the Enhydris users.
Inside the openmeteo/enhydris directory, run the following command:
python manage.py runserver 8088
The above command will start the Django development server and set it to listen to port 8088. If you then start your browser and point it to http://localhost:8088/, you should see Enhydris in action. Note that this only listens to the localhost; if you want it to listen on all interfaces, use 0.0.0.0:8088 instead.
To use Enhydris in production, you need to setup a web server such as apache. This is described in detail in Deploying Django.
After you run Enhydris, logon as a superuser, visit the admin panel, go to Sites, edit the default site, and enter your domain name there instead of example.com. Emails to users for registration confirmation will appear to be coming from that domain. Restart the webserver after changing the domain name.
These are the settings available to Enhydris, in addition to the Django settings.
If the instance is configured as a data aggregator and doesn’t have the actual data locally stored, in order to fetch the data from another instance a user name and password must be provided which correspond to a superuser account in the remote instance. Many instances can be configured using this setting, each with its own user/pass combination following this scheme:
REMOTE_INSTANCE_CREDENTIALS = {
'kyy.hydroscope.gr': ('myusername','mypassword'),
'itia.hydroscope.gr': ('anotheruser','anotherpass')
}