From 63a0592dc920a09be7fb2f8068a38440c06f7ac9 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sat, 12 Oct 2019 17:58:16 -0500 Subject: [PATCH 1/1] Drop BUP_RESOURCE_PATH; find it via __file__ Assume that the resource path is always next to the libdir. Signed-off-by: Rob Browning Tested-by: Rob Browning --- cmd/python-cmd.sh | 1 - cmd/web-cmd.py | 3 ++- lib/bup/helpers.py | 7 ------- lib/bup/path.py | 4 ++++ 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/cmd/python-cmd.sh b/cmd/python-cmd.sh index 30a8434..8449bc8 100644 --- a/cmd/python-cmd.sh +++ b/cmd/python-cmd.sh @@ -35,6 +35,5 @@ export LC_CTYPE=ISO-8859-1 bup_libdir="$script_home/../lib" # bup_libdir will be adjusted during install export PYTHONPATH="$bup_libdir${PYTHONPATH:+:$PYTHONPATH}" -export BUP_RESOURCE_PATH="$bup_libdir" # This last line will be replaced with 'exec some/python "$@" diff --git a/cmd/web-cmd.py b/cmd/web-cmd.py index 810af2d..eeb9107 100755 --- a/cmd/web-cmd.py +++ b/cmd/web-cmd.py @@ -11,8 +11,9 @@ import mimetypes, os, posixpath, signal, stat, sys, time, urllib, webbrowser from bup import options, git, vfs from bup.helpers import (chunkyreader, debug1, format_filesize, handle_ctrl_c, - log, resource_path, saved_errors) + log, saved_errors) from bup.metadata import Metadata +from bup.path import resource_path from bup.repo import LocalRepo try: diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py index f6b71cd..b962b73 100644 --- a/lib/bup/helpers.py +++ b/lib/bup/helpers.py @@ -395,13 +395,6 @@ def hostname(): return _hostname -_resource_path = None -def resource_path(subdir=''): - global _resource_path - if not _resource_path: - _resource_path = os.environ.get('BUP_RESOURCE_PATH') or '.' - return os.path.join(_resource_path, subdir) - def format_filesize(size): unit = 1024.0 size = float(size) diff --git a/lib/bup/path.py b/lib/bup/path.py index 7a4f31c..b6167d0 100644 --- a/lib/bup/path.py +++ b/lib/bup/path.py @@ -7,6 +7,7 @@ import os # we could use realpath here and save some stats... _libdir = os.path.abspath(os.path.dirname(__file__) + '/..') +_resdir = _libdir _exedir = os.path.abspath(_libdir + '/cmd') _exe = os.path.join(_exedir, 'bup') @@ -21,3 +22,6 @@ cmddir = exedir def libdir(): return _libdir + +def resource_path(subdir=''): + return os.path.join(_resdir, subdir) -- 2.39.2