-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
tree-wide: port debpython to termux #23652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
tree-wide: port debpython to termux #23652
Conversation
This folder should only be excluded only when performing on-device build. In some packages, like python, this content in this folder is managed by apt. It is quite annoying to see some warnings like |
Should the content in these folders remain managed by apt in any case? In Debian, I believe these folders are not managed by https://packages.debian.org/sid/amd64/libpython3.12-minimal/filelist In Arch Linux, I believe these folders are managed by https://archlinux.org/packages/core/x86_64/python/ (file list) Fedora also ships them https://packages.fedoraproject.org/pkgs/python3.12/python3-libs/fedora-40.html it seems to me like it is optional whether to include them in the package, because I think Python can automatically generate them, but this problem is very difficult because, I think Arch Linux and Fedora might ship them for performance. At least this does not break Python, I think, because a
I do not think there is any way to get rid of this warning, because on Termux Example: warning always reproducible with current packages pkg install python-pip
pip install setuptools
pkg remove python
That happens without this change. Can you think of any way to:
I do not actually notice the performance difference at the startup of Python, when I try to test for it, but I believe someone else might. |
In Debain, they have a postinst script to compile the modules when new packages are installed, and a prerm script to clean up See |
eef60d2
to
7456b5b
Compare
ok I did it, is this what you meant? |
84e2f31
to
5d3a7a9
Compare
@Maxython now I have:
however, I am not sure whether the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting in the effort.
Looks like I accidentally created a merge conflict for you with one of my earlier PRs, sorry about that.
That's ok, However, the reason why many packages are marked with revision-bumps in this is because, that is marking all packages that a test I did indicates will have changed Because of that, I think probably what I need to do is split this into several PRs one after another that do not have CI disabled. |
5d3a7a9
to
cd049e3
Compare
9c780b7
to
e7253ee
Compare
5b68174
to
9266459
Compare
f1ec5dd
to
8331f6f
Compare
e966bc9
to
d53b6cf
Compare
The idea for solving the problem: if in the list of modules to install during the installation of packages there is a module whose name matches the name of the package, then the |
Ok, I have tested installing the current version on two termux-apt devices with two different CPU architectures, and one clean installed and one not clean installed, and I can confirm there are no more fatal errors anywhere in this PR. However, the one remaining possible problem I see is, I still frequently see these errors: licy183 mentioned these errors first, but unfortunately, I don't know how to fix these. They are non-fatal errors, because after they show, "Successfully installed" prints anyway. Also, they do not necessarily produce runtime errors in the python programs, because for example, after this I tested commands like On the other hand, I am not sure whether these errors indicate that subtle, hard-to-find crashes in some programs might appear. Do you think it is acceptable to allow these errors, or do you know of any way to prevent them? |
I checked and noticed that the dependencies logged as "not installed", do actually appear as installed at the end after all debscripts finish running. for example, This suggests the error might be spurious, or also, it could be a coincidence, and maybe |
As I commented before, if you install some package manually ( |
Thank you for explaining, I am sorry for being dense about this detail. I think I am beginning to get an idea of what should be done. I will think about this and make a solution. |
d53b6cf
to
b7df09e
Compare
After the most recent changes, when I test fully recompiling and reinstalling every single package here at once into a clean Termux installation, the amount of visible instances of
In particular, I noticed by looking closely that I think all of the dependencies are now being resolved as well as possible for every single package, one by one as the
...
@Maxython The amount of changes I have made to do this is quite large, and I am not sure whether you agree with all of the changes. Please let me know if you think everything I have done here is a good idea. however, after you have finished reviewing my new changes, and any follow-up changes have finished, I believe this PR will be ready. |
0cdccc1
to
f313757
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -39,7 +39,7 @@ def parse_build_file_dependencies_with_vars(path, vars): | |||
with open(path, encoding="utf-8") as build_script: | |||
for line in build_script: | |||
if line.startswith(vars): | |||
dependencies_string = line.split('DEPENDS=')[1] | |||
dependencies_string = line.split('DEPS=' if 'DEPS=' in line else 'DEPENDS=')[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Maxython I am a little bit confused about this line, and I don't know if I need to change it to match my other recent changes somehow. If it's easy for you to explain, could you explain a little bit about what this line is supposed to do?
87abddc
to
ebfbea5
Compare
1e8062c
to
4a8e5ae
Compare
- debpython is the commands `py3compile` and `py3clean` from Debian. I am calling them that because a large chunk of their source code is found inside a folder inside Debian's source code named "debpython" - https://salsa.debian.org/cpython-team/python3-defaults/-/tree/5348f704668c0b6c360b6c6fb10153b9c2898af5 - rather than packaging `.pyc` files into packages, `py3compile` and `py3clean` can be called from `postinst` and `prerm` scripts to generate all `.pyc` for the `.py` files in the package immediately after the package is installed, and remove all `.pyc` files immediately before uninstalling the package, respectively - fixes the error `trying to overwrite '/data/data/com.termux/files/usr/lib/python3.12/__pycache__/cProfile.cpython-312.pyc'` when packages were built on-device, but at the same time, also: - prevents the warnings `dpkg: warning: while removing python, directory '/data/data/com.termux/files/usr/lib/python3.12/site-packages' not empty so not removed` as long as no packages were installed using `pip` - The revision-bumps that change `control.tar.xz` (debscripts) of packages only and are not otherwise visible are omitted from this PR, and will come in a second PR afterward. - The `termux_step_create_python_debscripts.sh` can configure work on debpython (i.e. its `py3copile` and `py3clean` commands) from the glibc package `python-glibc`, if some glibc package is being compiled. - New variables have been implemented: - `TERMUX_PYTHON_CROSSENV_BUILDHOME` - location of crossenv's python build libraries. - `TERMUX_PKG_PYTHON_RUNTIME_DEPS` - configures the installation of the python modules via pip3 in the pkg's debscripts. If not configured in the package, it will use the value from `TERMUX_PKG_PYTHON_TARGET_DEPS`. If the variable is set to `false`, then the customization of installing python modules will be disabled, even if the `TERMUX_PKG_PYTHON_TARGET_DEPS` variable is set in the package. - `TERMUX_SUBPKG_PYTHON_RUNTIME_DEPS` - configures the installation of the python modules via pip3 in the subpkg's debscripts. - Implemented reconfiguration of prefixes in python module `sysconfig` and setting in `TERMUX_PYTHON_CROSSENV_BUILDHOME`, so that python modules from crossenv building can specify system paths of termux for correct compilation. - Added automatic addition of `python-glibc{-glibc}` dependency when using the `TERMUX_PKG_PYTHON_RUNTIME_DEPS` (for pkg; will be disabled, i.e. will not be added, if the variable is set to `false`) or `TERMUX_SUBPKG_PYTHON_RUNTIME_DEPS` (for subpkg) value. - setup-termux: - add comment and disabled dependency 'pandoc' to prepare for steps towards fixing on-device build of 'nala' - add 'python-pip' and implementation of installing 'system-wide' (Termux-wide) pip packages outside of venv in order to work towards closer accuracy of setup-termux.sh to setup-ubuntu.sh - add 'itstool' from PyPi system-wide to approximate the installation through 'apt' of 'itstool' system-wide in the Ubuntu cross-builder image Co-authored-by: Maxython <mixython@gmail.com>
- packages/borgbackup - packages/electrum - packages/hash-slinger - packages/lv2 - packages/manim - packages/nala - packages/python-cryptography - packages/python-tldp - packages/python-xlib - packages/rdiff-backup - packages/rdircd - packages/sabnzbd - packages/srt2vobsub - packages/termux-gui-package - packages/termux-gui-pm - packages/ytui-music - x11-packages/orca - x11-packages/pyqt5 - packages/matplotlib - packages/python-onnxruntime - packages/python-torch - packages/python-torchvision - packages/python-yt-dlp - x11-packages/xfce4-panel-profiles - disabled-packages/python-pandas - packages/calcurse - packages/units - root-packages/frida - x11-packages/inkscape Co-authored-by: @robertkirkman
4a8e5ae
to
aa0b286
Compare
What is debpython?
debpython is the commands
py3compile
andpy3clean
from Debian. Iam calling them that because a large chunk of their source code is
found inside a folder inside Debian's source code named "debpython"
rather than packaging
.pyc
files into.deb
files,py3compile
andpy3clean
can be called frompostinst
andprerm
scripts togenerate all
.pyc
for the.py
files in the package immediatelyafter the package is installed, and remove all
.pyc
files immediatelybefore uninstalling the package, respectively
fixes the error
trying to overwrite '/data/data/com.termux/files/usr/lib/python3.12/__pycache__/cProfile.cpython-312.pyc'
when packages were built on-device, but at the same time, also:prevents the warnings
dpkg: warning: while removing python, directory '/data/data/com.termux/files/usr/lib/python3.12/site-packages' not empty so not removed
, as long as no packages were installed usingpip
.Not implemented for
pypy
,pypy3
, orpython2
packages, onlypython3
packages currently.How to add a new Python package after this?
Everything is the same, except, now, this block is no longer necessary in
build.sh
.scripts/build/termux_step_create_python_debscripts.sh
can now detect the presence ofpip
package lists in$TERMUX_PKG_PYTHON_TARGET_DEPS
,$TERMUX_SUBPKG_PYTHON_TARGET_DEPS
, and theMETADATA
file of the Python package if it exists, and automatically insert them as a block into thepostinst
script for all relevant packages.$TERMUX_PKG_PYTHON_TARGET_DEPS
is used forpip
dependencies that are both on-device build-time and on-device run-time dependencies, and$TERMUX_PKG_PYTHON_RUNTIME_DEPS
is used for runtime-onlypip
dependencies.$TERMUX_PKG_PYTHON_RUNTIME_DEPS
overrides$TERMUX_PKG_PYTHON_TARGET_DEPS
for runtime dependencies,TERMUX_PKG_PYTHON_RUNTIME_DEPS
is not specified, butTERMUX_PKG_PYTHON_TARGET_DEPS
is, thenTERMUX_PKG_PYTHON_TARGET_DEPS
will be used as both on-device build and on-device runtime dependencies,TERMUX_PKG_PYTHON_RUNTIME_DEPS
is specified, thenTERMUX_PKG_PYTHON_TARGET_DEPS
, if specified, is used only for on-device build-time dependencies.python-pip
is also automatically inserted into the runtime dependencies of every package that needs it, appropriately.