From: Dan Mick Date: Wed, 12 Jun 2013 02:46:53 +0000 (-0700) Subject: ceph: make life easier on developers by handling in-tree runs X-Git-Tag: v0.65~95 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e5184ea95031b7bea4264062de083045767d5dc3;p=ceph.git 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 --- diff --git a/src/ceph.in b/src/ceph.in index 01dd908ad98a..18e518669dc3 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