Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pyenv: BUILD FAILED (Fedora 34 using python-build 20180424)

I need help to install python via pyenv

$ pyenv -v
pyenv 1.2.27

I try to install version 3.6.8

$ pyenv install 3.6.8

I got error

Downloading Python-3.6.8.tar.xz... -> https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz Installing Python-3.6.8... /home/dn121283mvp1/.pyenv/plugins/python-build/bin/python-build: line 1804: 355307 Segmentation fault (core dumped) "$PYTHON_BIN" -s -m ensurepip ${ensurepip_opts} > /dev/null 2>&1 Installing pip from https://bootstrap.pypa.io/get-pip.py... /home/dn121283mvp1/.pyenv/plugins/python-build/bin/python-build: line 1785: 355338 Segmentation fault (core dumped) "${PYTHON_BIN}" -s "${get_pip}" ${GET_PIP_OPTS} 1>&4 2>&1 error: failed to install pip via get-pip.py

BUILD FAILED (Fedora 34 using python-build 20180424)

Inspect or clean up the working tree at /tmp/python-build.20210506064823.343245 Results logged to /tmp/python-build.20210506064823.343245.log

Last 10 log lines: install|*) ensurepip="" ;; \ esac; \ ./python -E -m ensurepip \ $ensurepip --root=/ ; \ fi Looking in links: /tmp/tmp4a3uh2fu Collecting setuptools Collecting pip Installing collected packages: setuptools, pip Successfully installed pip-18.1 setuptools-40.6.2

I need version 3.6.8 to install

like image 753
Vitalii Avatar asked Jul 16 '26 01:07

Vitalii


1 Answers

You can pass a patch to pyenv to fix this.

I posted a solution here https://github.com/pyenv/pyenv/issues/1889#issuecomment-837697366

You need to patch some Python 3.6 object allocation code to use 16 byte alignment. It appears that this was fixed in Python 3.7.

  • https://bugs.python.org/issue27987
  • https://bugs.python.org/file44413/alignment.patch

Had to tweak the patch to not use a and b parent directory names before feeding it to pyenv.

Tested on Python 3.6.8 because that's what I needed.

$ cat alignment.patch
--- Include/objimpl.h
+++ Include/objimpl.h
@@ -250,7 +250,7 @@
         union _gc_head *gc_prev;
         Py_ssize_t gc_refs;
     } gc;
-    double dummy;  /* force worst-case alignment */
+    long double dummy;  /* force worst-case alignment */
 } PyGC_Head;

 extern PyGC_Head *_PyGC_generation0;
--- Objects/obmalloc.c
+++ Objects/obmalloc.c
@@ -643,8 +643,8 @@
  *
  * You shouldn't change this unless you know what you are doing.
  */
-#define ALIGNMENT               8               /* must be 2^N */
-#define ALIGNMENT_SHIFT         3
+#define ALIGNMENT               16               /* must be 2^N */
+#define ALIGNMENT_SHIFT         4

 /* Return the number of bytes in size class I, as a uint. */
 #define INDEX2SIZE(I) (((uint)(I) + 1) << ALIGNMENT_SHIFT)
$ pyenv install --patch 3.6.8 < alignment.patch
Downloading Python-3.6.8.tar.xz...
-> https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz
Installing Python-3.6.8...
patching file Include/objimpl.h
Hunk #1 succeeded at 255 (offset 5 lines).
patching file Objects/obmalloc.c
Hunk #1 succeeded at 650 (offset 7 lines).
Installed Python-3.6.8 to /home/asdf/.pyenv/versions/3.6.8
like image 186
BriarPatch Avatar answered Jul 18 '26 16:07

BriarPatch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!