]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/path.py
get: adjust for python 3 and test there
[bup.git] / lib / bup / path.py
index 820c78b8eb4c73745c010e6088567e9599acd10a..7dd3905a2ecf22196b333362c0d5e20cd22f455a 100644 (file)
@@ -1,16 +1,27 @@
-"""This is a separate module so we can cleanly getcwd() before anyone
-   does chdir().
-"""
-import sys, os
 
-startdir = os.getcwd()
+from __future__ import absolute_import
+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__.encode('iso-8859-1')) + b'/..')
+_resdir = _libdir
+_exedir = os.path.abspath(_libdir + b'/cmd')
+_exe = os.path.join(_exedir, b'bup')
+
 
 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 libdir():
+    return _libdir
 
-def exefile():
-    return os.path.split(exe())[1]
+def resource_path(subdir=b''):
+    return os.path.join(_resdir, subdir)