Skip to content

Commit

Permalink
Refactor dependencies and their tests (#1686)
Browse files Browse the repository at this point in the history
* Refactor dependencies and their tests

Tackles #.
Supersede #.

* setup.py
	* Remove false dependencies: virtualenv or sh
	* Add Cython, on behalf of p4a. Could be removed when p4a is
	  updated.
	* Add sphinx for docs, pytest for tests, and kivy-ios for ios builds.
	* Flake8 fixes
	
* android.yml
	* Stop installing Cython so setup.py can be tested.
	* Stop making installs editable. Unnecessary and deprecated by PEP.
	* Remove false dependencies: automake, and ssl hacks
	* Give job's names at the right level of abstraction.
	

* ios.yml
	* Stop installing Cython so setup.py can be tested.
	* Stop making installs editable. Unnecessary and deprecated by PEP.
	* Remove false dependencies: cookiecutter and pbxproj
	* Specify [ios] so dependencies are correctly installed.
	* Give job's names at the right level of abstraction.

* Dockerfile
	* Make Cython version match setup.py.
	* I don't understand Docker enough to know whether this runs setup.py, so I don't know if cython is required here or not.
	
* tox.ini
	* Simplify by assuming py3
	
* Installation.rst
	* Move the pip install buildozer instruction into individual sections, so we can specify [ios]
	* Stop claiming Buildozer will work on earlier versions. setup.py explicitly rejects them.
	* Stop recommending to upgrade pip. If Buildozer needs a particular minimum version of pip, it should say so in setup.py.
	* Stop recommending to install Cython or virtualenv manually.
	* Minor copy-edits.

* Reinstate automake install

Rolling back to change to allow other changes to be merged while this one is resolved.

* Add automake to Android installation instructions
  • Loading branch information
Julian-O authored Nov 12, 2023
1 parent 56908b0 commit dda7eaa
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 43 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [push, pull_request]
env:
PYTHONFORANDROID_PREREQUISITES_INSTALL_INTERACTIVE: 0

name: Android
name: Android Integration
jobs:
Integration:
strategy:
Expand All @@ -20,8 +20,7 @@ jobs:
- uses: actions/checkout@v4
- name: Setup environment
run: |
pip install -e .
pip install Cython==0.29.36
pip install .
- run: buildozer --help
- run: buildozer init
- name: SDK, NDK and p4a download
Expand All @@ -32,17 +31,14 @@ jobs:
# Install OS specific dependencies
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt -y install automake
- name: Install macOS dependencies
if: matrix.os == 'macOS-latest'
run: |
brew install automake
sudo ln -sfn /usr/local/opt/openssl /usr/local/ssl
- name: buildozer android debug
# Required by some p4a recipes, but not
# installed by p4a on Linux.
run: sudo apt -y install automake
- name: Debug Build
run: |
touch main.py
buildozer android debug
- name: buildozer android release (aab)
- name: Release Build (aab)
run: |
touch main.py
export BUILDOZER_ALLOW_ORG_TEST_DOMAIN=1
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ jobs:
- uses: actions/checkout@v4
- name: Setup environment
run: |
pip install -e .
pip install Cython==0.29.36 cookiecutter pbxproj
pip install .[ios]
- name: Check buildozer installation
run: |
buildozer --help
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install dependencies
- name: Install build dependencies
run: |
python -m pip install --upgrade setuptools wheel twine
python -m pip install --upgrade setuptools wheel twine build
- name: Build
run: |
python setup.py sdist bdist_wheel
python -m build
twine check dist/*
- name: Publish package
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ WORKDIR ${WORK_DIR}
COPY --chown=user:user . ${SRC_DIR}

# installs buildozer and dependencies
RUN pip3 install --user --upgrade Cython==0.29.36 wheel pip virtualenv ${SRC_DIR}
RUN pip3 install --user --upgrade "Cython<3.0" wheel pip ${SRC_DIR}

ENTRYPOINT ["buildozer"]
34 changes: 19 additions & 15 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,37 @@
Installation
============

Buildozer is tested on Python 3.8 and above but may work on
earlier versions, back to Python 3.3.
Depending the platform you want to target, you might need more tools installed.
Buildozer tries to give you hints or tries to install few things for
Depending the platform you want to target, you might need a few dependencies installed.
Buildozer tries to give you hints and tries to install few things for
you, but it doesn't cover every situation.

First, install the buildozer project with::
Buildozer is tested on Python 3.8 and above.

pip3 install --user --upgrade buildozer

Targeting Android
-----------------

Android on Ubuntu 20.04 and 22.04 (64bit)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(expected to work as well in later version, but only regularly tested in the latest LTS)
(Buildozer is expected to work in later versions of Ubuntu, but it is only regularly tested on the latest LTS version
of Ubuntu.)

::

sudo apt update
sudo apt install -y git zip unzip openjdk-17-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-dev
pip3 install --user --upgrade Cython==0.29.33 virtualenv # the --user should be removed if you do this in a venv
sudo apt install -y git zip unzip openjdk-17-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-dev automake

# add the following line at the end of your ~/.bashrc file
export PATH=$PATH:~/.local/bin/
If openjdk-17 is not compatible with other installed programs, for Buildozer the minimum compatible openjdk version is 11.

Then install the buildozer project with::

pip3 install --user --upgrade buildozer


Android on Windows 10 or 11
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand All @@ -40,6 +42,10 @@ These instructions were tested with WSL 1 and Ubuntu 18.04 LTS, and WSL2 with Ub

After installing WSL and Ubuntu on your Windows machine, open Ubuntu, run the commands listed in the previous section, and restart your WSL terminal to enable the path change.

Install the buildozer project with::

pip3 install --user --upgrade buildozer

Copy your Kivy project directory from the Windows partition to the WSL partition, and follow the Quickstart Instructions. **Do not** change to the project directory on the Windows partition and build there, this may give unexpected and obscure fails.

For debugging, WSL does not have direct access to USB. Copy the .apk file to the Windows partition and run ADB (Android Debug Bridge) from a Windows prompt. ADB is part of Android Studio, if you do not have this installed you can install just the platform tools which also contain ADB.
Expand All @@ -51,7 +57,7 @@ For debugging, WSL does not have direct access to USB. Copy the .apk file to the
Before Using Buildozer
~~~~~~~~~~~~~~~~~~~~~~

If you wish, clone your code to a new folder, where the build process will run.
If you wish, clone your code to a new folder where the build process will run.

You don't need to create a virtualenv for your code requirements. But just add these requirements to a configuration file called buildozer.spec as you will see in the following sections.

Expand All @@ -62,7 +68,7 @@ Android on macOS

::

python3 -m pip install --user --upgrade Cython==0.29.33 virtualenv # the --user should be removed if you do this in a venv
python3 -m pip install --user --upgrade buildozer # the --user should be removed if you do this in a venv


TroubleShooting
Expand Down Expand Up @@ -97,16 +103,14 @@ Targeting IOS

Install XCode and command line tools (through the AppStore)


Install homebrew (https://brew.sh)

::

brew install pkg-config sdl2 sdl2_image sdl2_ttf sdl2_mixer gstreamer autoconf automake


Install pip and virtualenv
Install Buildozer and its ios dependencies

::

python3 -m pip install --user --upgrade pip virtualenv kivy-ios
python3 -m pip install --user --upgrade buildozer[ios]
22 changes: 17 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
sys.exit(1)



def find_version(*file_paths):
# Open in Latin-1 so that we avoid encoding errors.
# Use codecs.open for Python 2 compatibility
Expand Down Expand Up @@ -61,20 +60,33 @@ def find_version(*file_paths):
license='MIT',
packages=[
'buildozer', 'buildozer.targets', 'buildozer.libs', 'buildozer.scripts'
],
],
package_data={'buildozer': ['default.spec']},
include_package_data=True,
install_requires=['pexpect', 'virtualenv', 'sh'],
install_requires=[
'pexpect',
# Cython is required by both kivy-ios and python-for-android.
# However, python-for-android does not include it in its dependencies
# and kivy-ios's dependencies are not always checked, so it is included
# here.
# Restricted version because python-for-android's recipes can't handle
# later versions.
'cython<3.0'
],
extras_require={
'test': ['pytest'],
'docs': ['sphinx'],
'ios': ['kivy-ios'],
},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',

],
entry_points={
'console_scripts': [
Expand Down
9 changes: 3 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
[tox]
envlist = pep8,py3
envlist = pep8

[testenv]
deps =
pytest
py3: coverage
commands = pytest tests/

[testenv:py3]
# for py3 env we will get code coverage
coverage
commands =
pytest tests/
coverage run --branch --source=buildozer -m pytest {posargs:tests/}
coverage report -m

Expand Down

0 comments on commit dda7eaa

Please sign in to comment.