fixes #245: use alternate datafiles location
authorJaved Khan <javed@agiliq.com>
Sun, 4 Aug 2013 15:37:22 +0000 (20:37 +0530)
committerJaved Khan <javed@agiliq.com>
Sun, 4 Aug 2013 15:37:22 +0000 (20:37 +0530)
setup.py

index 0ea8aa3..aed5698 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -11,18 +11,23 @@ util = imp.load_source('version', 'lib/util.py')
 if sys.version_info[:3] < (2,6,0):
     sys.exit("Error: Electrum requires Python version >= 2.6.0...")
 
+usr_share = '/usr/share'
+if not os.access(usr_share, os.W_OK):
+    usr_share = os.getenv("XDG_DATA_HOME",
+                           os.path.join(os.getenv("HOME"), ".local", "share"))
+
 data_files = []
 if (len(sys.argv) > 1 and (sys.argv[1] == "sdist")) or (platform.system() != 'Windows' and platform.system() != 'Darwin'):
     print "Including all files"
     data_files += [
-        ('/usr/share/applications/',['electrum.desktop']),
-        ('/usr/share/app-install/icons/',['icons/electrum.png'])
+        (os.path.join(usr_share, 'applications/'),['electrum.desktop']),
+        (os.path.join(usr_share, 'app-install', 'icons/'),['icons/electrum.png'])
     ]
     if not os.path.exists('locale'):
         os.mkdir('locale')
     for lang in os.listdir('locale'):
         if os.path.exists('locale/%s/LC_MESSAGES/electrum.mo'%lang):
-            data_files.append(  ('/usr/share/locale/%s/LC_MESSAGES'%lang, ['locale/%s/LC_MESSAGES/electrum.mo'%lang]) )
+            data_files.append(  (os.path.join(usr_share, 'locale/%s/LC_MESSAGES'%lang), ['locale/%s/LC_MESSAGES/electrum.mo'%lang]) )
 
 data_files += [
     (util.appdata_dir(), ["data/README"]),