python / cpython

The Python programming language
https://www.python.org
Other
63.03k stars 30.18k forks source link

Installing Python 3.13.0 on Android proot-chroot (Debian Environment) #125381

Open b9Joker108 opened 3 days ago

b9Joker108 commented 3 days ago

Bug report

Bug description:

Environment:

Steps and Issues Encountered:

  1. Install Dependencies:

    • apt-get install build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev libncurses5-dev libncursesw5-dev xz-utils tk-dev libgdbm-dev libc6-dev libffi-dev
    • All dependencies installed without issues.
  2. Configure and Compile libtinfo:

    • Downloaded source for libtinfo via apt-get source libtinfo-dev.
    • Recompiled with -fPIC flag using:
      cd ncurses-6.4
      make clean
      CFLAGS="-fPIC" ./configure --host=aarch64-linux-gnu --prefix=/usr --with-shared --with-termlib
      make
      make install
    • Successfully compiled libtinfo.
  3. Configure and Compile Python 3.13.0:

    • Downloaded Python 3.13.0 source:
      wget https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz
      tar -xzf Python-3.13.0.tgz
      cd Python-3.13.0
    • In a build directory, ran the configuration script with optimizations:
      ../configure --enable-optimizations --prefix=$HOME/.pyenv/versions/3.13.0
    • Modified Makefile to remove -Werror and fix implicit-function-declaration:
      sed -i 's/-Werror//g' Makefile
      sed -i 's/ =implicit-function-declaration/ /g' Makefile
    • Attempted to compile:
      make
      make install
    • Compilation failed with libtinfo linkage errors.
  4. Revisit libtinfo:

    • Ensured all steps for libtinfo recompile were correctly followed.
    • Reattempted Python build multiple times with no success.
  5. Considered Alternative Approaches:

    • Considered excluding libtinfo with ./configure --without-curses, but concerned about compromised functionality.
    • Explored Docker, but ruled out due to root privileges requirement.
    • Tried to find a pre-compiled binary for aarch64 from s reputable source, without success.

Current Status:

Termux Info

(base) root@localhost:~ # termux-info
Termux Variables:
unsupported
Packages CPU architecture:
arm64
Subscribed repositories:
# sources.list
deb https://mirrors.middlendian.com/termux/termux-main stable main
# sources.list.d/pointless.list
deb https://its-pointless.github.io/files/21 termux extras
# sources.list.d/ivam3-termux-packages.list
deb [trusted=yes arch=all] https://ivam3.github.io/termux-packages stable extras
# sources.list.d/x11.list
deb https://mirrors.middlendian.com/termux/termux-x11 x11 main
# sources.list.d/tur.list
deb https://tur.kcubeterm.com tur-packages tur tur-on-device tur-continuous
# sources.list.d/root.list
deb https://mirrors.middlendian.com/termux/termux-root root stable
# sources.list.d/rendiix.list
deb https://rendiix.github.io android-tools termux
Updatable packages:
Running as root. Cannot check package updates.
termux-tools version:
1.43.6
Android version:
14
Kernel build information:
Linux localhost 6.2.1-PRoot-Distro #1 SMP PREEMPT Thu Jul 11 02:48:07 UTC 2024 aarch64 GNU/Linux
Device manufacturer:
samsung
Device model:
SM-X910
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=
Installed termux plugins:
com.termux.widget versionCode:13
com.termux.x11 versionCode:14
com.termux.api versionCode:51
com.termux.window versionCode:15
com.termux.styling versionCode:1000

Logs:

TBP

CPython versions tested on:

3.13

Operating systems tested on:

Linux

picnixz commented 3 days ago

Not sure if the build is supported or not. Does building 3.12 work on this environment?

b9Joker108 commented 3 days ago

I haven't tried 3.12. In the main part of the chroot I have 3.10.14 and in a Python Virtual Environment I have: 3.11.8.

I was just endeavouring to install 3.13.0 with pyenv to give the new REPL a go!

picnixz commented 3 days ago

cc @mhsmith as the Android expert

picnixz commented 3 days ago

