[Lldb-commits] [PATCH] D114106: [lldb] remove usage of distutils, fix python path on debian/ubuntu

2021-11-17 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG63270710f13a: [lldb] remove usage of distutils, fix python 
path on debian/ubuntu (authored by lawrence_danna).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114106/new/

https://reviews.llvm.org/D114106

Files:
  lldb/CMakeLists.txt
  lldb/bindings/python/get-python-config.py


Index: lldb/bindings/python/get-python-config.py
===
--- lldb/bindings/python/get-python-config.py
+++ lldb/bindings/python/get-python-config.py
@@ -4,7 +4,6 @@
 import sys
 import argparse
 import sysconfig
-import distutils.sysconfig
 
 
 def relpath_nodots(path, base):
@@ -20,7 +19,18 @@
 parser.add_argument("variable_name")
 args = parser.parse_args()
 if args.variable_name == "LLDB_PYTHON_RELATIVE_PATH":
-print(distutils.sysconfig.get_python_lib(True, False, ''))
+# LLDB_PYTHON_RELATIVE_PATH is the relative path from lldb's prefix
+# to where lldb's python libraries will be installed.
+#
+# The way we're going to compute this is to take the relative path from
+# PYTHON'S prefix to where python libraries are supposed to be
+# installed.
+#
+# The result is if LLDB and python are give the same prefix, then
+# lldb's python lib will be put in the correct place for python to 
find it.
+# If not, you'll have to use lldb -P or lldb 
-print-script-interpreter-info
+# to figure out where it is.
+print(relpath_nodots(sysconfig.get_path("platlib"), sys.prefix))
 elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
 tried = list()
 exe = sys.executable
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -32,9 +32,9 @@
 
 if (LLDB_ENABLE_PYTHON)
   set(cachestring_LLDB_PYTHON_RELATIVE_PATH
-"Path where Python modules are installed, relative to install prefix")
+"Path where Python modules are installed, relative to LLDB's install 
prefix")
   set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
-"Path to python interpreter exectuable, relative to install prefix")
+"Path to python interpreter exectuable, relative to python's install 
prefix")
   set(cachestring_LLDB_PYTHON_EXT_SUFFIX
 "Filename extension for native code python modules")
 


Index: lldb/bindings/python/get-python-config.py
===
--- lldb/bindings/python/get-python-config.py
+++ lldb/bindings/python/get-python-config.py
@@ -4,7 +4,6 @@
 import sys
 import argparse
 import sysconfig
-import distutils.sysconfig
 
 
 def relpath_nodots(path, base):
@@ -20,7 +19,18 @@
 parser.add_argument("variable_name")
 args = parser.parse_args()
 if args.variable_name == "LLDB_PYTHON_RELATIVE_PATH":
-print(distutils.sysconfig.get_python_lib(True, False, ''))
+# LLDB_PYTHON_RELATIVE_PATH is the relative path from lldb's prefix
+# to where lldb's python libraries will be installed.
+#
+# The way we're going to compute this is to take the relative path from
+# PYTHON'S prefix to where python libraries are supposed to be
+# installed.
+#
+# The result is if LLDB and python are give the same prefix, then
+# lldb's python lib will be put in the correct place for python to find it.
+# If not, you'll have to use lldb -P or lldb -print-script-interpreter-info
+# to figure out where it is.
+print(relpath_nodots(sysconfig.get_path("platlib"), sys.prefix))
 elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
 tried = list()
 exe = sys.executable
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -32,9 +32,9 @@
 
 if (LLDB_ENABLE_PYTHON)
   set(cachestring_LLDB_PYTHON_RELATIVE_PATH
-"Path where Python modules are installed, relative to install prefix")
+"Path where Python modules are installed, relative to LLDB's install prefix")
   set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
-"Path to python interpreter exectuable, relative to install prefix")
+"Path to python interpreter exectuable, relative to python's install prefix")
   set(cachestring_LLDB_PYTHON_EXT_SUFFIX
 "Filename extension for native code python modules")
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D114106: [lldb] remove usage of distutils, fix python path on debian/ubuntu

2021-11-17 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

I guess the correct path might depend on the precise value of "us". The ubuntu 
packagers might still want to put the files at that location, but they can just 
use the cmake variable to do that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114106/new/

https://reviews.llvm.org/D114106

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D114106: [lldb] remove usage of distutils, fix python path on debian/ubuntu

