From e5184ea95031b7bea4264062de083045767d5dc3 Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Tue, 11 Jun 2013 19:46:53 -0700 Subject: [PATCH] ceph: make life easier on developers by handling in-tree runs If contains pybind and .libs: - prepend /pybind to PYTHONPATH - append /.libs to LD_LIBRARY_PATH if not already there and exec self so it takes effect Signed-off-by: Dan Mick Reviewed-by: Sage Weil --- src/ceph.in | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/ceph.in b/src/ceph.in index 01dd908ad98..18e518669dc 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -1,12 +1,41 @@ # # Processed in Makefile to add python #! line and version variable # +# +# vim: ts=4 sw=4 smarttab expandtab + + +import os +import sys + +# Make life easier on developers: +# If in src/, and .libs and pybind exist here, assume we're running +# from a Ceph source dir and tweak PYTHONPATH and LD_LIBRARY_PATH +# to use local files + +MYPATH = os.path.abspath(__file__) +MYDIR = os.path.dirname(MYPATH) +DEVMODEMSG = '*** DEVELOPER MODE: setting PYTHONPATH and LD_LIBRARY_PATH' + +if MYDIR.endswith('src') and \ + os.path.exists(os.path.join(MYDIR, '.libs')) and \ + os.path.exists(os.path.join(MYDIR, 'pybind')): + MYLIBPATH = os.path.join(MYDIR, '.libs') + if 'LD_LIBRARY_PATH' in os.environ: + if MYLIBPATH not in os.environ['LD_LIBRARY_PATH']: + os.environ['LD_LIBRARY_PATH'] += ':' + MYLIBPATH + print >> sys.stderr, DEVMODEMSG + os.execvp('python', ['python'] + sys.argv) + else: + os.environ['LD_LIBRARY_PATH'] = MYLIBPATH + print >> sys.stderr, DEVMODEMSG + os.execvp('python', ['python'] + sys.argv) + sys.path.insert(0, os.path.join(MYDIR, 'pybind')) import argparse import copy import errno import json -import os import rados # for raw_input to do readline cmd editing import readline @@ -15,7 +44,6 @@ import stat import string import struct import subprocess -import sys import types import uuid -- 2.47.3