Skip to content

Commit

Permalink
Merge branch 'beeware:main' into patch-20
Browse files Browse the repository at this point in the history
  • Loading branch information
proneon267 authored Jun 1, 2024
2 parents a53a820 + d68e9a8 commit f3db6ff
Show file tree
Hide file tree
Showing 113 changed files with 355 additions and 141 deletions.
61 changes: 37 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ on:
branches:
- main
workflow_call:
inputs:
attest-package:
description: "Create GitHub provenance attestation for the package."
default: "false"
type: string
outputs:
artifact-name:
description: "Name of the uploaded artifact; use for artifact retrieval."
value: ${{ jobs.package.outputs.artifact-name }}
artifact-basename:
description: "Base name of the uploaded artifacts; use for artifact retrieval."
value: ${{ jobs.package.outputs.artifact-basename }}

env:
min_python_version: "3.8"
Expand Down Expand Up @@ -38,12 +43,11 @@ jobs:
tox-source: "./core[dev]"

package:
name: Python package
uses: beeware/.github/.github/workflows/python-package-create.yml@main
with:
tox-source: "./core[dev]"
build-subdirectory: ${{ matrix.subdir }}
distribution-path: "*/dist/*"
name: Package Toga
permissions:
id-token: write
contents: read
attestations: write
strategy:
matrix:
subdir:
Expand All @@ -58,6 +62,10 @@ jobs:
- "textual"
- "web"
- "winforms"
uses: beeware/.github/.github/workflows/python-package-create.yml@main
with:
build-subdirectory: ${{ matrix.subdir }}
attest: ${{ inputs.attest-package }}

core:
name: Test core
Expand Down Expand Up @@ -93,30 +101,34 @@ jobs:
python-version: "3.13-dev"
steps:
- name: Checkout
uses: actions/checkout@v4.1.5
uses: actions/checkout@v4.1.6
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5.1.0
with:
python-version: ${{ matrix.python-version }}

- name: Install dev Dependencies
run: |
# We don't actually want to install toga-core;
# we just want the dev extras so we have a known version of tox and coverage
python -m pip install ./core[dev]
- name: Install Tox
uses: beeware/.github/.github/actions/install-requirement@main
with:
requirements: tox
extra: dev
project-root: core

- name: Get Packages
uses: actions/download-artifact@v4.1.7
with:
pattern: ${{ needs.package.outputs.artifact-name }}-*
pattern: ${{ format('{0}-*', needs.package.outputs.artifact-basename) }}
merge-multiple: true
path: dist

- name: Test
run: |
# The $(ls ...) shell expansion is done in the Github environment;
# the value of TOGA_INSTALL_COMMAND will be a literal string without any shell expansions to perform
TOGA_INSTALL_COMMAND="python -m pip install ../$(ls core/dist/toga_core-*.whl)[dev] ../$(ls dummy/dist/toga_dummy-*.whl)" \
TOGA_INSTALL_COMMAND="python -m pip install ../$(ls dist/toga_core-*.whl)[dev] ../$(ls dist/toga_dummy-*.whl)" \
tox -e py-cov
tox -qe coverage$(tr -dc "0-9" <<< "${{ matrix.python-version }}")
mv core/.coverage core/.coverage.${{ matrix.platform }}.${{ matrix.python-version }}
Expand All @@ -134,7 +146,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.5
uses: actions/checkout@v4.1.6
with:
fetch-depth: 0

Expand All @@ -145,11 +157,12 @@ jobs:
# https://github.com/nedbat/coveragepy/issues/1572#issuecomment-1522546425
python-version: ${{ env.min_python_version }}

- name: Install dev dependencies
run: |
# We don't actually want to install toga-core;
# we just want the dev extras so we have a known version of coverage
python -m pip install ./core[dev]
- name: Install Tox
uses: beeware/.github/.github/actions/install-requirement@main
with:
requirements: tox
extra: dev
project-root: core

- name: Retrieve Coverage Data
uses: actions/download-artifact@v4.1.7
Expand Down Expand Up @@ -260,7 +273,7 @@ jobs:
sudo udevadm trigger --name-match=kvm
steps:
- name: Checkout
uses: actions/checkout@v4.1.5
uses: actions/checkout@v4.1.6
with:
fetch-depth: 0

Expand Down
24 changes: 14 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
jobs:
ci:
uses: ./.github/workflows/ci.yml
with:
attest-package: "true"

docs:
name: Verify Docs Build
Expand All @@ -24,28 +26,29 @@ jobs:
permissions:
contents: write
steps:
- name: Set build variables
- name: Set Build Variables
run: |
echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
echo "VERSION=${GITHUB_REF_NAME#v}" | tee -a $GITHUB_ENV
- name: Get packages
- name: Get Packages
uses: actions/download-artifact@v4.1.7
with:
pattern: ${{ needs.ci.outputs.artifact-name }}-*
pattern: ${{ format('{0}-*', needs.ci.outputs.artifact-basename) }}
merge-multiple: true
path: dist