2021-11-17 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna created this revision.
lawrence_danna added reviewers: labath, jingham, JDevlieghere.
Herald added a subscriber: mgorny.
lawrence_danna requested review of this revision.
Herald added a project: LLDB.

distutils is deprecated and will be removed, so we shouldn't be
using it.

We were using it to compute LLDB_PYTHON_RELATIVE_PATH.

Discussing a similar issue
at python.org , Filipe LaĆ­ns said:

  If you are relying on the value of distutils.sysconfig.get_python_lib()
  as you shown in your system, you probably don't want to. That
  directory (dist-packages) should be for Debian provided packages
  only, so moving to sysconfig.get_path() would be a good thing,
  as it has the correct value for user installed packages on your
  system.

So I propose using a relative path from `sys.prefix` to
`sysconfig.get_path("platlib")` instead.

On Mac and windows, this results in the same paths as we had before,
which are `lib/python3.9/site-packages` and `Lib\site-packages`,
respectively.

On ubuntu however, this will change the path from
`lib/python3/dist-packages` to `lib/python3.9/site-packages`.

This change seems to be correct, as Filipe said above, `dist-packages`
belongs to the distribution, not us.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114106

Files:
  lldb/CMakeLists.txt
  lldb/bindings/python/get-python-config.py


Index: lldb/bindings/python/get-python-config.py
===
--- lldb/bindings/python/get-python-config.py
+++ lldb/bindings/python/get-python-config.py
@@ -4,7 +4,6 @@
 import sys
 import argparse
 import sysconfig
-import distutils.sysconfig
 
 
 def relpath_nodots(path, base):
@@ -20,7 +19,18 @@
 parser.add_argument("variable_name")
 args = parser.parse_args()
 if args.variable_name == "LLDB_PYTHON_RELATIVE_PATH":
-print(distutils.sysconfig.get_python_lib(True, False, ''))
+# LLDB_PYTHON_RELATIVE_PATH is the relative path from lldb's prefix
+# to where lldb's python libraries will be installed.
+#
+# The way we're going to compute this is to take the relative path from
+# PYTHON'S prefix to where python libraries are supposed to be
+# installed.
+#
+# The result is if LLDB and python are give the same prefix, then
+# lldb's python lib will be put in the correct place for python to 
find it.
+# If not, you'll have to use lldb -P or lldb 
-print-script-interpreter-info
+# to figure out where it is.
+print(relpath_nodots(sysconfig.get_path("platlib"), sys.prefix))
 elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
 tried = list()
 exe = sys.executable
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -32,9 +32,9 @@
 
 if (LLDB_ENABLE_PYTHON)
   set(cachestring_LLDB_PYTHON_RELATIVE_PATH
-"Path where Python modules are installed, relative to install prefix")
+"Path where Python modules are installed, relative to LLDB's install 
prefix")
   set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
-"Path to python interpreter exectuable, relative to install prefix")
+"Path to python interpreter exectuable, relative to python's install 
prefix")
   set(cachestring_LLDB_PYTHON_EXT_SUFFIX
 "Filename extension for native code python modules")
 


Index: lldb/bindings/python/get-python-config.py
===
--- lldb/bindings/python/get-python-config.py
+++ lldb/bindings/python/get-python-config.py
@@ -4,7 +4,6 @@
 import sys
 import argparse
 import sysconfig
-import distutils.sysconfig
 
 
 def relpath_nodots(path, base):
@@ -20,7 +19,18 @@
 parser.add_argument("variable_name")
 args = parser.parse_args()
 if args.variable_name == "LLDB_PYTHON_RELATIVE_PATH":
-print(distutils.sysconfig.get_python_lib(True, False, ''))
+# LLDB_PYTHON_RELATIVE_PATH is the relative path from lldb's prefix
+# to where lldb's python libraries will be installed.
+#
+# The way we're going to compute this is to take the relative path from
+# PYTHON'S prefix to where python libraries are supposed to be
+# installed.
+#
+# The result is if LLDB and python are give the same prefix, then
+# lldb's python lib will be put in the correct place for python to find it.
+# If not, you'll have to use lldb -P or lldb -print-script-interpreter-info
+# to figure out where it is.
+print(relpath_nodots(sysconfig.get_path("platlib"), sys.prefix))
 elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
 tried = list()
 exe = sys.executable
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++