Workaround to PYTHONPATH and PYTHONHOME being messed up by py2app.

Sun, 21 Jan 2018 01:53:10 +0000

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sun, 21 Jan 2018 01:53:10 +0000
changeset 24
94d58d514d69
parent 23
86b42610d5a8
child 25
efa4c61c6f01

Workaround to PYTHONPATH and PYTHONHOME being messed up by py2app.

instance.py file | annotate | diff | comparison | revisions
setup.py file | annotate | diff | comparison | revisions
--- a/instance.py	Sun Jan 21 01:15:01 2018 +0000
+++ b/instance.py	Sun Jan 21 01:53:10 2018 +0000
@@ -46,6 +46,16 @@
             env=os.environ.copy()
             env['BORG_PASSPHRASE']=passphrase
 
+        # Workaround: if launched is a standalone app created with py2app,
+        # borg will fail unless Python environment is reset.
+        # TODO: Of course, this will fail if the system needs the variables
+        # PYTHONPATH or PYTHONHOME set to certain values.
+        if '_PY2APP_LAUNCHED_' in env and env['_PY2APP_LAUNCHED_']=='1':
+            if env==None:
+                env=os.environ.copy()
+            del env['PYTHONPATH']
+            del env['PYTHONHOME']
+
         self.proc=Popen(cmd, env=env, stdout=PIPE, stderr=PIPE, stdin=PIPE)
 
         # We don't do passphrase input etc.
--- a/setup.py	Sun Jan 21 01:15:01 2018 +0000
+++ b/setup.py	Sun Jan 21 01:53:10 2018 +0000
@@ -3,7 +3,7 @@
 APP = ['borgend.py']
 DATA_FILES = []
 OPTIONS = {
-    'argv_emulation': True,
+    'argv_emulation': False,
     'plist': {
         'LSUIElement': True,
     },

mercurial