Skip to content

Update python-for-android prerequisites (Dockerfile, prerequisites.py, docs) #2923

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

Merged
merged 5 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 28 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# If platform is not specified, by default the target platform of the build request is used.
# This is not what we want, as Google doesn't provide a linux/arm64 compatible NDK.
# See: https://docs.docker.com/engine/reference/builder/#from
FROM --platform=linux/amd64 ubuntu:20.04
FROM --platform=linux/amd64 ubuntu:22.04

# configure locale
RUN apt -y update -qq > /dev/null \
Expand Down Expand Up @@ -48,43 +48,37 @@ ENV HOME_DIR="/home/${USER}"
ENV WORK_DIR="${HOME_DIR}/app" \
PATH="${HOME_DIR}/.local/bin:${PATH}" \
ANDROID_HOME="${HOME_DIR}/.android" \
JAVA_HOME="/usr/lib/jvm/java-13-openjdk-amd64"
JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"


# install system dependencies
RUN dpkg --add-architecture i386 \
&& ${RETRY} apt -y update -qq > /dev/null \
RUN ${RETRY} apt -y update -qq > /dev/null \
&& ${RETRY} DEBIAN_FRONTEND=noninteractive apt install -qq --yes --no-install-recommends \
autoconf \
automake \
autopoint \
build-essential \
ccache \
cmake \
gettext \
git \
lbzip2 \
libffi-dev \
libgtk2.0-0:i386 \
libidn11:i386 \
libltdl-dev \
libncurses5:i386 \
libssl-dev \
libstdc++6:i386 \
libtool \
openjdk-13-jdk \
patch \
pkg-config \
python3 \
python3-dev \
python3-pip \
python3-venv \
sudo \
unzip \
wget \
zip \
zlib1g-dev \
zlib1g:i386 \
ant \
autoconf \
automake \
ccache \
cmake \
g++ \
gcc \
git \
lbzip2 \
libffi-dev \
libltdl-dev \
libtool \
libssl-dev \
make \
openjdk-17-jdk \
patch \
pkg-config \
python3 \
python3-dev \
python3-pip \
python3-venv \
sudo \
unzip \
wget \
zip \
&& apt -y autoremove \
&& apt -y clean \
&& rm -rf /var/lib/apt/lists/*
Expand Down
71 changes: 34 additions & 37 deletions doc/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,48 +56,45 @@ You can also test the master branch from Github using::

pip install git+https://github.com/kivy/python-for-android.git

Installing Dependencies
Installing Prerequisites
~~~~~~~~~~~~~~~~~~~~~~~

p4a has several dependencies that must be installed:

- ant
- autoconf (for libffi and other recipes)
- automake
- ccache (optional)
- cmake (required for some native code recipes like jpeg's recipe)
- cython (can be installed via pip)
- gcc
- git
- libncurses (including 32 bit)
- libtool (for libffi and recipes)
- libssl-dev (for TLS/SSL support on hostpython3 and recipe)
- openjdk-8
- patch
- python3
- unzip
- virtualenv (can be installed via pip)
- zlib (including 32 bit)
- zip

On recent versions of Ubuntu and its derivatives you may be able to
install most of these with::

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y build-essential ccache git zlib1g-dev python3 python3-dev libncurses5:i386 libstdc++6:i386 zlib1g:i386 openjdk-8-jdk unzip ant ccache autoconf libtool libssl-dev

On Arch Linux you should be able to run the following to
install most of the dependencies (note: this list may not be
complete)::
p4a requires a few dependencies to be installed on your system to work
properly. While we're working on a way to automate pre-requisites checks,
suggestions and installation on all platforms (macOS is already supported),
on Linux distros you'll need to install them manually.

sudo pacman -S core/autoconf core/automake core/gcc core/make core/patch core/pkgconf extra/cmake extra/jdk8-openjdk extra/python-pip extra/unzip extra/zip
On recent versions of Ubuntu and its derivatives you can easily install them via
the following command (re-adapted from the `Dockerfile` we use to perform CI builds)::

On macOS::
sudo apt-get update
sudo apt-get install -y \
ant \
autoconf \
automake \
ccache \
cmake \
g++ \
gcc \
git \
lbzip2 \
libffi-dev \
libltdl-dev \
libtool \
libssl-dev \
make \
openjdk-17-jdk \
patch \
pkg-config \
python3 \
python3-dev \
python3-pip \
python3-venv \
sudo \
unzip \
wget \
zip

brew install autoconf automake libtool openssl pkg-config
brew tap homebrew/cask-versions
brew install --cask homebrew/cask-versions/adoptopenjdk8

Installing Android SDK
~~~~~~~~~~~~~~~~~~~~~~
Expand Down
16 changes: 8 additions & 8 deletions pythonforandroid/prerequisites.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class JDKPrerequisite(Prerequisite):
name = "JDK"
mandatory = dict(linux=False, darwin=True)
installer_is_supported = dict(linux=False, darwin=True)
min_supported_version = 11
supported_version = 17

def darwin_checker(self):
if "JAVA_HOME" in os.environ:
Expand Down Expand Up @@ -197,21 +197,21 @@ def _darwin_jdk_is_supported(self, jdk_path):
res = _stdout_res.strip().decode()

major_version = int(res.split(" ")[-1].split(".")[0])
if major_version >= self.min_supported_version:
if major_version == self.supported_version:
info(f"Found a valid JDK at {jdk_path}")
return True
else:
error(f"JDK {self.min_supported_version} or higher is required")
error(f"JDK version {major_version} is not supported")
return False

def darwin_helper(self):
info(
"python-for-android requires a JDK 11 or higher to be installed on macOS,"
f"python-for-android requires a JDK {self.supported_version} to be installed on macOS,"
"but seems like you don't have one installed."
)
info(
"If you think that a valid JDK is already installed, please verify that "
"you have a JDK 11 or higher installed and that `/usr/libexec/java_home` "
f"you have a JDK {self.supported_version} installed and that `/usr/libexec/java_home` "
"shows the correct path."
)
info(
Expand All @@ -221,12 +221,12 @@ def darwin_helper(self):

def darwin_installer(self):
info(
"Looking for a JDK 11 or higher installation which is not the default one ..."
f"Looking for a JDK {self.supported_version} installation which is not the default one ..."
)
jdk_path = self._darwin_get_libexec_jdk_path(version="11+")
jdk_path = self._darwin_get_libexec_jdk_path(version=str(self.supported_version))

if not self._darwin_jdk_is_supported(jdk_path):
info("We're unlucky, there's no JDK 11 or higher installation available")
info(f"We're unlucky, there's no JDK {self.supported_version} or higher installation available")

base_url = "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.2%2B8/"
if platform.machine() == "arm64":
Expand Down