[gnoduino] Use share/arduino source when available



commit a4736431a92d942aa9ff603b5bcd4f6c550ddc45
Author: Claude Paroz <claude 2xlibre net>
Date:   Tue Sep 6 22:44:01 2011 +0200

    Use share/arduino source when available
    
    Fixes bug #659311

 setup.py    |   42 +++++++++++++++++++-----------------------
 src/misc.py |    1 +
 2 files changed, 20 insertions(+), 23 deletions(-)
---
diff --git a/setup.py b/setup.py
index 7ec94c3..017464a 100644
--- a/setup.py
+++ b/setup.py
@@ -97,16 +97,6 @@ compline = "scripts/gitlog.sh"
 (run, sout) = runProg(compline)
 
 
-data_files = [('share/gnoduino/ui', ['ui/main.ui', 'ui/arduino.xml']),
-		('share/gnoduino/', ['BOARDS', 'ChangeLog', 'NEWS', 'PROGRAMMERS', 'preferences.txt']),
-		('share/gnoduino/pixmaps', glob.glob('pixmaps/*.png')),
-		('share/gnoduino/scripts', ['scripts/gen_boards.py', 'scripts/gen_programmers.py']),
-		('share/man/man1', ['data/gnoduino.1']),
-		('share/applications', ['data/gnoduino.desktop']),
-		('share/pixmaps', ['pixmaps/gnoduino.png']),
-
-]
-
 class install(_install):
 	def run(self):
 		if len(glob.glob('pixmaps/*.png')) == 0:
@@ -115,18 +105,24 @@ class install(_install):
 		_install.run(self)
 		installSchema(self.distribution).run()
 
-"""we ship hardware module"""
-for r,d,f in os.walk("hardware"):
-	if ".git" not in r and f:
-		data_files.append([os.path.join("share", "gnoduino", r), [os.path.join(r,i) for i in f]])
-"""we ship libraries module"""
-for r,d,f in os.walk("libraries"):
-	if ".git" not in r and f:
-		data_files.append([os.path.join("share", "gnoduino", r), [os.path.join(r,i) for i in f]])
-"""we ship reference module"""
-for r,d,f in os.walk("reference"):
-	if ".git" not in r and f:
-		data_files.append([os.path.join("share", "gnoduino", r), [os.path.join(r,i) for i in f]])
+def get_data_files():
+    data_files = [
+        ('share/gnoduino/ui', ['ui/main.ui', 'ui/arduino.xml']),
+        ('share/gnoduino/', ['BOARDS', 'ChangeLog', 'NEWS', 'PROGRAMMERS', 'preferences.txt']),
+        ('share/gnoduino/pixmaps', glob.glob('pixmaps/*.png')),
+        ('share/gnoduino/scripts', ['scripts/gen_boards.py', 'scripts/gen_programmers.py']),
+        ('share/man/man1', ['data/gnoduino.1']),
+        ('share/applications', ['data/gnoduino.desktop']),
+        ('share/pixmaps', ['pixmaps/gnoduino.png']),
+    ]
+    for subdir in ("hardware", "libraries", "reference"):
+        # We ship hardware/libraries/reference modules if not already installed
+        if not os.path.exists(os.path.join(sys.prefix, "share", "arduino", subdir)):
+            for dirpath, dirnames, filenames in os.walk(subdir):
+                if ".git" not in dirpath and filenames:
+                    data_files.append([os.path.join("share", "gnoduino", dirpath),
+                                       [os.path.join(dirpath,i) for i in filenames]])
+    return data_files
 
 cmd_classes = {
 	"pixmaps": Pixmaps,
@@ -150,7 +146,7 @@ setup(name='gnoduino',
 	url='http://gnome.eu.org/evo/index.php/Gnoduino',
 	license='GPL',
 	platforms='linux',
-	data_files = data_files,
+	data_files = get_data_files(),
 	cmdclass=cmd_classes,
 )
 
diff --git a/src/misc.py b/src/misc.py
index fbecf98..dddeca0 100644
--- a/src/misc.py
+++ b/src/misc.py
@@ -40,6 +40,7 @@ def get_path(main_path, default=None):
     possible_paths = [
         os.path.join(os.path.expanduser('~/.arduino'), main_path),
         os.path.join(os.getcwd(), main_path),
+        os.path.join(sys.prefix, "share", "arduino", main_path),
         os.path.join(sys.prefix, "local", "share", "gnoduino", main_path),
         os.path.join(sys.prefix, "share", "gnoduino", main_path),
     ]



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