[turbine] Move to a python distutils layout



commit 061deabb69327069dcc56b1bb3bb840a77f61fc9
Author: Thomas Wood <thomas wood intel com>
Date:   Mon Jun 1 14:55:39 2009 +0100

    Move to a python distutils layout
    
    Based on patches from Christian Hergert
---
 AUTHORS                                   |    4 ++++
 setup.py                                  |   18 ++++++++++++++++++
 gobject-gen.py => src/turbine/__init__.py |   27 +++++++++++++++------------
 ui.xml => src/turbine/turbine.xml         |    0
 turbine                                   |   26 ++++++++++++++++++++++++++
 5 files changed, 63 insertions(+), 12 deletions(-)

diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..86d1200
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,4 @@
+Ross Burton <ross burtonini com>
+Dafydd Harries <daf rhydd org>
+Thomas Wood <thos gnome org>
+Christian Hergert <chris dronelabs com>
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..d0e2136
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+
+"""
+Installation module for Turbine.
+"""
+
+from distutils.core import setup
+
+setup(name='Turbine',
+      version='0.1',
+      description='GObject Code Generator',
+      author=file('AUTHORS').read(),
+      url='http://git.gnome.org/cgit/turbine/',
+      packages=['turbine'],
+      package_dir={'turbine': 'src/turbine'},
+      package_data={'turbine': ['*.xml']},
+      scripts=['turbine'],
+)
diff --git a/gobject-gen.py b/src/turbine/__init__.py
similarity index 93%
rename from gobject-gen.py
rename to src/turbine/__init__.py
index e9de5cc..a534989 100755
--- a/gobject-gen.py
+++ b/src/turbine/__init__.py
@@ -28,6 +28,7 @@
 import os
 import gtk
 import re
+import sys
 
 PACKAGE_NAME    = "GObject Generator"
 PACKAGE_VERSION = "0.1"
@@ -349,21 +350,23 @@ def about_button_clicked_cb (button, ui):
     about.destroy ()
 
 
-ui = gtk.Builder()
-ui.add_from_file ("ui.xml")
+def main(argv = sys.argv, stdout=sys.stdout, stderr=sys.stderr):
+    ui = gtk.Builder()
+    ui_file = os.path.join(os.path.dirname(__file__), 'turbine.xml');
+    ui.add_from_file (ui_file)
 
-window = ui.get_object ('main-window')
-window.show_all()
-window.connect ('delete-event', gtk.main_quit);
+    window = ui.get_object ('main-window')
+    window.show_all()
+    window.connect ('delete-event', gtk.main_quit);
 
-button = ui.get_object ('save-button')
-button.connect ('clicked', handle_post, ui)
+    button = ui.get_object ('save-button')
+    button.connect ('clicked', handle_post, ui)
 
-button = ui.get_object ('about-button')
-button.connect ('clicked', about_button_clicked_cb, ui)
+    button = ui.get_object ('about-button')
+    button.connect ('clicked', about_button_clicked_cb, ui)
 
-ui.get_object ('class_camel').connect ('changed', guess_class_params, ui)
-ui.get_object ('parent_camel').connect ('changed', guess_parent_params, ui)
+    ui.get_object ('class_camel').connect ('changed', guess_class_params, ui)
+    ui.get_object ('parent_camel').connect ('changed', guess_parent_params, ui)
 
-gtk.main()
+    gtk.main()
 
diff --git a/ui.xml b/src/turbine/turbine.xml
similarity index 100%
rename from ui.xml
rename to src/turbine/turbine.xml
diff --git a/turbine b/turbine
new file mode 100755
index 0000000..4a1b4bf
--- /dev/null
+++ b/turbine
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+
+"""Turbine is a GObject code generator."""
+
+import sys
+import os
+
+if __name__ == '__main__':
+    if os.path.isdir('src'):
+        sys.path.insert(0, 'src')
+    from turbine import main
+    sys.exit(main())



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]