Skip to content

Commit

Permalink
Change finishSwigPythonLLDB.py to copy six.py instead of simlink it
Browse files Browse the repository at this point in the history
Summary: If six.py is simlink'd, an installation won't be able to find it unless it has access to the source tree that lldb was built from.

Reviewers: zturner

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D15422

llvm-svn: 255340
  • Loading branch information
Ted Woodward committed Dec 11, 2015
1 parent f016a1b commit ec24223
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions lldb/scripts/Python/finishSwigPythonLLDB.py
Expand Up @@ -70,6 +70,8 @@
strErrMsgMkLinkExecute = "Command mklink failed: %s"
strErrMsgMakeSymlink = "creating symbolic link"
strErrMsgUnexpected = "Unexpected error: %s"
strMsgCopySixPy = "Copying six.py from '%s' to '%s'"
strErrMsgCopySixPyFailed = "Unable to copy '%s' to '%s'"

def is_debug_interpreter():
return hasattr(sys, 'gettotalrefcount')
Expand Down Expand Up @@ -336,14 +338,6 @@ def make_symlink(vDictArgs, vstrFrameworkPythonDir, vstrSrcFile, vstrTargetFile)

return make_symlink_native(vDictArgs, strSrc, strTarget)

def make_symlink_six(vDictArgs, vstrFrameworkPythonDir):
dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_six()")
site_packages_dir = os.path.dirname(vstrFrameworkPythonDir)
six_module_filename = "six.py"
src_file = os.path.join(vDictArgs['--srcRoot'], "third_party", "Python", "module", "six", six_module_filename)
src_file = os.path.normpath(src_file)
target = os.path.join(site_packages_dir, six_module_filename)
return make_symlink_native(vDictArgs, src_file, target)

#++---------------------------------------------------------------------------
# Details: Make the symbolic that the script bridge for Python will need in
Expand Down Expand Up @@ -472,9 +466,6 @@ def create_symlinks(vDictArgs, vstrFrameworkPythonDir):
vstrFrameworkPythonDir,
strLibLldbFileName)

if bOk:
bOk, strErrMsg = make_symlink_six(vDictArgs, vstrFrameworkPythonDir)

# Make symlink for darwin-debug on Darwin
strDarwinDebugFileName = "darwin-debug"
if bOk and eOSType == utilsOsType.EnumOsType.Darwin:
Expand All @@ -491,6 +482,27 @@ def create_symlinks(vDictArgs, vstrFrameworkPythonDir):

return (bOk, strErrMsg)

def copy_six(vDictArgs, vstrFrameworkPythonDir):
dbg = utilsDebug.CDebugFnVerbose("Python script copy_six()")
bDbg = "-d" in vDictArgs
bOk = True
strMsg = ""
site_packages_dir = os.path.dirname(vstrFrameworkPythonDir)
six_module_filename = "six.py"
src_file = os.path.join(vDictArgs['--srcRoot'], "third_party", "Python", "module", "six", six_module_filename)
src_file = os.path.normpath(src_file)
target = os.path.join(site_packages_dir, six_module_filename)

if bDbg:
print((strMsgCopySixPy % (src_file, target)))
try:
shutil.copyfile(src_file, target)
except:
bOk = False
strMsg = strErrMsgCopySixPyFailed % (src_file, target)

return (bOk, strMsg)

#++---------------------------------------------------------------------------
# Details: Look for the directory in which to put the Python files if it
# does not already exist, attempt to make it.
Expand Down Expand Up @@ -707,6 +719,9 @@ def main(vDictArgs):
if bOk:
bOk, strMsg = create_symlinks(vDictArgs, strFrameworkPythonDir)

if bOk:
bOk, strMsg = copy_six(vDictArgs, strFrameworkPythonDir)

if bOk:
bOk, strMsg = copy_lldbpy_file_to_lldb_pkg_dir(vDictArgs,
strFrameworkPythonDir,
Expand Down

0 comments on commit ec24223

Please sign in to comment.