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 pythonThat 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
This comment was marked as outdated.
This comment was marked as outdated.
TomJo2000
left a comment
There was a problem hiding this comment.
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.
This comment was marked as outdated.
This comment was marked as outdated.
5d3a7a9 to
cd049e3
Compare
9c780b7 to
e7253ee
Compare
5b68174 to
9266459
Compare
f1ec5dd to
8331f6f
Compare
4303fc3 to
3ad7894
Compare
edec5d4 to
9362481
Compare
9362481 to
e7c4207
Compare
|
I have finished final testing and it is working, so I will merge it in 24 hours if there are no more reviews. I historically wrote a great amount of words discussing this message in this thread: To recap concisely: thorough testing indicates that the reason this message occurs is because, when multiple packages are being installed at once, their and each time Once all the |
13820e7 to
ffe311d
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 `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. > How to add a new Python package after this? Everything is the same, except, now, this block is no longer necessary in `build.sh`. ```bash termux_step_create_debscripts() { cat <<- EOF > ./postinst #!$TERMUX_PREFIX/bin/sh echo "Installing dependencies through pip..." pip3 install ${TERMUX_PKG_PYTHON_TARGET_DEPS//, / } EOF } ``` - Instead, `scripts/build/termux_step_create_python_debscripts.sh` can now detect the presence of `pip` package lists in `$TERMUX_PKG_PYTHON_TARGET_DEPS`, `$TERMUX_SUBPKG_PYTHON_TARGET_DEPS`, and the `METADATA` file of the Python package if it exists, and automatically insert them as a block into the `postinst` script for all relevant packages. - `$TERMUX_PKG_PYTHON_TARGET_DEPS` is used for `pip` dependencies that are both on-device build-time and on-device run-time dependencies, and `$TERMUX_PKG_PYTHON_RUNTIME_DEPS` is used for runtime-only `pip` dependencies. `$TERMUX_PKG_PYTHON_RUNTIME_DEPS` overrides `$TERMUX_PKG_PYTHON_TARGET_DEPS` for runtime dependencies, - i.e. if `TERMUX_PKG_PYTHON_RUNTIME_DEPS` is not specified, but `TERMUX_PKG_PYTHON_TARGET_DEPS` is, then `TERMUX_PKG_PYTHON_TARGET_DEPS` will be used as both on-device build and on-device runtime dependencies, - but if `TERMUX_PKG_PYTHON_RUNTIME_DEPS` is specified, then `TERMUX_PKG_PYTHON_TARGET_DEPS`, if specified, is used only for on-device build-time dependencies. - If `python-pip` is not already in the dependencies of any package that needs it, the build will fail with an error instructing maintainers to add `python-pip` to the dependencies of the package that needs it. Co-authored-by: Maxython <mixython@gmail.com>
ffe311d to
7724a12
Compare
- No longer necessary after #23652
…_BUILD_DEPS` - Planned here, and separated into another PR for easier review and source control #23652 (comment)
…ON_BUILD_DEPS` - Planned here, and separated into another PR for easier review and source control: #23652 (comment) %ci:no-build
…_BUILD_DEPS` - Planned here, and separated into another PR for easier review and source control termux/termux-packages#23652 (comment)
…ON_BUILD_DEPS` - Planned here, and separated into another PR for easier review and source control: termux/termux-packages#23652 (comment) %ci:no-build
- termux/termux-packages#23652 for TUR - Fix builds of all TUR Python packages - Newer version of `maturin` requires adjustments to `ANDROID_API_LEVEL` and `wheel_arch` variables to build successfully - `dlib` had a fatal build error related to `libjpeg`, so unvendored all dependencies at the same time as fixing the `libjpeg` error - Switch `python-scipy` from PyPi `pybind11` to Termux `pybind11` to prevent `/usr/include/python3.12/pyconfig.h:17:12: fatal error: arm-linux-gnueabi/python3.12/pyconfig.h: No such file or directory`
- follow-up to termux/termux-packages#23652 for TUR - `TERMUX_PKG_PYTHON_BUILD_DEPS` -> `TERMUX_PKG_PYTHON_CROSS_BUILD_DEPS` - `TERMUX_PKG_PYTHON_COMMON_DEPS` -> `TERMUX_PKG_PYTHON_COMMON_BUILD_DEPS`
- termux/termux-packages#23652 for TUR - Fix builds of all TUR Python packages - Newer version of `maturin` requires adjustments to `ANDROID_API_LEVEL` and `wheel_arch` variables to build successfully - `dlib` had a fatal build error related to `libjpeg`, so unvendored all dependencies at the same time as fixing the `libjpeg` error - Switch `python-scipy` from PyPi `pybind11` to Termux `pybind11` to prevent `/usr/include/python3.12/pyconfig.h:17:12: fatal error: arm-linux-gnueabi/python3.12/pyconfig.h: No such file or directory`
- follow-up to termux/termux-packages#23652 for TUR - `TERMUX_PKG_PYTHON_BUILD_DEPS` -> `TERMUX_PKG_PYTHON_CROSS_BUILD_DEPS` - `TERMUX_PKG_PYTHON_COMMON_DEPS` -> `TERMUX_PKG_PYTHON_COMMON_BUILD_DEPS`
Fixes [Bug]: Conflicts:
asciidocandtinysparql#25921Fixes [Bug]: mesa & mesa-vulkan-icd-freedreno-dri3 build error #21658
Fixes Auto update failing for python-onnxruntime #26687
Fixes [Bug]:
python-llvmliteconflict withlibllvm#25621What is debpython?
debpython is the commands
py3compileandpy3cleanfrom 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
.pycfiles into packages,py3compileandpy3cleancan be called frompostinstandprermscripts togenerate all
.pycfor the.pyfiles in the package immediatelyafter the package is installed, and remove all
.pycfiles 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 removedas long as no packages were installed usingpipThe
termux_step_create_python_debscripts.shcan configure work on debpython (i.e. itspy3copileandpy3cleancommands) from the glibc packagepython-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 fromTERMUX_PKG_PYTHON_TARGET_DEPS. If the variable is set tofalse, then the customization of installing python modules will be disabled, even if theTERMUX_PKG_PYTHON_TARGET_DEPSvariable 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
sysconfigand setting inTERMUX_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 theTERMUX_PKG_PYTHON_RUNTIME_DEPS(for pkg; will be disabled, i.e. will not be added, if the variable is set tofalse) orTERMUX_SUBPKG_PYTHON_RUNTIME_DEPS(for subpkg) value.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.shcan now detect the presence ofpippackage lists in$TERMUX_PKG_PYTHON_TARGET_DEPS,$TERMUX_SUBPKG_PYTHON_TARGET_DEPS, and theMETADATAfile of the Python package if it exists, and automatically insert them as a block into thepostinstscript for all relevant packages.$TERMUX_PKG_PYTHON_TARGET_DEPSis used forpipdependencies that are both on-device build-time and on-device run-time dependencies, and$TERMUX_PKG_PYTHON_RUNTIME_DEPSis used for runtime-onlypipdependencies.$TERMUX_PKG_PYTHON_RUNTIME_DEPSoverrides$TERMUX_PKG_PYTHON_TARGET_DEPSfor runtime dependencies,TERMUX_PKG_PYTHON_RUNTIME_DEPSis not specified, butTERMUX_PKG_PYTHON_TARGET_DEPSis, thenTERMUX_PKG_PYTHON_TARGET_DEPSwill be used as both on-device build and on-device runtime dependencies,TERMUX_PKG_PYTHON_RUNTIME_DEPSis specified, thenTERMUX_PKG_PYTHON_TARGET_DEPS, if specified, is used only for on-device build-time dependencies.python-pipis not already in the dependencies of any package that needs it, the build will fail with an error instructing maintainers to addpython-pipto the dependencies of the package that needs it.