summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2007-11-17 23:50:28 +0100
committerGuillaume Seguin <guillaume@segu.in>2007-11-17 23:50:28 +0100
commitd66d70e900a7dad2fa3ef9c5d5d96f41512dc06b (patch)
tree4d1ae9166245a2fbd53093a02b168073fcbe0840
parent029000d69c8ca03941b7e919e70076a4a6741196 (diff)
downloadugok-d66d70e900a7dad2fa3ef9c5d5d96f41512dc06b.tar.gz
ugok-d66d70e900a7dad2fa3ef9c5d5d96f41512dc06b.tar.bz2
* Add buildsystem
-rw-r--r--MANIFEST.in3
-rwxr-xr-xscripts/ugok (renamed from ugok.py)0
-rw-r--r--setup.py138
3 files changed, 141 insertions, 0 deletions
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..62fec38
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,3 @@
+include README AUTHORS COPYING VERSION
+include ugok.desktop
+include MANIFEST.in
diff --git a/ugok.py b/scripts/ugok
index b756be2..b756be2 100755
--- a/ugok.py
+++ b/scripts/ugok
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..062676c
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,138 @@
+#!/usr/bin/env python
+
+import sys, os, glob
+from stat import *
+from distutils.core import setup
+from distutils.command.install import install as _install
+from distutils.command.install_data import install_data as _install_data
+
+INSTALLED_FILES = "installed_files"
+
+class install (_install):
+
+ def run (self):
+ _install.run (self)
+ outputs = self.get_outputs ()
+ length = 0
+ if self.root:
+ length += len (self.root)
+ if self.prefix:
+ length += len (self.prefix)
+ if length:
+ for counter in xrange (len (outputs)):
+ outputs[counter] = outputs[counter][length:]
+ data = "\n".join (outputs)
+ try:
+ file = open (INSTALLED_FILES, "w")
+ except:
+ self.warn ("Could not write installed files list %s" % \
+ INSTALLED_FILES)
+ return
+ file.write (data)
+ file.close ()
+
+class install_data (_install_data):
+
+ def run (self):
+ def chmod_data_file (file):
+ try:
+ os.chmod (file, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
+ except:
+ self.warn ("Could not chmod data file %s" % file)
+ _install_data.run (self)
+ map (chmod_data_file, self.get_outputs ())
+
+class uninstall (_install):
+
+ def run (self):
+ try:
+ file = open (INSTALLED_FILES, "r")
+ except:
+ self.warn ("Could not read installed files list %s" % \
+ INSTALLED_FILES)
+ return
+ files = file.readlines ()
+ file.close ()
+ prepend = ""
+ if self.root:
+ prepend += self.root
+ if self.prefix:
+ prepend += self.prefix
+ if len (prepend):
+ for counter in xrange (len (files)):
+ files[counter] = prepend + files[counter].rstrip ()
+ for file in files:
+ print "Uninstalling %s" % file
+ try:
+ os.unlink (file)
+ except:
+ self.warn ("Could not remove file %s" % file)
+
+ops = ("install", "build", "sdist", "uninstall", "clean")
+
+if len (sys.argv) < 2 or sys.argv[1] not in ops:
+ print "Please specify operation : %s" % " | ".join (ops)
+ sys.exit (1)
+
+prefix = None
+if len (sys.argv) > 2:
+ i = 0
+ for o in sys.argv:
+ if o.startswith ("--prefix"):
+ if o == "--prefix":
+ if len (sys.argv) >= i:
+ prefix = sys.argv[i + 1]
+ sys.argv.remove (prefix)
+ elif o.startswith ("--prefix=") and len (o[9:]):
+ prefix = o[9:]
+ sys.argv.remove (o)
+ break
+ i += 1
+if not prefix and "PREFIX" in os.environ:
+ prefix = os.environ["PREFIX"]
+if not prefix or not len (prefix):
+ prefix = "/usr"
+
+if sys.argv[1] in ("install", "uninstall") and len (prefix):
+ sys.argv += ["--prefix", prefix]
+
+version_file = open ("VERSION", "r")
+version = version_file.read ().strip ()
+if "=" in version:
+ version = version.split ("=")[1]
+
+data_files = [
+ ("share/applications", ["ugok.desktop"]),
+ ]
+
+podir = os.path.join (os.path.realpath ("."), "po")
+if os.path.isdir (podir):
+ buildcmd = "msgfmt -o build/locale/%s/ugok.mo po/%s.po"
+ mopath = "build/locale/%s/ugok.mo"
+ destpath = "share/locale/%s/LC_MESSAGES"
+ for name in os.listdir (podir):
+ if name[-2:] == "po":
+ name = name[:-3]
+ if sys.argv[1] == "build" \
+ or (sys.argv[1] == "install" and \
+ not os.path.exists (mopath % name)):
+ if not os.path.isdir ("build/locale/" + name):
+ os.makedirs ("build/locale/" + name)
+ os.system (buildcmd % (name, name))
+ data_files.append ((destpath % name, [mopath % name]))
+
+setup (
+ name = "uGOK",
+ version = version,
+ description = "Minimal GTK Onscreen Keyboard",
+ author = "Guillaume Seguin",
+ author_email = "guillaume@segu.in",
+ url = "http://guillaume.segu.in/",
+ license = "GPL",
+ data_files = data_files,
+ packages = ["ugok"],
+ scripts = ["scripts/ugok"],
+ cmdclass = {"uninstall" : uninstall,
+ "install" : install,
+ "install_data" : install_data}
+ )