Skip to content
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

Add support for Python 3.13 #49

Merged
merged 20 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
39e0167
Remove references to deprecated modules.
freakboy3742 Nov 20, 2023
f72dabb
Make binary modules conditional on Python version.
freakboy3742 Nov 20, 2023
0d7fe21
Add 3.13 to the test matrix.
freakboy3742 Nov 21, 2023
2180763
Use linux to run Android tests.
freakboy3742 Nov 21, 2023
611925a
Add xfail strategy for third party binaries.
freakboy3742 Nov 21, 2023
a001520
Remove lru-dict wheels; 1.3.0 has been released, providing universal …
freakboy3742 Nov 21, 2023
69856df
Merge branch 'main' into py3.13-support
freakboy3742 Jul 26, 2024
92cf810
Update pyproject to new briefcase format, and drop Py3.8 support.
freakboy3742 Jul 29, 2024
5966053
Don't validate dead (or soon to be dead) batteries.
freakboy3742 Jul 30, 2024
cf2a6fc
Add a timeout for running the test suite.
freakboy3742 Jul 30, 2024
e8eee7c
Temporarily disable binary package tests.
freakboy3742 Aug 6, 2024
abace5e
Add missing icons.
freakboy3742 Aug 6, 2024
194585d
Clarify exclusions in CI and binary packaging.
freakboy3742 Aug 13, 2024
51a11be
Add CI exclusions for Linux/Windows 3.13 testing.
freakboy3742 Aug 13, 2024
ec0215e
Restore Android 3.11/3.12 exclusion.
freakboy3742 Aug 16, 2024
f88d063
Restore iOS binary package tests.
freakboy3742 Sep 1, 2024
fe24cda
Merge branch 'main' into py3.13-support
freakboy3742 Sep 2, 2024
50e83b7
Add a Python 3.13 macOS wheel for lru-dict.
freakboy3742 Sep 5, 2024
e747bc9
Merge branch 'main' into py3.13-support
freakboy3742 Sep 5, 2024
b7b2247
Only use --find-links for macOS.
freakboy3742 Sep 5, 2024
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
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- "windows-app"
- "iOS"
- "android"
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13-dev" ]
include:
- runs-on: ubuntu-latest
- pre-command:
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
briefcase-run-args: ' -d "iPhone SE (3rd generation)"'

- backend: android
runs-on: "ubuntu-latest"
runs-on: ubuntu-latest
briefcase-target: "android"
briefcase-run-args: >
--device '{"avd":"beePhone"}'
Expand All @@ -106,12 +106,11 @@ jobs:
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
exclude:
# Binary packages aren't available for 3.11+ on Android yet
- backend: "android"
python-version: "3.11"

- backend: "android"
# Binary packages aren't available for 3.12+ on Android yet
- backend: android
python-version: "3.12"
- backend: android
python-version: "3.13-dev"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do now have 3.12 Android wheels for Pillow and NumPy, so I guess that doesn't need to be excluded.

On 3.13 we don't have wheels for iOS either, so is the plan to exclude iOS as well, or to hold off merging this PR until you've built them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on the Android 3.12 exclusion; that exists because I originally wrote this PR late last year before 3.12 support landed in Chaquopy.

As for other platforms - we need to exclude binaries on all iOS versions because of the change in binary tag from the 3.13 backport; and we need to exclude numpy and pandas from all platforms on 3.13 specifically because there aren't 3.13 wheels yet. We can drop the "!= iOS" exclusion once I've updated mobile-forge et al and have published new wheels.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we're still missing binary packages on Android for Cryptography on 3.11 and 3.12, though.

Copy link
Member

@mhsmith mhsmith Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


steps:
- name: Checkout
Expand All @@ -132,6 +131,7 @@ jobs:
uses: beeware/.github/.github/actions/install-briefcase@main

- name: Test App
timeout-minutes: 15
run: briefcase run ${{ matrix.briefcase-target }} --test ${{ matrix.briefcase-run-args }}

- name: Package
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added icons/testbed-1280.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added icons/testbed-1920.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added icons/testbed-640.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added icons/testbed.icns
Binary file not shown.
19 changes: 10 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project_name = "Testbed"
bundle = "org.beeware"
version = "0.0.1"
url = "https://beeware.org"
license = "BSD license"
license.file = "LICENSE"
author = 'Russell Keith-Magee'
author_email = "[email protected]"

Expand All @@ -14,16 +14,16 @@ long_description = """A test of common use cases and known problems with bundled

Validates 3rd party module loading, as well as basic app packaging.
"""
icon = "src/testbed/resources/testbed"
icon = "icons/testbed"
sources = ["src/testbed"]
test_sources = ["tests"]

