Author xdegaye
Recipients xdegaye
Date 2017-08-03.17:40:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1501782040.16.0.9530512469.issue31114@psf.upfronthosting.co.za>
In-reply-to
Content
The error messages:
    running install_lib
    creating /lib/python3.7
    error: could not create '/lib/python3.7': Permission denied
    make[1]: *** [Makefile:1449: sharedinstall] Error 1

The command that triggers this failure:
    _PYTHON_PROJECT_BASE=/tmp/android-makesetup/build/python3.7-android-21-armv7 _PYTHON_HOST_PLATFORM=linux-arm PYTHONPATH=/tmp/android-makesetup/build/python3.7-android-21-armv7/build/lib.linux-arm-3.7:/src/python/master/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_m_linux_ python /src/python/master/setup.py install \
      --prefix=/ \
      --install-scripts=//bin \
      --install-platlib=//lib/python3.7/lib-dynload \
      --root=/tmp/android-makesetup/build/python3.7-install-android-21-armv7/

Note how some paths in the setup.py options start with two slashes.

The problem is that change_root() in Lib/distutils/util.py cannot concatenate 'root' with 'pathname' as 'pathname' starts with two slashes and therefore cannot be made relative by just removing one slash.  The behavior of change_root() is correct (although it could be made more robust by calling os.path.normpath() first before removing the first slash) because according to POSIX a pathname starting with two slashes is implementation defined (but not when starting with three or more slashes).  And normpath respects this rule:
    >>> from os.path import normpath
    >>> normpath('//tmp')
    '//tmp'
    >>> normpath('///tmp')
    '/tmp'
However for most posix systems (possibly except Cygwin ?), a path starting with two slashes is the same path as the path starting with one slash.

The problem lies with the Makefile. A workaround for the user is to set the --exec-prefix option to '/./' instead of '/' when running configure and this fixes the problem, the installation is successfull. So a fix could be to swap '/' for '/./' in configure itself.
Maybe there is a better solution.

References:
issue 1676135:
    The changes made by this issue have excluded the case of '/' as there was a concern at that time that the sys.prefix value would be wrong.  I have checked that sys.prefix is correct when '/' is changed to '/./' (on configure command line). This is because the determination of sys.prefix made by Lib/site.py is quite different now from what it was 10 years ago.

issue 9674:
    This is exactly the same issue as this one.  I have preferred to open a new issue here because the discussion on issue 9674 is focused on making changes to distutils while the problem is actually in the posixly incorrect use of paths starting with double slashes in the Makefile.
History
Date User Action Args
2017-08-03 17:40:40xdegayesetrecipients: + xdegaye
2017-08-03 17:40:40xdegayesetmessageid: <1501782040.16.0.9530512469.issue31114@psf.upfronthosting.co.za>
2017-08-03 17:40:40xdegayelinkissue31114 messages
2017-08-03 17:40:39xdegayecreate