summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPawel Hajdan, Jr <phajdan.jr@gentoo.org>2010-11-28 17:34:51 +0100
committerPawel Hajdan, Jr <phajdan.jr@gentoo.org>2010-11-28 17:34:51 +0100
commitef48ccbf143a3dd6d6efaeb8a44f62e103588907 (patch)
tree57f296c413490888d27a2987df5ea7053d7da943
parentAdd chromium-depot-tool. (diff)
downloadchromium-tools-ef48ccbf143a3dd6d6efaeb8a44f62e103588907.tar.gz
chromium-tools-ef48ccbf143a3dd6d6efaeb8a44f62e103588907.tar.bz2
chromium-tools-ef48ccbf143a3dd6d6efaeb8a44f62e103588907.zip
Add setup.py.
-rw-r--r--.gitignore1
-rwxr-xr-xchromium-depot-tool1
-rw-r--r--setup.py52
3 files changed, 54 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..551698e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+MANIFEST
diff --git a/chromium-depot-tool b/chromium-depot-tool
index 7974529..e5de0ee 100755
--- a/chromium-depot-tool
+++ b/chromium-depot-tool
@@ -82,6 +82,7 @@ tools = {
}
argv = sys.argv[:]
+argv[0] = os.path.basename(argv[0])
if argv[0] in tools:
tool = argv[0]
argv = argv[1:]
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..0959f8d
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,52 @@
+import os.path
+import subprocess
+
+from distutils.command.install_scripts import install_scripts
+from distutils.command.sdist import sdist
+from distutils.core import setup
+
+def get_version_from_file():
+ return open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'VERSION')).read()
+
+def get_version_from_git():
+ # TODO: replace with check_output when python-2.7 is stable.
+ output = subprocess.Popen(
+ ['git', 'describe'],
+ stdout=subprocess.PIPE).communicate()[0]
+ chunks = output.split('-')
+ return '.'.join(chunks[:2])
+
+def get_version():
+ try:
+ return get_version_from_file()
+ except IOError:
+ return get_version_from_git()
+
+class my_sdist(sdist):
+ def make_release_tree(self, base_dir, files):
+ sdist.make_release_tree(self, base_dir, files)
+ open(os.path.join(base_dir, 'VERSION'), 'w').write(get_version_from_git())
+
+class my_install_scripts(install_scripts):
+ def __symlink(self, src, dst):
+ dest_name, _ = self.copy_file(
+ src,
+ os.path.join(self.install_dir, dst),
+ link='sym')
+ self.outfiles.append(dest_name)
+
+ def run(self):
+ install_scripts.run(self)
+ self.__symlink('chromium-depot-tool', 'drover')
+ self.__symlink('chromium-depot-tool', 'gcl')
+ self.__symlink('chromium-depot-tool', 'gclient')
+
+setup(
+ name="chromium-tools",
+ version=get_version(),
+ scripts=["chromium-depot-tool", "v8-create-tarball"],
+ cmdclass={
+ 'sdist': my_sdist,
+ 'install_scripts': my_install_scripts,
+ }
+)