Skip to content

Commit dda7eaa

Browse files
authored
Refactor dependencies and their tests (#1686)
* 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
1 parent 56908b0 commit dda7eaa

File tree

7 files changed

+51
-43
lines changed

7 files changed

+51
-43
lines changed

.github/workflows/android.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on: [push, pull_request]
33
env:
44
PYTHONFORANDROID_PREREQUISITES_INSTALL_INTERACTIVE: 0
55

6-
name: Android
6+
name: Android Integration
77
jobs:
88
Integration:
99
strategy:
@@ -20,8 +20,7 @@ jobs:
2020
- uses: actions/checkout@v4
2121
- name: Setup environment
2222
run: |
23-
pip install -e .
24-
pip install Cython==0.29.36
23+
pip install .
2524
- run: buildozer --help
2625
- run: buildozer init
2726
- name: SDK, NDK and p4a download
@@ -32,17 +31,14 @@ jobs:
3231
# Install OS specific dependencies
3332
- name: Install Linux dependencies
3433
if: matrix.os == 'ubuntu-latest'
35-
run: sudo apt -y install automake
36-
- name: Install macOS dependencies
37-
if: matrix.os == 'macOS-latest'
38-
run: |
39-
brew install automake
40-
sudo ln -sfn /usr/local/opt/openssl /usr/local/ssl
41-
- name: buildozer android debug
34+
# Required by some p4a recipes, but not
35+
# installed by p4a on Linux.
36+
run: sudo apt -y install automake
37+
- name: Debug Build
4238
run: |
4339
touch main.py
4440
buildozer android debug
45-
- name: buildozer android release (aab)
41+
- name: Release Build (aab)
4642
run: |
4743
touch main.py
4844
export BUILDOZER_ALLOW_ORG_TEST_DOMAIN=1

.github/workflows/ios.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ jobs:
1515
- uses: actions/checkout@v4
1616
- name: Setup environment
1717
run: |
18-
pip install -e .
19-
pip install Cython==0.29.36 cookiecutter pbxproj
18+
pip install .[ios]
2019
- name: Check buildozer installation
2120
run: |
2221
buildozer --help

.github/workflows/pypi-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ jobs:
1010
uses: actions/setup-python@v4
1111
with:
1212
python-version: 3.x
13-
- name: Install dependencies
13+
- name: Install build dependencies
1414
run: |
15-
python -m pip install --upgrade setuptools wheel twine
15+
python -m pip install --upgrade setuptools wheel twine build
1616
- name: Build
1717
run: |
18-
python setup.py sdist bdist_wheel
18+
python -m build
1919
twine check dist/*
2020
- name: Publish package
2121
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ WORKDIR ${WORK_DIR}
7676
COPY --chown=user:user . ${SRC_DIR}
7777

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

8181
ENTRYPOINT ["buildozer"]

docs/source/installation.rst

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,37 @@
22
Installation
33
============
44

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

11-
First, install the buildozer project with::
9+
Buildozer is tested on Python 3.8 and above.
1210

13-
pip3 install --user --upgrade buildozer
1411

1512
Targeting Android
1613
-----------------
1714

1815
Android on Ubuntu 20.04 and 22.04 (64bit)
1916
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017

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

2321
::
2422

2523
sudo apt update
26-
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
27-
pip3 install --user --upgrade Cython==0.29.33 virtualenv # the --user should be removed if you do this in a venv
24+
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
2825

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

31+
Then install the buildozer project with::
32+
33+
pip3 install --user --upgrade buildozer
34+
35+
3436
Android on Windows 10 or 11
3537
~~~~~~~~~~~~~~~~~~~~~~~~~~~
3638

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

4143
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.
4244

45+
Install the buildozer project with::
46+
47+
pip3 install --user --upgrade buildozer
48+
4349
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.
4450

4551
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.
@@ -51,7 +57,7 @@ For debugging, WSL does not have direct access to USB. Copy the .apk file to the
5157
Before Using Buildozer
5258
~~~~~~~~~~~~~~~~~~~~~~
5359

54-
If you wish, clone your code to a new folder, where the build process will run.
60+
If you wish, clone your code to a new folder where the build process will run.
5561

5662
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.
5763

@@ -62,7 +68,7 @@ Android on macOS
6268

6369
::
6470

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

6773

6874
TroubleShooting
@@ -97,16 +103,14 @@ Targeting IOS
97103

98104
Install XCode and command line tools (through the AppStore)
99105

100-
101106
Install homebrew (https://brew.sh)
102107

103108
::
104109

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

107-
108-
Install pip and virtualenv
112+
Install Buildozer and its ios dependencies
109113

110114
::
111115

112-
python3 -m pip install --user --upgrade pip virtualenv kivy-ios
116+
python3 -m pip install --user --upgrade buildozer[ios]

setup.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
sys.exit(1)
2828

2929

30-
3130
def find_version(*file_paths):
3231
# Open in Latin-1 so that we avoid encoding errors.
3332
# Use codecs.open for Python 2 compatibility
@@ -61,20 +60,33 @@ def find_version(*file_paths):
6160
license='MIT',
6261
packages=[
6362
'buildozer', 'buildozer.targets', 'buildozer.libs', 'buildozer.scripts'
64-
],
63+
],
6564
package_data={'buildozer': ['default.spec']},
6665
include_package_data=True,
67-
install_requires=['pexpect', 'virtualenv', 'sh'],
66+
install_requires=[
67+
'pexpect',
68+
# Cython is required by both kivy-ios and python-for-android.
69+
# However, python-for-android does not include it in its dependencies
70+
# and kivy-ios's dependencies are not always checked, so it is included
71+
# here.
72+
# Restricted version because python-for-android's recipes can't handle
73+
# later versions.
74+
'cython<3.0'
75+
],
76+
extras_require={
77+
'test': ['pytest'],
78+
'docs': ['sphinx'],
79+
'ios': ['kivy-ios'],
80+
},
6881
classifiers=[
69-
'Development Status :: 5 - Production/Stable',
82+
'Development Status :: 5 - Production/Stable',
7083
'Intended Audience :: Developers',
7184
'Topic :: Software Development :: Build Tools',
7285
'Programming Language :: Python :: 3',
7386
'Programming Language :: Python :: 3.8',
7487
'Programming Language :: Python :: 3.9',
7588
'Programming Language :: Python :: 3.10',
7689
'Programming Language :: Python :: 3.11',
77-
7890
],
7991
entry_points={
8092
'console_scripts': [

tox.ini

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
[tox]
2-
envlist = pep8,py3
2+
envlist = pep8
33

44
[testenv]
55
deps =
66
pytest
7-
py3: coverage
8-
commands = pytest tests/
9-
10-
[testenv:py3]
11-
# for py3 env we will get code coverage
7+
coverage
128
commands =
9+
pytest tests/
1310
coverage run --branch --source=buildozer -m pytest {posargs:tests/}
1411
coverage report -m
1512

0 commit comments

Comments
 (0)