summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2007-08-06 23:38:39 +0200
committerGuillaume Seguin <guillaume@segu.in>2007-08-06 23:38:39 +0200
commit333481305df31640a184b58fc6a6d4ee60b60779 (patch)
treea76b45b0406a2e087307db57255bd6cf862142f7
parent2f54bf7ee7208badaad3bb8de0feb646dfa603f3 (diff)
downloadgshaderedit-333481305df31640a184b58fc6a6d4ee60b60779.tar.gz
gshaderedit-333481305df31640a184b58fc6a6d4ee60b60779.tar.bz2
* Update setup.py script
* Add VERSION file
-rw-r--r--VERSION1
-rwxr-xr-x[-rw-r--r--]setup.py131
2 files changed, 118 insertions, 14 deletions
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..2e94ead
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+VERSION=0.1
diff --git a/setup.py b/setup.py
index 19c82a9..f990a6b 100644..100755
--- a/setup.py
+++ b/setup.py
@@ -1,13 +1,109 @@
-#! /usr/bin/env python
+#!/usr/bin/env python
import sys, os, glob
+from stat import *
from distutils.core import setup
-from distutils.sysconfig import PREFIX
+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 ()
+ failures = 0
+ for file in files:
+ print "Uninstalling %s" % file
+ try:
+ os.unlink (file)
+ except:
+ failures += 1
+ self.warn ("Could not remove file %s" % file)
+ if not failures:
+ os.unlink (INSTALLED_FILES)
+
+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)
+ raise SystemExit
+
+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/local"
+
+if sys.argv[1] in ("install", "uninstall") and len (prefix):
+ sys.argv += ["--prefix", prefix]
f = open (os.path.join ("gshaderedit.in"), "rt")
data = f.read ()
f.close ()
-data = data.replace ("@prefix@", PREFIX)
+data = data.replace ("@prefix@", prefix)
f = open (os.path.join ("gshaderedit"), "wt")
f.write (data)
f.close ()
@@ -20,10 +116,6 @@ data_files = [
"images/gshaderedit.svg", "images/chromaticity.png"])
]
-if len (sys.argv) == 1 or sys.argv[1] not in ("install", "build"):
- print "Please specify operation : install | build"
- raise SystemExit
-
podir = os.path.join (os.path.realpath ("."), "po")
if os.path.isdir (podir):
buildcmd = "msgfmt -o build/locale/%s/gshaderedit.mo po/%s.po"
@@ -32,22 +124,33 @@ if os.path.isdir (podir):
for name in os.listdir (podir):
if name[-2:] == "po":
name = name[:-3]
- if not os.path.isdir ("build/locale/" + name):
- os.makedirs ("build/locale/" + name)
- os.system (buildcmd % (name, name))
+ 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]))
+version_file = open ("VERSION", "r")
+version = version_file.read ().strip ()
+if "=" in version:
+ version = version.split ("=")[1]
+
setup (
- name = "gShaderEdit",
- version = "0.1",
+ name = "gshaderedit",
+ version = version,
description = "OpenGL Fragment and Vertex Program editor",
author = "Guillaume Seguin",
author_email = "guillaume@segu.in",
- url = "http://guillaume.segu.in/",
+ url = "http://guillaume@segu.in/",
license = "GPL",
data_files = data_files,
packages = ["gShaderEdit"],
- scripts = ["gshaderedit"]
+ scripts = ["gshaderedit"],
+ cmdclass = {"uninstall" : uninstall,
+ "install" : install,
+ "install_data" : install_data}
)
os.remove ("gshaderedit")