#!/usr/bin/python
#
# File: setup.py
#
# This file is part of the Gmpm-Project, a graphical MiKTeX Package Manager frontend.
#
# Copyright (C) 2008 Juan Fiol
# This is free software.  You may redistribute copies of it under the terms of
# the GNU General Public License version 2.
# There is NO WARRANTY, to the extent permitted by law.
#
# Written by Juan Fiol <juanfiol@gmail.com>
_ = lambda x : x

import sys, os, os.path, glob
from distutils.core import setup
import distutils
try:
  from gmpm.constants import VERSION, DATA_DIR, ICON_DIR, DOC_DIR, TEMPLATE_DIR, TEMPLATE_FILE, APP_ICON
except ImportError, e:
  print e
  sys.exit(1)

try:
  import gksu2
except ImportError, e:
  print 3*'\n', 72*'*'
  print e
  print _('You will have to run the program as root in order to install/remove packages in a write-protected TeX tree\n')
  print 72*'*',3*'\n'

try:
  import gtkmpm
except ImportError, e:
  print e

### copied from portato setup.py and modified following the python documentation ###


packages = ["gmpm", "gmpm.gui"]
data_files = [("bin", ["gtkmpm.py"]), (ICON_DIR, ['icons/gmpm-icon.png'])
#               , (DOC_DIR, [os.path.join('doc','AUTHORS'), os.path.join('doc','LICENSE'),os.path.join('doc','TRANSLATING')])
              , (DOC_DIR, glob.glob(os.path.join('doc','*')))
              , (TEMPLATE_DIR, glob.glob(os.path.join(TEMPLATE_DIR,'*'))+['gmpm-uninstall.py'])
              , ("/usr/local/share/applications", ['gmpm.desktop'])
              , ("/etc", ['etc/gmpm.cfg'])]

# do the distutils setup
setup(name="gmpm",
      version = VERSION,
      description = "GTK frontend to MiKTeX Package Manager",
      long_description = "A GUI for the MiKTeX Package Manager written in python and using pyGTK and libglade. It is not a replacement for mpm",
      license = "GPLv2",
      url = "www.cabcat2.cnea.gov.ar/staff/fiolj/gmpm",
      author = "Juan Fiol",
      author_email = "juanfiol@gmail.com",
      scripts= ["gtkmpm.py"],
      packages = packages,
      data_files = data_files,
      )

try:
  if os.path.exists('installedfiles.txt'):
    os.system("cp installedfiles.txt /usr/share/gmpm")
except:
  pass
