If python package is installed under get_python_lib(prefix='/usr/local') it cannot be imported by python

Bug #1832215 reported by vital on 2019-06-10
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python3-stdlib-extensions (Ubuntu)
Undecided
Unassigned

Bug Description

When `get_python_lib` function is called with `/usr/local` prefix it returns path which is not included into `sys.path` list. Consequently if python package is installed under this path it cannot be imported by python.

Path which is returned:
$ /usr/bin/python3 -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr/local'))"
/usr/local/lib/python3/dist-packages

`usr/local/path` which is present in `sys.path`
$ /usr/bin/python3 -c "import sys; print('\n'.join(sys.path))" | fgrep '/usr/local'
/usr/local/lib/python3.6/dist-packages

There is the same bug reported to the `python3` package (https://bugs.launchpad.net/ubuntu/+source/python3-defaults/+bug/1814653) I created this report to stick it to the correct package.

1) The release of Ubuntu

$ lsb_release -rd
Description: Ubuntu 18.04.2 LTS
Release: 18.04

2) The version of the package

$ apt-cache policy python3-distutils
python3-distutils:
  Installed: 3.6.7-1~18.04
  Candidate: 3.6.7-1~18.04
  Version table:
 *** 3.6.7-1~18.04 500
        500 http://ru.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        500 http://ru.archive.ubuntu.com/ubuntu bionic-updates/main i386 Packages
        100 /var/lib/dpkg/status
     3.6.5-3 500
        500 http://ru.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
        500 http://ru.archive.ubuntu.com/ubuntu bionic/main i386 Packages

3) What you expected to happen

Path returned by `get_python_lib(prefix='/usr/local')` call is present in `sys.path` list.

4) What happened instead

`get_python_lib(prefix='/usr/local')` returns /usr/local/lib/python3/dist-packages which is absent in `sys.path`

vital (vsbogd) wrote :

The root cause is the Debian patch: https://salsa.debian.org/cpython-team/python3-stdlib/blob/master/debian/patches/3.6/distutils-install-layout.diff

The patch changes behavior of the `get_python_lib` for two paths '/usr' and '/usr/local', see: https://salsa.debian.org/cpython-team/python3-stdlib/blob/master/debian/patches/3.7/distutils-install-layout.diff
Lines 144 and 152-157.

I would suggest remove '/usr/local' from the line 144 to fix.

vital (vsbogd) wrote :

Attaching patch for an issue

The attachment "1832215.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers