Are there any gotchas I should be aware of when running Python scripts from inside rpm install?
Here's the gist of the problem. We created a custom RPM installer for deploying our Django app. As part of the installation process I want to run a Django management command that collects all static files and copies them into a predefined location. Here's what this looks like when run manually from a command line:
$ python2.6 manage.py collectstatic --noinput
/usr/lib/python2.6/site-packages/reversion/__init__.py:31: UserWarning: django-reversion 1.5 is intended for use with django 1.3.0. You are running django 1.3.1, so some features, such as admin integration, may not work. Please see https://github.com/etianen/django-reversion/wiki/Compatible-Django-Versions
"django_version": format_version(django.VERSION[:3]),
Copying '/usr/lib/python2.6/site-packages/django/contrib/admin/media/img/gis/move_vertex_on.png'
Copying '/usr/lib/python2.6/site-packages/django/contrib/admin/media/img/gis/move_vertex_off.png'
Copying '/usr/lib/python2.6/site-packages/django/contrib/admin/media/img/admin/icon_clock.gif'
Copying '/usr/lib/python2.6/site-packages/django/contrib/admin/media/img/admin/arrow-down.gif'
Copying '/usr/lib/python2.6/site-packages/django/contrib/admin/media/img/admin/inline-restore.png'
...
So to run this as part of the RPM install I added the following to the spec file:
%post
# collect static files
pushd .
cd %{installpath}/src/app/
%{__python} manage.py collectstatic --noinput --settings=settings_prod
popd
The problem is that when I run this, I can see the task being kicked off:
sudo rpm -U app-0.2.8.18889M-1.x86_64.rpm -vv
...
+ pushd .
/ /
+ cd /opt/qpsi/app/src/app/
+ /usr/bin/python2.6 manage.py collectstatic --noinput --settings=settings_prod
/usr/lib/python2.6/site-packages/reversion/__init__.py:31: UserWarning: django-reversion 1.5 is intended for use with django 1.3.0. You are running django 1.3.1, so some features, such as admin integration, may not work. Please see https://github.com/etianen/django-reversion/wiki/Compatible-Django-Versions
"django_version": format_version(django.VERSION[:3]),
There is no South database module 'south.db.oracle' for your database. Please either choose a supported database, check for SOUTH_DATABASE_ADAPTER[S] settings, or remove South from INSTALLED_APPS.
+ popd
But there is no expected list of files being copied in the output and the static directory isn't actually being populated.
So the questions are:
- Is there anything special about running python scripts from RPM that I need to be aware of
- I'm using -vv option of the rpm command to get verbose output from the install process, but is there a way to further debug what's going on inside of rpm once the python script gets kicked off.
Thanks D.