From b2404821b04986a2d16448b1b5690a273c9fcb00 Mon Sep 17 00:00:00 2001 From: Julian-o Date: Sun, 10 Sep 2023 14:05:45 +1000 Subject: [PATCH] Let Setup do the setting up. Use modern Python build tools. Remove unnecessary prep from IOS too Removed py3 special case for tox Add ios version Non-editable installs More Copy edits --- .github/workflows/android.yml | 18 ++++------------- .github/workflows/ios.yml | 3 +-- .github/workflows/pypi-release.yml | 6 +++--- Dockerfile | 2 +- docs/source/installation.rst | 32 +++++++++++++++++------------- setup.py | 22 +++++++++++++++----- tox.ini | 9 +++------ 7 files changed, 47 insertions(+), 45 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index d18a81469..fae19f2ef 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -3,7 +3,7 @@ on: [push, pull_request] env: PYTHONFORANDROID_PREREQUISITES_INSTALL_INTERACTIVE: 0 -name: Android +name: Android Integration jobs: Integration: strategy: @@ -20,8 +20,7 @@ jobs: - uses: actions/checkout@v2 - 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 @@ -29,20 +28,11 @@ jobs: sed -i.bak "s/# android.accept_sdk_license = False/android.accept_sdk_license = True/" buildozer.spec sed -i.bak "s/#p4a.branch = master/p4a.branch = develop/" buildozer.spec buildozer android p4a -- --help - # 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 + - 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 diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 82acf0e28..325cf5133 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -23,8 +23,7 @@ jobs: run: | source .ci/osx_ci.sh arm64_set_path_and_python_version ${{ matrix.python }} - pip install -e . - pip install Cython==0.29.36 cookiecutter pbxproj + pip install .[ios] - name: Check buildozer installation run: | source .ci/osx_ci.sh diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 9c34f8559..657980a4a 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -10,12 +10,12 @@ jobs: uses: actions/setup-python@v2 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') diff --git a/Dockerfile b/Dockerfile index 5132b4faf..075b6ee6b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/docs/source/installation.rst b/docs/source/installation.rst index df03b9be2..de27e0961 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -2,15 +2,12 @@ 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 ----------------- @@ -18,19 +15,24 @@ 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 # 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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -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. @@ -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. @@ -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 @@ -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] diff --git a/setup.py b/setup.py index 3f1489303..928d7a16a 100644 --- a/setup.py +++ b/setup.py @@ -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 @@ -61,12 +60,26 @@ 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', @@ -74,7 +87,6 @@ def find_version(*file_paths): 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', - ], entry_points={ 'console_scripts': [ diff --git a/tox.ini b/tox.ini index 9a24f225e..00446fcf9 100644 --- a/tox.ini +++ b/tox.ini @@ -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