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.

classification
Title: building for riscv multilib (patch attached)
Type: enhancement Stage: resolved
Components: Build Versions: Python 3.8
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: Andreas K. Hüttel, Arfrever, mgorny
Priority: normal Keywords:

Created on 2019-04-22 18:24 by Andreas K. Hüttel, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg340667 - (view) Author: Andreas K. Hüttel (Andreas K. Hüttel) Date: 2019-04-22 18:24
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.
msg341250 - (view) Author: Michał Górny (mgorny) * Date: 2019-05-02 06:09
This is not really an upstream issue, it is due to Gentoo-specific patching.
msg341317 - (view) Author: Andreas K. Hüttel (Andreas K. Hüttel) Date: 2019-05-02 22:10
Who am I to disagree.
History
Date User Action Args
2022-04-11 14:59:14adminsetgithub: 80880
2019-05-02 22:10:21Andreas K. Hüttelsetstatus: open -> closed
resolution: third party
messages: + msg341317

stage: resolved
2019-05-02 06:09:55mgornysetnosy: + mgorny
messages: + msg341250
2019-04-22 19:49:25Arfreversetnosy: + Arfrever
2019-04-22 18:24:51Andreas K. Hüttelcreate