This is an archive of the discontinued LLVM Phabricator instance.

[lldb] remove usage of distutils, fix python path on debian/ubuntu
ClosedPublic

Authored by lawrence_danna on Nov 17 2021, 10:28 AM.

Details

Summary

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.

Diff Detail

Event Timeline

lawrence_danna requested review of this revision.Nov 17 2021, 10:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 17 2021, 10:28 AM
labath accepted this revision.Nov 17 2021, 10:38 AM

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.

This revision is now accepted and ready to land.Nov 17 2021, 10:38 AM