- name: Create release
- name: Create Release
uses: ncipollo/release-action@v1.14.0
with:
name: ${{ env.VERSION }}
draft: true
artifacts: "*/dist/*"
artifacts: "dist/*"
artifactErrorsFailBuild: true

deploy-test:
name: Publish to TestPyPI
runs-on: ubuntu-latest
needs: [ci, release]
needs: [ ci, release ]
permissions:
# This permission is required for trusted publishing.
id-token: write
Expand All @@ -68,16 +71,17 @@ jobs:
- "toga_web"
- "toga_winforms"
steps:
- name: Get packages
- name: Get Packages
uses: actions/download-artifact@v4.1.7
with:
pattern: ${{ needs.ci.outputs.artifact-name }}-*
pattern: ${{ format('{0}-*', needs.ci.outputs.artifact-basename) }}
merge-multiple: true
path: staging_dist

- name: Extract ${{ matrix.package }}
run: |
mkdir dist
mv */dist/$(echo ${{ matrix.package }} | sed 's/_/?/')-[0-9]* dist
mv staging_dist/$(echo ${{ matrix.package }} | sed 's/_/?/')-[0-9]* dist
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
# remove toml extra once Python 3.10 is no longer supported
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ contributors`_ will help you get started.
If you experience problems with Toga, `log them on GitHub`_. If you want to
contribute code, please `fork the code`_ and `submit a pull request`_.

.. _guide for first time contributors: https://toga.readthedocs.io/en/latest/how-to/contribute-code.html
.. _guide for first time contributors: https://toga.readthedocs.io/en/latest/how-to/contribute/index.html
.. _log them on Github: https://github.com/beeware/toga/issues
.. _fork the code: https://github.com/beeware/toga
.. _submit a pull request: https://github.com/beeware/toga/pulls
2 changes: 1 addition & 1 deletion android/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = [
"setuptools==69.5.1",
"setuptools==70.0.0",
"setuptools_scm==8.1.0",
"setuptools_dynamic_dependencies @ git+https://github.com/beeware/setuptools_dynamic_dependencies",
]
Expand Down
29 changes: 22 additions & 7 deletions android/src/toga_android/widgets/detailedlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@
from android.graphics import Rect
from android.view import Gravity, View
from android.widget import ImageView, LinearLayout, RelativeLayout, ScrollView, TextView
from androidx.swiperefreshlayout.widget import SwipeRefreshLayout
from java import dynamic_proxy

try:
from androidx.swiperefreshlayout.widget import SwipeRefreshLayout
except ImportError: # pragma: no cover
# Import will fail if SwipeRefreshLayout is not listed in dependencies
# No cover due to not being able to test in CI
SwipeRefreshLayout = None


from .base import Widget


Expand Down Expand Up @@ -78,17 +85,25 @@ def onClick(self, dialog, which):
self.actions[which].handler(row=self.row)


class OnRefreshListener(dynamic_proxy(SwipeRefreshLayout.OnRefreshListener)):
def __init__(self, interface):
super().__init__()
self._interface = interface
if SwipeRefreshLayout is not None: # pragma: no cover

class OnRefreshListener(dynamic_proxy(SwipeRefreshLayout.OnRefreshListener)):
def __init__(self, interface):
super().__init__()
self._interface = interface

def onRefresh(self):
self._interface.on_refresh()
def onRefresh(self):
self._interface.on_refresh()


class DetailedList(Widget):
def create(self):
if SwipeRefreshLayout is None: # pragma: no cover
raise RuntimeError(
"Unable to import SwipeRefreshLayout. Ensure that the AndroidX Swipe Refresh Layout "
"widget package (androidx.swiperefreshlayout:swiperefreshlayout:1.1.0) "
"is listed in your app's dependencies."
)
# get the selection color from the current theme
attrs = [R.attr.colorBackground, R.attr.colorControlHighlight]
typed_array = self._native_activity.obtainStyledAttributes(attrs)
Expand Down
3 changes: 1 addition & 2 deletions android/src/toga_android/widgets/textinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ def is_valid(self):
return self.native.getError() is None

def _on_change(self):
self.interface.on_change()
self.interface._validate()
self.interface._value_changed()

def _on_confirm(self):
self.interface.on_confirm()
Expand Down
3 changes: 3 additions & 0 deletions android/tests_backend/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,6 @@ def assert_toolbar_item(self, index, label, tooltip, has_icon, enabled):

def press_toolbar_button(self, index):
self.native.onOptionsItemSelected(self._toolbar_items()[index])

def is_modal_dialog(self, dialog):
return True
1 change: 1 addition & 0 deletions changes/2301.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APIs were added for replacing a widget in an existing layout, and for obtaining the index of a widget in a list of children.
1 change: 1 addition & 0 deletions changes/2307.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The content of a window can now be set when the window is constructed.
1 change: 1 addition & 0 deletions changes/2325.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Invocation order of TextInput on_change and validation is now correct.
1 change: 1 addition & 0 deletions changes/2446.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dialog windows are now properly modal when using the Gtk+ backend.
1 change: 1 addition & 0 deletions changes/2454.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Android deployments no longer require the SwipeRefreshLayout component unless the app uses the Toga DetailedList widget.
1 change: 1 addition & 0 deletions changes/2576.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated pytest-asyncio from 0.23.6 to 0.23.7 in /core.
1 change: 1 addition & 0 deletions changes/2577.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated setuptools-scm from 8.0.4 to 8.1.0 in /core.
1 change: 1 addition & 0 deletions changes/2578.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated pytest from 8.2.0 to 8.2.1 in /core.
1 change: 1 addition & 0 deletions changes/2579.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated actions/checkout from 4.1.5 to 4.1.6.
1 change: 1 addition & 0 deletions changes/2580.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The pinned dependencies in pyproject.toml and tox.ini were updated to their latest versions.
1 change: 1 addition & 0 deletions changes/2583.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Button testbed tests can accommodate minor rendering differences on Fedora 40.
1 change: 1 addition & 0 deletions changes/2588.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The first-time contributor README link has been updated.
1 change: 1 addition & 0 deletions changes/2589.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
On macOS, apps will now raise a warning if camera permissions have been requested, but those permissions have not been declared as part of the application metadata.
1 change: 1 addition & 0 deletions changes/2593.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tutorial instructions were clarified.
1 change: 1 addition & 0 deletions changes/2600.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated coverage[toml] from 7.5.1 to 7.5.2 in /core.
1 change: 1 addition & 0 deletions changes/2601.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The pinned dependencies in pyproject.toml and tox.ini were updated to their latest versions.
1 change: 1 addition & 0 deletions changes/2602.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The ``pre-commit`` hook for ``codespell`` was updated to its latest version.
1 change: 1 addition & 0 deletions changes/2604.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``hynek/build-and-inspect-python-package`` is now used to create the Python package.
1 change: 1 addition & 0 deletions changes/2605.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
An error in an example argument was corrected.
2 changes: 1 addition & 1 deletion cocoa/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = [
"setuptools==69.5.1",
"setuptools==70.0.0",
"setuptools_scm==8.1.0",
"setuptools_dynamic_dependencies @ git+https://github.com/beeware/setuptools_dynamic_dependencies",
]
Expand Down
19 changes: 19 additions & 0 deletions cocoa/src/toga_cocoa/hardware/camera.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import warnings
from threading import Thread

from rubicon.objc import Block, objc_method
Expand All @@ -22,6 +23,7 @@
AVCaptureVideoPreviewLayer,
AVLayerVideoGravityResizeAspectFill,
AVMediaTypeVideo,
NSBundle,
)


Expand Down Expand Up @@ -247,6 +249,23 @@ def photo_taken(self, photo):
class Camera:
def __init__(self, interface):
self.interface = interface

if not NSBundle.mainBundle.objectForInfoDictionaryKey(
"NSCameraUsageDescription"
): # pragma: no cover
# The app doesn't have the NSCameraUsageDescription key (e.g., via
# `permission.camera` in Briefcase). No-cover because we can't manufacture
# this condition in testing.
msg = (
"Application metadata does not declare that the app will use "
"the camera. See "
"https://toga.readthedocs.io/en/stable/reference/api/hardware/camera.html"
)
if self.interface.app.is_bundled:
raise RuntimeError(msg)
else:
warnings.warn(msg)

self.preview_windows = []

def has_permission(self, allow_unknown=False):
Expand Down
3 changes: 1 addition & 2 deletions cocoa/src/toga_cocoa/widgets/textinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ def get_value(self):

def set_value(self, value):
self.native.stringValue = value
self.interface.on_change()
self.interface._validate()
self.interface._value_changed()

def rehint(self):
# Height of a text input is known and fixed.
Expand Down
3 changes: 3 additions & 0 deletions cocoa/tests_backend/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,6 @@ def press_toolbar_button(self, index):
restype=None,
argtypes=[objc_id],
)

def is_modal_dialog(self, dialog):
return True
2 changes: 1 addition & 1 deletion core/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ contributors`_ will help you get started.
If you experience problems with Toga, `log them on GitHub`_. If you want to
contribute code, please `fork the code`_ and `submit a pull request`_.

.. _guide for first time contributors: https://toga.readthedocs.io/en/latest/how-to/contribute-code.html
.. _guide for first time contributors: https://toga.readthedocs.io/en/latest/how-to/contribute/index.html
.. _log them on Github: https://github.com/beeware/toga/issues
.. _fork the code: https://github.com/beeware/toga
.. _submit a pull request: https://github.com/beeware/toga/pulls
Loading

0 comments on commit f3db6ff

Please sign in to comment.