Installing Pyaella

System / Library Requirements

  • Mac OS X 10.9 < or Ubuntu 14.04 LTS
  • PostgreSQL 9.2 <
  • PostGIS 2 <
  • Python 2.7
  • file
  • libjpeg9 (optional)
  • opencv2 (optional)
  • mediainfo (optional)


Github

git clone http://github.com/migacollabs/Pyaella@master

Github into a virtualenv

pip install git+https://github.com/migacollabs/Pyaella@master

Pyaella is opinionated, and sometimes unapologetically so. It only supports PostgreSQL and other open-source, enterprise-quality solutions like PostGIS. This results in a large dependency tree. When installed using pip the following packages are installed automatically.

Python Package Requirements

  • Babel==1.3
  • Chameleon==2.11
  • GeoAlchemy2==0.2.1
  • Mako==0.9.1
  • MarkupSafe==0.23
  • PasteDeploy==1.5.2
  • Pillow==2.9.0
  • PyYAML==3.10
  • Pyaella==0.7.9
  • Pygments==1.6
  • SQLAlchemy==1.0.6
  • Shapely==1.5.9
  • WebOb==1.3.1
  • boto==2.9.8
  • distribute==0.6.31
  • docutils==0.12
  • futures==2.1.4
  • isodate==0.4.9
  • jsonpickle==0.4.0
  • numpy==1.8.0
  • psycopg2==2.6.1
  • pyasn1==0.1.7
  • pycrypto==2.6
  • pygeocoder==1.2.5
  • pyramid==1.5b1
  • pyramid-debugtoolbar==2.4
  • pyramid-mako==0.3.1
  • python-geohash==0.8.5
  • python-geoip==1.2
  • python-geoip-geolite2==2015.0303
  • python-magic==0.4.6
  • qrcode==3.1.1
  • redis==2.8.0
  • repoze.lru==0.6
  • requests==2.2.1
  • rsa==3.1.1
  • six==1.9.0
  • translationstring==1.1
  • venusian==1.0
  • waitress==0.8.5
  • wsgiref==0.1.2
  • zope.deprecation==4.1.2
  • zope.interface==4.1.2

Installing on a Mac

Pyaella can use Python and PostgreSQL framework installs, but out-of-the-box it is much easier to use MacPorts. Using port will create a separate and clean /opt/ directory and environment with more traditional Unix structure and linking.

Download and install MacPorts. Once it is installed, by following all the instructions, make sure to run the port selfupdate command before continuing.

Warning

Because MacPorts still builds the software from source, the Apple Developer Tools are required. These will have to be installed first!

AND... Its highly dangerous to use multiple Package Managers at the same time, so if you are using Homebrew or something else, stick to that!

Install Python 2.7.x.

sudo port install python27

Now make sure the Mac Ports Python is selected and active. We don’t wnat to be installing packages into the wrong Python environment.

sudo port select --set python python27

We are going to install Python packages using pip. Lets get pip using Mac Ports

sudo port install py27-pip

Installing bacis unix utilities

sudo port install filemagic

Installing mediainfo (optional)

Download and install the appropriate version from http://mediaarea.net/en/MediaInfo

Installing JPEG support (optional)

Strangely, adding JPEG encoding and decoding support on a Mac can be troublesome. Its best to get this done immediately before any other dependent libraries need be built.

Download libjpeg9. Unpack the gz and follow the normal compilation instruction. Such as:

./configure
make
./sudo make install

Installing OpenCV support (optional)

Pyaella uses OpenCV for image and video processing. There are many was to build OpenCV, but the easiest on a Mac is again using MacPorts, with the Python binding variant. This will download, configure, compile and install opencv along with the Python 2.7 bindings.

sudo port install opencv +python27

Warning

OpenCV and the Python bindings will not be available to a project using virtualenv without coping the .so to the virtualenv’s lib.



Initializing a PostgreSQL Database

Install the PostgreSQL client libraries.

sudo port install postgresql93

Install the PostgreSQL server, so a local database is available for development. This is optional but highly recommended.

sudo port install postgresql93-server

Install the PostGIS extension

sudo port install postgis2

Warning

Be sure to install PostGIS2 and not PostGIS1.5!

The following commands are the typical PostgreSQL installation process on a Mac OS X machine after using MacPorts:

sudo mkdir -p /opt/local/var/db/postgresql93/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql93/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql93/bin/initdb -D /opt/local/var/db/postgresql93/defaultdb'

Note

Starting and stopping the local development database

cd /opt/local/etc/LaunchDaemons/org.macports.postgresql93-server sudo ./postgresql93-server.wrapper start

or -

sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql93-server.plist

Creating a database

There are a few extras for the database. These include the PostGIS extension, and all the default tables, functions, and types for Pyaella.

You can prepare a Postgres database to be Pyaella ‘ready’ in a few steps:

The pyaella.server.dbinstall module can create a new database, and adds PostGIS and Pyaella support by default. There are two ways to do this, depending on systems administration requirements and preference.

No previous database?

If there is no database set up yet, you can build a Pyaella db using a command like the following:

python -m pyaella.server.dbinstall -U postgres -O postgres --host localhost --port 5432 --contrib-dir /opt/local/share/postgresql93/contrib/postgis-2.0 --appcfg [APPCONFIG]--db [DBNAME]

This would create a new database on your locally running Postgres instance, that you have administration access to, as the user ‘postgres’ and the owner ‘posgres’. The –contrib-dir argument specifies where the postgis-2 SQL scripts are on your machine, so it can run them, loading a full PostGIS environment.

If PostGIS is not needed or desired, add the –no-postgis argument:

python -m pyaella.server.dbinstall -U postgres -O postgres --no-postgis --db [DBNAME]

If default Pyaella functions, triggers, types, and tables are also not needed or required then also add the –no-pyaella argument:

python -m pyaella.server.dbinstall -U postgres -O postgres --no-postgis --no-pyaella --db [DBNAME]

But what if a database already exists?

You can use the conninfo connection string in the format

postgres://yourname:yourpassword@host/databasename

Export the conninfo as an environment variable DATABASE_URL like:

export DATABASE_URL=postgres://yourname:yourpassword@host/databasename

When you run dbinstall don`t specify the user -U or the owner -O or the database -db arguments. Pyaella will use your conninfo environment variable to connect and configure the database.

Warning

Using the conninfo environment variable does not allow you to drop the database if it already exists.