Browse Source

Do not use XDG_DATA_HOME. Tell user to use virtualenv if they are not root

283
ThomasV 10 years ago
parent
commit
b8a5d4146d
  1. 4
      lib/util.py
  2. 11
      setup.py

4
lib/util.py

@ -62,13 +62,15 @@ def data_dir():
else: else:
return appdata_dir() return appdata_dir()
def usr_share_dir():
return os.path.join(sys.prefix, "share")
def appdata_dir(): def appdata_dir():
"""Find the path to the application data directory; add an electrum folder and return path.""" """Find the path to the application data directory; add an electrum folder and return path."""
if platform.system() == "Windows": if platform.system() == "Windows":
return os.path.join(os.environ["APPDATA"], "Electrum") return os.path.join(os.environ["APPDATA"], "Electrum")
elif platform.system() == "Linux": elif platform.system() == "Linux":
return os.path.join(sys.prefix, "share", "electrum") return os.path.join(usr_share_dir(), "electrum")
elif (platform.system() == "Darwin" or elif (platform.system() == "Darwin" or
platform.system() == "DragonFly" or platform.system() == "DragonFly" or
platform.system() == "OpenBSD" or platform.system() == "OpenBSD" or

11
setup.py

@ -10,14 +10,14 @@ import imp
version = imp.load_source('version', 'lib/version.py') version = imp.load_source('version', 'lib/version.py')
util = imp.load_source('version', 'lib/util.py') util = imp.load_source('util', 'lib/util.py')
if sys.version_info[:3] < (2, 6, 0): if sys.version_info[:3] < (2, 6, 0):
sys.exit("Error: Electrum requires Python version >= 2.6.0...") sys.exit("Error: Electrum requires Python version >= 2.6.0...")
usr_share = '/usr/share' usr_share = util.usr_share_dir()
if not os.access(usr_share, os.W_OK): if not os.access(usr_share, os.W_OK):
usr_share = os.getenv("XDG_DATA_HOME", os.path.join(os.getenv("HOME"), ".local", "share")) sys.exit("Error: cannot write to %s.\nIf you do not have root permissions, you may install Electrum a virtualenv.\nAlso, please note that you can run Electrum without installing it on your system."%usr_share)
data_files = [] data_files = []
if (len(sys.argv) > 1 and (sys.argv[1] == "sdist")) or (platform.system() != 'Windows' and platform.system() != 'Darwin'): if (len(sys.argv) > 1 and (sys.argv[1] == "sdist")) or (platform.system() != 'Windows' and platform.system() != 'Darwin'):
@ -32,10 +32,7 @@ if (len(sys.argv) > 1 and (sys.argv[1] == "sdist")) or (platform.system() != 'Wi
if os.path.exists('locale/%s/LC_MESSAGES/electrum.mo' % lang): if os.path.exists('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.append((os.path.join(usr_share, 'locale/%s/LC_MESSAGES' % lang), ['locale/%s/LC_MESSAGES/electrum.mo' % lang]))
appdata_dir = os.path.join(usr_share, "electrum")
appdata_dir = util.appdata_dir()
if not os.access(appdata_dir, os.W_OK):
appdata_dir = os.path.join(usr_share, "electrum")
data_files += [ data_files += [
(appdata_dir, ["data/README"]), (appdata_dir, ["data/README"]),

Loading…
Cancel
Save