requires = [
"cryptography",
"lru_dict",
"pillow",
"numpy",
"pandas",
# "cryptography; python_version < '3.13'",
# "lru_dict; python_version < '3.13'",
# "pillow; python_version < '3.13'",
# "numpy; python_version < '3.13'",
# "pandas; python_version < '3.13'",
]
test_requires = [
"pytest",
Expand All @@ -36,10 +36,11 @@ requires = [
"rubicon-objc",
"std-nslog",
]
# support_package = "../Python-Apple-support/dist/Python-3.8-macOS-support.custom.tar.gz"
# support_package = "../Python-Apple-support/dist/Python-3.13-macOS-support.custom.tar.gz"

[tool.briefcase.app.testbed.macOS.app]
# template = "../../templates/briefcase-macOS-app-template"
# stub_binary = "../../templates/briefcase-macOS-Xcode-template/stub/build/gui-stub/macos/xcode/build/Release/GUI Stub.app/Contents/MacOS/GUI Stub"

[tool.briefcase.app.testbed.macOS.Xcode]
# template = "../../templates/briefcase-macOS-Xcode-template"
Expand Down Expand Up @@ -92,7 +93,7 @@ requires = [
"rubicon-objc",
"std-nslog",
]
# support_package = "../Python-Apple-support/dist/Python-3.8-iOS-support.custom.tar.gz"
# support_package = "../Python-Apple-support/dist/Python-3.10-iOS-support.custom.tar.gz"
# template = "../../templates/briefcase-iOS-Xcode-template"

[tool.briefcase.app.testbed.android]
Expand Down
4 changes: 1 addition & 3 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_bootstrap_modules():


def test_stdlib_modules():
"All the stdlib modules exist"
"All the stdlib binary modules exist"
missing = []
all_modules = [
"_asyncio",
Expand Down Expand Up @@ -95,8 +95,6 @@ def test_stdlib_modules():
"syslog",
"termios",
"unicodedata",
# Scheduled for deprecation
"audioop",
]

# Modules added in 3.8
Expand Down
35 changes: 35 additions & 0 deletions tests/test_thirdparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,40 @@
###########################################################################
import os
import sys
from importlib.metadata import PackageNotFoundError, metadata
from pathlib import Path

import pytest


def xfail_if_not_installed(package_name):
"""A test decorator that xfails a test if the named package isn't installed.

The third-party tests are dependant on packages being built. During pre-release some
packages won't be compilable. So - the pyproject.toml installs third party packages
with a version conditional gate.

This decorator checks for app metadata (which is an indicator that the package has
been installed). If the metadata exists, the test is executed; if it isn't we XFAIL
the test because it *can't* pass.
"""

def _xfail_if_not_installed(fn):
def _testfunc(*args, **kwargs):
try:
metadata(package_name)
except PackageNotFoundError:
pytest.xfail(f"{package_name} is not installed")

# Actually run the test
fn(*args, **kwargs)

return _testfunc

return _xfail_if_not_installed


@xfail_if_not_installed("pillow")
def test_module_paths():
"Third party binary modules have meaningful __file__ attributes"
import PIL
Expand All @@ -22,6 +51,7 @@ def test_module_paths():


@pytest.mark.skipif(sys.platform == "win32", reason="cffi not available on windows")
@xfail_if_not_installed("cffi")
def test_cffi():
"CFFI can be used as an alternative FFI interface"
from cffi import FFI
Expand All @@ -32,6 +62,7 @@ def test_cffi():
assert lib.strlen(ffi.new("char[]", b"hello world")) == 11


@xfail_if_not_installed("cryptography")
def test_cryptography():
"The cryptography module can be used"
# Cryptography is a common binary library that uses cffi and OpenSSL internally
Expand Down Expand Up @@ -87,6 +118,7 @@ def test_cryptography():
assert "www.android.com" == domain


@xfail_if_not_installed("lru-dict")
def test_lru_dict():
"The LRUDict binary module can be used"
# lru-dict is the simplest possible example of a third-party module.
Expand All @@ -107,6 +139,7 @@ def test_lru_dict():
assert lru_dict[f"item_{i}"] == i


@xfail_if_not_installed("pillow")
def test_pillow():
"Pillow can be used to load images"
# Pillow is a module that has dependencies on other libraries (libjpeg, libft2)
Expand All @@ -122,6 +155,7 @@ def test_pillow():
image.close()


@xfail_if_not_installed("numpy")
def test_numpy():
"Numpy Arrays can be created"
from numpy import array
Expand All @@ -130,6 +164,7 @@ def test_numpy():
assert [4, 7] == (array([1, 2]) + array([3, 5])).tolist()


@xfail_if_not_installed("pandas")
def test_pandas():
"Pandas DataFrames can be created"
from pandas import DataFrame, __version__
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading