-
Notifications
You must be signed in to change notification settings - Fork 187
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
[GUIDE]: How to update Python #293
Comments
thanks for this I tried it and it worked I had some issues during the build on one Ubuntu machine due to permission issues so I added some updated commands in your method just to help others I have also made a fork and uploaded the latest libs if someone wants to download them directly https://github.com/syedusama5556/youtubedl-android-updated/tree/master/library/src/main/jniLibs [REVISED-GUIDE]: How to update PythonHi guys, today I'm creating this issue to show you all the process I followed in order to build the Python package from source for this library.
|
Nice @syedusama5556 ! Thanks for sharing it. |
It would be even better if we could use GitHub action to schedule releases |
That's a pretty good idea. At some time I may create one |
[GUIDE]: How to update Python
Hi guys, today I'm creating this issue to show you all the process I followed in order to build the Python package from source for this library.
We are about to update Python to the latest possible version available in the Termux repository nowadays - (C)Python 3.11
Prerequisites
Steps
1. Clone the termux-packages repository
From here you are about to download all the available Termux packages, which contains the scripts and patches needed to build Python for Termux.
To do this, you have to enter the next commands in the Terminal:
2. Create the Python builder file
Now we are about to get all the needed binaries for creating our final Python
zip
for being used in youtubedl-android. The output of this will be files with the.deb
extension, installable packages for Linux, the ones we are later going to de-package.I have created for you a little bash script for building the binaries for ALL 4 possible architectures:
Copy this whole content into a file named (for example)
build-python.sh
and give to it run permissions by running:3. Build the Python package
Now we are about to build the Python packages by running the next commands (this will start a Docker container and all the processes will be running in there)
Once this two commands finished running, there will be a folder called
output
in the same directory you ran the command; in there you will find 4 different folders, one for each built architecture (or less in case you deleted some from the architectures array in thebuild-python.sh
file).4. Merge packages into the
.zip
fileI have found the following packages (
.deb
) to be enough for youtube-dl to work, but this may vary depending on which yt-dlp functions you will use.python_3.11.9-5_aarch64.deb
libandroid-posix-semaphore_0.1-3_aarch64.deb
libandroid-support_29_aarch64.deb
libffi_3.4.6-1_aarch64.deb
zlib_1.3.1_aarch64.deb
openssl_1:3.3.1_aarch64.deb
ca-certificates_1:2024.07.02_all.deb
Now let's create the final usable Python package by de-packaging every
.deb
file that we want to be used. For this run the next commands:First of all, create in the
output
folder a file calleddeb-unpackage.sh
, open it with some text editor and put the next content into it:This script automates the extraction of
.deb
packages usingdpkg-deb
. It allows users to specify a set of package base names to be extracted, with an optional flag to include "static" versions of these packages (-s
). Additionally, it supports specifying the directory where the .deb files are located by using the flag-d
.Now make it an executable by executing:
chmod +x ./deb-unpackage.sh
You have to run this command once per architecture (I'm not doing an architecture-batch depackager because of unnecessary complexity).
An example of its usage (working on the
output
directory) is:arm64-v8a
This will create inside the
aarch64
folder a folder calleddata
that contains the content of our Python update.To finish we have to navigate to the desired architecture folder by using
cd {arch}
and execute the next command:Now navigate to the
/temp
directory and you will find the built Python packages.5. The Python Executable
In the
jniLibs
folder, you should notice two key files:libpython.zip.so
andlibpython.so
.libpython.zip.so
file is the zipped package you created in the previous steps.libpython.so
file is extracted from thebin
directory within the generateddata
folder (created in Step 4).The code snippet above already handles copying the
libpython.so
file to the/tmp
directory, along with thepython3_11_{arch}.zip
file.Now, follow these final steps:
python3_11_{arch}.zip
file tolibpython.zip.so
.libpython_{arch}.so
tolibpython.so
libpython.zip.so
andlibpython.so
) to the correspondingjniLibs
subfolder. For example, if you are using theaarch64
architecture, move the files to thearm64-v8a
folder.6.
jniLibs
folder structureEnsure that your jniLibs folder contains the following structure for each architecture. This ensures that the application can correctly locate the Python binaries.
In the
jniLibs
folder you should have 4 folders, each one named with the available CPU instructions architecture. Taking for example thearm64-v8a
folder, you must have:libpython.zip.so
- The generated zip file from the termux-packages repositorylibpython.so
- The Python executable that has been copied automatically by the code snippet to the/tmp
directoryThe text was updated successfully, but these errors were encountered: