#! /usr/bin/env python

### Copyright (C) 2002-2003 Stephen Kennedy <steve9000@users.sf.net>

### This program is free software; you can redistribute it and/or modify
### it under the terms of the GNU General Public License as published by
### the Free Software Foundation; either version 2 of the License, or
### (at your option) any later version.

### This program is distributed in the hope that it will be useful,
### but WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
### GNU General Public License for more details.

### You should have received a copy of the GNU General Public License
### along with this program; if not, write to the Free Software
### Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# fake gettext until translations in place
__builtins__.__dict__["_"] = lambda x : x

pyver = (2,2)
pygtkver = (1,99,15)

def ver2str(ver):
    return ".".join(map(str,ver))

#
# python version
#
import sys
if sys.version_info[:2] < pyver:
    print _("Meld requires python%s or higher.") % ver2str(pyver)
    sys.exit(1)

#
# pygtk 2 
#
try:
    import pygtk
except ImportError, e:
    print e
    print _("Meld requires a recent version of pygtk.")
    print _("pygtk-%s or higher is recommended.") % ver2str(pygtkver)
    sys.exit(1)
else:
    pygtk.require("2.0")

#
# pygtk version
#
import gtk
if gtk.pygtk_version < pygtkver:
    print _("Meld works best with pygtk-%s or higher. (found %s)") % (ver2str(pygtkver), ver2str(gtk.pygtk_version))
    print _("Due to incompatible API changes some functions may not operate as expected.")

#
# Add the library path to the system load path
#
import os
sys.path = [os.curdir, '/usr/lib/meld'] + sys.path

#
# main
#
import meldapp
try:
    minusp = sys.argv.index("--profile")
    del sys.argv[minusp]
    import profile
    profile.run("meldapp.main()")
except ValueError:
    meldapp.main()
