[Lldb-commits] [PATCH] D29405: Install six.py copy into subdirectory lldb

Kamil Rytarowski via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 2 08:57:48 PST 2017


krytarowski updated this revision to Diff 86828.
krytarowski added a comment.

LLDB_USE_SYSTEM_SIX approach


Repository:
  rL LLVM

https://reviews.llvm.org/D29405

Files:
  cmake/modules/LLDBConfig.cmake
  scripts/CMakeLists.txt
  scripts/Python/finishSwigPythonLLDB.py


Index: scripts/Python/finishSwigPythonLLDB.py
===================================================================
--- scripts/Python/finishSwigPythonLLDB.py
+++ scripts/Python/finishSwigPythonLLDB.py
@@ -70,7 +70,6 @@
 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'"
 
 
@@ -527,33 +526,6 @@
     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.
@@ -822,9 +794,6 @@
             vDictArgs, strFrameworkPythonDir, strLldbLibDir)
 
     if bOk:
-        bOk, strMsg = copy_six(vDictArgs, strFrameworkPythonDir)
-
-    if bOk:
         bOk, strMsg = copy_lldbpy_file_to_lldb_pkg_dir(vDictArgs,
                                                        strFrameworkPythonDir,
                                                        strCfgBldDir)
Index: scripts/CMakeLists.txt
===================================================================
--- scripts/CMakeLists.txt
+++ scripts/CMakeLists.txt
@@ -56,5 +56,18 @@
 # Install the LLDB python module
 install(DIRECTORY ${SWIG_PYTHON_DIR} DESTINATION ${SWIG_INSTALL_DIR})
 
+execute_process(
+  COMMAND "${PYTHON_EXECUTABLE}" -c "if True:
+    from distutils import sysconfig as sc
+    print(sc.get_python_lib(prefix='', plat_specific=True))"
+  OUTPUT_VARIABLE PYTHON_SITE
+  OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+if(NOT LLDB_USE_SYSTEM_SIX)
+  install(FILES
+    ${LLDB_SOURCE_DIR}/third_party/Python/module/six/six.py
+    DESTINATION ${PYTHON_SITE}/)
+endif()
+
 # build Python modules
 add_subdirectory(Python/modules)
Index: cmake/modules/LLDBConfig.cmake
===================================================================
--- cmake/modules/LLDBConfig.cmake
+++ cmake/modules/LLDBConfig.cmake
@@ -29,6 +29,9 @@
 set(LLDB_RELOCATABLE_PYTHON 0 CACHE BOOL
   "Causes LLDB to use the PYTHONHOME environment variable to locate Python.")
 
+set(LLDB_USE_SYSTEM_SIX 0 CACHE BOOL
+  "Use six.py shipped with system and do not install a copy of it")
+
 if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
   set(LLDB_EXPORT_ALL_SYMBOLS 0 CACHE BOOL
     "Causes lldb to export all symbols when building liblldb.")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29405.86828.patch
Type: text/x-patch
Size: 3265 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20170202/91fb43b4/attachment-0001.bin>


More information about the lldb-commits mailing list