]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/path.py
Simplify bup startup process
[bup.git] / lib / bup / path.py
index 9b9445eb65ada6260b4f1723944c936113fa1088..7a4f31cde52d9981cbe5ca9392548010d60d0eb0 100644 (file)
@@ -1,18 +1,23 @@
-"""This is a separate module so we can cleanly getcwd() before anyone
-   does chdir().
-"""
 
 from __future__ import absolute_import
-import sys, os
+import os
+
+
+# Eventually, if we physically move the source tree cmd/ to lib/, then
+# we could use realpath here and save some stats...
+
+_libdir = os.path.abspath(os.path.dirname(__file__) + '/..')
+_exedir = os.path.abspath(_libdir + '/cmd')
+_exe = os.path.join(_exedir, 'bup')
 
-startdir = os.getcwd()
 
 def exe():
-    return (os.environ.get('BUP_MAIN_EXE') or
-            os.path.join(startdir, sys.argv[0]))
+    return _exe
 
 def exedir():
-    return os.path.split(exe())[0]
+    return _exedir
+
+cmddir = exedir
 
-def exefile():
-    return os.path.split(exe())[1]
+def libdir():
+    return _libdir