This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Andreas K. Hüttel
Recipients Andreas K. Hüttel
Date 2019-04-22.18:24:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1555957491.02.0.328369650892.issue36699@roundup.psfhosted.org>
In-reply-to
Content
Hi. I have been trying to install Python on a (well prototype of a) risc-v multilib Gentoo system, where the system library directory is /usr/lib64/lp64d (!).

See as reference for the directories
https://www.sifive.com/blog/all-aboard-part-5-risc-v-multilib

Python as is builds and installs fine but the results are pretty much unuseable. Symptoms are "/usr/lib64/lib64/lp64d/python3.6/site-packages" directory name and distutils installs unable to find Python.h  (it is correctly installed in /usr/include/..., but distutils passes /usr/lib64/include as include path).

I've tracked this down to bad values in sys.base_prefix and sys.exec_prefix:

 >>> sys.base_prefix
 '/usr/lib/python-exec/python3.6/../../../lib64'

Even if I set PYTHONHOME=/usr , I get '/usr/lib64'

The fix, specific for this directory layout, is to have one more directory component stripped in Modules/getpath.c , see patch below. 
With this I have been able to install Python with a normal-looking directory layout, and distutils things install fine.

Posting this here so it gets your attention, and hoping that you're better in coming up with a general solution than I am... probably the number of components stripped should depend on the number of slashes in the library path, e.g., "lib" versus "lib64/lp64d"

diff -ruN Python-3.6.8.orig/Modules/getpath.c Python-3.6.8/Modules/getpath.c
--- Python-3.6.8.orig/Modules/getpath.c	2018-12-23 22:37:14.000000000 +0100
+++ Python-3.6.8/Modules/getpath.c	2019-04-21 01:05:35.127440301 +0200
@@ -796,6 +796,7 @@
     if (pfound > 0) {
         reduce(prefix);
         reduce(prefix);
+        reduce(prefix);
         /* The prefix is the root directory, but reduce() chopped
          * off the "/". */
         if (!prefix[0])
@@ -808,6 +809,7 @@
         reduce(exec_prefix);
         reduce(exec_prefix);
         reduce(exec_prefix);
+        reduce(exec_prefix);
         if (!exec_prefix[0])
                 wcscpy(exec_prefix, separator);
     }


Thanks.
History
Date User Action Args
2019-04-22 18:24:51Andreas K. Hüttelsetrecipients: + Andreas K. Hüttel
2019-04-22 18:24:51Andreas K. Hüttelsetmessageid: <1555957491.02.0.328369650892.issue36699@roundup.psfhosted.org>
2019-04-22 18:24:50Andreas K. Hüttellinkissue36699 messages
2019-04-22 18:24:50Andreas K. Hüttelcreate