Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: elcouz on January 20, 2023, 02:10:03 PM

Title: Lost while trying to compile Python 3.11.1
Post by: elcouz on January 20, 2023, 02:10:03 PM
Hello,

I've been using for months TCL, it is really nice. I am trying to upgrade the Python version from 3.10 to 3.11.1 (current with speed improvements)

I am following a guide for an older version but I am kinda lost. (http://tinycorelinux.net/11.x/x86_64/tcz/src/python3.6/compile_python3.6)

I always get curses missing while compiling even thought it is installed.

(https://i.postimg.cc/6QssSVGk/image.png)


(https://i.postimg.cc/2yt9WmQs/image.png)

(https://i.postimg.cc/dVjmPw7J/image.png)

Not sure what to do with CPPFLAGS line and I am not sure it applies to PiCore ARMV7 instructions.


Any help appreciated!

Thanks!!!
Title: Re: Lost while trying to compile Python 3.11.1
Post by: Juanito on January 20, 2023, 09:24:26 PM
The CPPFLAGS are correct and work with python3.6 and python3.9, so I'm not sure why the build failed for the curses module. Are both ncurses and ncurses-dev loaded?

For piCore you should replace "-mtune=generic" by "-march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp"
Title: Re: Lost while trying to compile Python 3.11.1
Post by: patrikg on January 21, 2023, 01:16:57 AM
Hello

Sorry for hijacking this thread, but something comes into mind.

What i have learned that there two versions of ncurses and ncursesw.
And then i used picore before i have to compile and get the older version of ncurses without "w".
I think the "w" stands for support for unicode wide charset.
Uses more than one byte to represent the glyph.

Title: Re: Lost while trying to compile Python 3.11.1
Post by: Juanito on January 21, 2023, 03:36:40 AM
ncurses is non-unicode only
ncursesw is both non-unicode and unicode

In prior versions of x86 tinycore both extensions existed, which tended to cause confusion and many users needed to load both.

As said, prior versions of python built against ncursesw without problems.

As it says "following modules built successfully, but could not be imported..", I wonder if the problem is not elsewhere - perhaps readline is not built against ncursesw or perhaps setuptools or pip is required?
Title: Re: Lost while trying to compile Python 3.11.1
Post by: elcouz on January 21, 2023, 04:51:34 AM
The CPPFLAGS are correct and work with python3.6 and python3.9, so I'm not sure why the build failed for the curses module. Are both ncurses and ncurses-dev loaded?

For piCore you should replace "-mtune=generic" by "-march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp"
I know it will sound like a newbie but where do you put this flag? On the ./configure line?

Should -march be armv7 (I am on that) instead armv6zk?


Quote
Are both ncurses and ncurses-dev loaded?

(https://i.postimg.cc/WbRRV8Qb/image.png)


Python build does work without ncurses not sure what will be the limitation without that.


Thanks for the replies everyone!
Title: Re: Lost while trying to compile Python 3.11.1
Post by: Juanito on January 21, 2023, 05:21:17 AM
The CPPFLAGS, CC and CXX all go on the ./configure line before ./configure.

The flags given ensure that your build will work on armv6, armv7 and armv7l - you can change them if you wish to build for a specific RPi.
Title: Re: Lost while trying to compile Python 3.11.1
Post by: elcouz on January 21, 2023, 05:23:38 AM
ok perfect ,,, will try right away and report back!

Thanks!
Title: Re: Lost while trying to compile Python 3.11.1
Post by: elcouz on January 21, 2023, 06:33:38 AM
The CPPFLAGS, CC and CXX all go on the ./configure line before ./configure.

The flags given ensure that your build will work on armv6, armv7 and armv7l - you can change them if you wish to build for a specific RPi.

CPPFLAGS="-I/usr/local/include/ncursesw" CC="gcc -flto -fuse-linker-plugin -march=armv7 -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -flto -fuse-linker-plugin -march=armv7 -mtu
ne=arm1176jzf-s -mfpu=vfp
-Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --localstatedir=/var --enable-shared --with-system-expat --with-system-ffi --with-ensurepip=yes --with-tcltk-i
ncludes='-I/usr/local/include' --with-tcltk-libs='-L/usr/local/lib -ltk8.6 -ltcl8.6'
configure: WARNING: unrecognized options: --with-tcltk-includes, --with-tcltk-libs
checking build system type... armv7l-unknown-linux-gnueabihf
checking host system type... armv7l-unknown-linux-gnueabihf
checking for Python interpreter freezing... ./_bootstrap_python
checking for python3.11... no
checking for python3.10... no
checking for python3.9... no
checking for python3.8... python3.8
checking Python for regen version... Python 3.8.7
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "linux"
checking for gcc... gcc -flto -fuse-linker-plugin -march=armv7 -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -flto -fuse-linker-plugin -march=armv7 -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe accepts -g... yes
checking for gcc -flto -fuse-linker-plugin -march=armv7 -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -flto -fuse-linker-plugin -march=armv7 -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -E
checking for grep that handles long lines and -e... /usr/local/bin/grep
checking for a sed that does not truncate output... /usr/local/bin/sed
checking for egrep... /usr/local/bin/grep -E
checking for CC compiler name... gcc
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for --with-cxx-main=<compiler>... no
checking for the platform triplet based on compiler characteristics... arm-linux-gnueabihf
checking for multiarch...
checking for PEP 11 support tier... armv7l-unknown-linux-gnueabihf/gcc has tier 3 (partially supported)
checking for -Wl,--no-as-needed... yes
checking for the Android API level... not Android
checking for --with-emscripten-target...
checking for --enable-wasm-dynamic-linking... missing
checking for --enable-wasm-pthreads... missing
checking for --with-suffix...
checking for case-insensitive build directory... no
checking LIBRARY... libpython$(VERSION)$(ABIFLAGS).a
checking LINKCC... $(PURIFY) $(MAINCC)
checking EXPORTSYMS...
checking for GNU ld... yes
checking for --enable-shared... yes
checking for --with-static-libpython... yes
checking for --enable-profiling... no
checking LDLIBRARY... checking HOSTRUNNER...
libpython$(LDVERSION).so
checking for ar... ar
checking for readelf... readelf
checking for a BSD-compatible install... /usr/bin/install -c
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for --with-pydebug... no
checking for --with-trace-refs... no
checking for --enable-pystats... no
checking for --with-assertions... no
checking for --enable-optimizations... no
checking PROFILE_TASK... -m test --pgo --timeout=$(TESTTIMEOUT)
checking for --with-lto... no
checking for llvm-profdata... no
checking if gcc -flto -fuse-linker-plugin -march=armv7 -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe supports -Og optimization level... yes
checking if we can add -Wextra... yes
checking whether gcc -flto -fuse-linker-plugin -march=armv7 -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-strict-aliasing accepts and needs -fno-strict-aliasing... no
checking if we can disable gcc -flto -fuse-linker-plugin -march=armv7 -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe unused-parameter warning... yes
checking if we can disable gcc -flto -fuse-linker-plugin -march=armv7 -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe missing-field-initializers warning... yes
checking if we can enable gcc -flto -fuse-linker-plugin -march=armv7 -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe sign-compare warning... yes
checking if we can enable gcc -flto -fuse-linker-plugin -march=armv7 -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe unreachable-code warning... yes
checking if we can enable gcc -flto -fuse-linker-plugin -march=armv7 -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe strict-prototypes warning... no
checking if we can make implicit function declaration an error in gcc -flto -fuse-linker-plugin -march=armv7 -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -Werror=implicit-function-declaration... yes
checking if we can use visibility in gcc -flto -fuse-linker-plugin -march=armv7 -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fvisibility=hidden... yes
checking whether pthreads are available without options... no

TRUNCATED

checking for gethostbyname_r... yes
checking gethostbyname_r with 6 args... yes
checking for __fpu_control... yes
checking for --with-libm=STRING... default LIBM="-lm"
checking for --with-libc=STRING... default LIBC=""
checking for x64 gcc inline assembler... no
checking whether float word ordering is bigendian... unknown
configure: error:

Unknown float word ordering. You need to manually preset
ax_cv_c_float_words_bigendian=no (or yes) according to your system.



I'll try with armv6zk arch


EDIT: It is the same for armv6zk unfortunately
 
When I follow this guide it does compile and work but with the curses missing

This specific part with tce-load -i all required tcz:

(https://i.postimg.cc/VknB5djX/image.png)

https://www.scivision.dev/compile-install-python-beta-raspberry-pi/
Title: Re: Lost while trying to compile Python 3.11.1
Post by: Juanito on January 21, 2023, 06:56:54 AM
You could try again adding:
ax_cv_c_float_words_bigendian=no
or
ax_cv_c_float_words_bigendian=yes

..after the end of the ./configure switches.
Title: Re: Lost while trying to compile Python 3.11.1
Post by: elcouz on January 21, 2023, 07:40:18 AM
You could try again adding:
ax_cv_c_float_words_bigendian=no
or
ax_cv_c_float_words_bigendian=yes

..after the end of the ./configure switches.

(https://i.postimg.cc/QMPpd4st/image.png)

I wonder if it is because we specify the architecture manually in the configure flags?

I found this ... but man it is getting quite complex

https://github.com/python/cpython/issues/86524
Title: Re: Lost while trying to compile Python 3.11.1
Post by: elcouz on January 21, 2023, 08:10:14 AM
I opened an issue on GitHub about this.

Is there a way to see who compiled Python3.10.tcz for PiCore ? Would be have his opinions about the build process ,,, maybe there is something different from 3.9 and up.
Title: Re: Lost while trying to compile Python 3.11.1
Post by: Juanito on January 21, 2023, 08:12:56 AM
Don’t put “-“ or “—“ before ax_blah_blah..
Title: Re: Lost while trying to compile Python 3.11.1
Post by: Juanito on January 21, 2023, 08:26:46 AM
You can check the info file to see who compiled the python3.10 extension.
Title: Re: Lost while trying to compile Python 3.11.1
Post by: Rich on January 21, 2023, 08:29:59 AM
Hi elcouz
... Is there a way to see who compiled Python3.10.tcz for PiCore ? ...
Sure:
http://tinycorelinux.net/13.x/armv6/tcz/python3.10.tcz.info

Python3.10 was likely built with the same settings shown in the Python3.8 and
Python3.9 build scripts found here:
http://tinycorelinux.net/13.x/armv6/tcz/src/
Title: Re: Lost while trying to compile Python 3.11.1
Post by: elcouz on January 21, 2023, 08:44:39 AM
Hi elcouz
... Is there a way to see who compiled Python3.10.tcz for PiCore ? ...
Sure:
http://tinycorelinux.net/13.x/armv6/tcz/python3.10.tcz.info

Python3.10 was likely built with the same settings shown in the Python3.8 and
Python3.9 build scripts found here:
http://tinycorelinux.net/13.x/armv6/tcz/src/

I will try to use this build script


Thank you guys,,, the force option ax_cv_c_float_words_bigendian=no seems to work (I read that PIs use little endian)
Title: Re: Lost while trying to compile Python 3.11.1
Post by: Juanito on January 21, 2023, 11:10:45 PM
This seems to cure the ncurses problem:

edit setup.py to read:
curses_includes.append('/usr/local/include/ncursesw')
Title: Re: Lost while trying to compile Python 3.11.1
Post by: elcouz on January 25, 2023, 01:28:06 PM
This seems to cure the ncurses problem:

edit setup.py to read:
curses_includes.append('/usr/local/include/ncursesw')

I forgot to mention this was already done since the beginning.

But anyway I kinda redneck my way through compilation (after many many tries) of Python 3.11.1...

To successfully compile it I needed to ditch the CFLAGS/CXXFLAGS flags.

This is the step I did:

- Extract source files
- edit setup.py to change curses_includes.append path to /usr/local/include/ncursesw
- ./configure --prefix=/usr/local --enable-shared --enable-optimizations <--- slower but worth it
- make -j -l 4
- make altinstall DESTDIR=/tmp/python3.11
- mksquashfs /tmp/python3.11 python3.11.tcz
- cp /tmp/python3.11.tcz /mnt/mmcblkp2/tce/optional

If I added the CFLAGS/CXXFLAGS flags, make will always fail afterward ... I tried many flags settings ... spend two days watching compilation fails :'(

tce-load -i python3.11

all good now ,,, thanks!
Title: Re: Lost while trying to compile Python 3.11.1
Post by: Juanito on January 25, 2023, 10:30:24 PM
I just tested on an RPi3 running piCore-13.1 and this works:
Code: [Select]
tce-load -i compiletc sqlite3-dev tk-dev glib2-dev gdbm-dev libEGL-dev readline-dev liblzma-dev openssl-dev

wget https://www.python.org/ftp/python/3.11.1/Python-3.11.1.tar.xz
tar xf *tar*
cd Python-3.11.1

edit setup.py
curses_includes.append('/usr/local/include/ncursesw')

CPPFLAGS="-I/usr/local/include/ncursesw" CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -mtune=-march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --localstatedir=/var --enable-shared --with-system-expat --with-system-ffi --with-ensurepip=yes

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;
find . -name Makefile -type f -exec sed -i 's/-g  -O3//g' {} \;
find . -name Makefile -type f -exec sed -i 's/flto-partition=none -g/flto-partition=none/g' {} \;

make [12m 38.39s]
sudo make install