Ah by the way thank you for your thorough report. It's 3 AM here but I see that the issue could be related to curses which I recently worked on.

I am not sure it's possible to make the REPL work without curses but I'll check tomorrow. In the meantime, I can also ask @pablogsal whether he has some insight on this matter.

b9Joker108 commented 3 days ago

I am not in any hurry. I was just curious to try the new REPL. Just progress when convenient. FYI, this is the build.log: https://we.tl/t-TK2vGFmZy0

mhsmith commented 3 days ago

Thanks for the report. The build log link appears to be time-limited, so I've attached the file below. You can attach any file to a GitHub issue by dragging it into the comment box, or clicking the link below the box.

build.log

The most relevant messages are:

gcc -D_DEFAULT_SOURCE  -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall    -fno-semantic-interposition -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes  -fvisibility=hidden -fprofile-generate -I../Include/internal -I../Include/internal/mimalloc -IObjects -IInclude -IPython -I. -I../Include    -fPIC -c ../Modules/_cursesmodule.c -o Modules/_cursesmodule.o
../Modules/_cursesmodule.c: In function ‘_curses_window_addch_impl’:
../Modules/_cursesmodule.c:761:9: warning: implicit declaration of function ‘setcchar’; did you mean ‘getchar’? [-Wimplicit-function-declaration]
  761 |         setcchar(&wcval, wstr, attr, PAIR_NUMBER(attr), NULL);
      |         ^~~~~~~~
      |         getchar
../Modules/_cursesmodule.c:763:19: warning: implicit declaration of function ‘mvwadd_wch’; did you mean ‘mvwaddch’? [-Wimplicit-function-declaration]
  763 |             rtn = mvwadd_wch(self->win,y,x, &wcval);
      |                   ^~~~~~~~~~
      |                   mvwaddch
../Modules/_cursesmodule.c:765:19: warning: implicit declaration of function ‘wadd_wch’; did you mean ‘waddch’? [-Wimplicit-function-declaration]
  765 |             rtn = wadd_wch(self->win, &wcval);
      |                   ^~~~~~~~
      |                   waddch

Modified Makefile to remove -Werror and fix implicit-function-declaration

This is an error for a good reason, so I suggest you revert that. Hiding it will only move the problem to a more confusing place.

In this case it probably means the curses headers aren't on the include path. I haven't tried to build Python for Android with curses before, so I don't know how the configure script discovers the library, but looking at the configure output might give you some hints.

gcc -shared   -fno-semantic-interposition -fprofile-generate  Modules/_cursesmodule.o -lncursesw -ltinfo   -o Modules/_curses.cpython-313-aarch64-linux-gnu.so
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/12/../../../aarch64-linux-gnu/libtinfo.a(lib_tputs.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_nc_outch_sp' which may bind externally can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/aarch64-linux-gnu/12/../../../aarch64-linux-gnu/libtinfo.a(lib_tputs.o): in function `delay_output_sp':
(.text+0x1e4): dangerous relocation: unsupported relocation
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/12/../../../aarch64-linux-gnu/libtinfo.a(lib_tputs.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_nc_putchar_sp' which may bind externally can not be used when making a shared object; recompile with -fPIC

I see you attempted to build libtinfo with -fPIC, but you should check its own build log to make sure the flag was actually used.

Not being familiar with this chroot arrangement, it also isn't obvious to me whether the libtinfo you're linking against is actually the one you built.

b9Joker108 commented 3 days ago

I am a noob. I am still learning. I read what you wrote, but I have had enough screentime today. I will progress it tomorrow.

appleboy159 commented 3 days ago

https://github.com/python/cpython/issues/125381#issue-2583524150

pablogsal commented 3 days ago

I am not sure it's possible to make the REPL work without curses but I'll check tomorrow. In the meantime, I can also ask @pablogsal whether he has some insight on this matter.

Not at the time but we think it's possible but requires us to reimplement a bunch of stuff to prepare the terminal and although possible, we need to weight how maintainable that is taking into account all the platforms we support

appleboy159 commented 3 days ago

😅😅😅😅😅

picnixz commented 3 days ago

@python/organization-owners Could you take care of the spam above? thank you!