Skip to content

Commit

Permalink
Add Travertino to Toga repository (#3086)
Browse files Browse the repository at this point in the history
Migrates the Travertino codebase into the Toga repository to allow for coordinated
releases and version locking with new features.
  • Loading branch information
HalfWhitt authored Jan 24, 2025
1 parent e400294 commit 20e16f0
Show file tree
Hide file tree
Showing 48 changed files with 5,370 additions and 207 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ updates:
day: "sunday"
time: "20:00"

- package-ecosystem: "pip"
directory: "/travertino"
schedule:
# Check for updates on Sunday, 8PM UTC
interval: "weekly"
day: "sunday"
time: "20:00"

- package-ecosystem: "pip"
directory: "/testbed"
ignore:
Expand Down
77 changes: 49 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ jobs:
- "gtk"
- "iOS"
- "toga"
- "travertino"
- "textual"
- "web"
- "winforms"
Expand All @@ -67,8 +68,8 @@ jobs:
build-subdirectory: ${{ matrix.subdir }}
attest: ${{ inputs.attest-package }}

core:
name: Test core
core-and-travertino:
name: Test ${{ matrix.package }} (${{ matrix.platform }}, ${{ matrix.python-version }})
runs-on: ${{ matrix.platform }}
needs: [ pre-commit, towncrier, package ]
continue-on-error: ${{ matrix.experimental }}
Expand All @@ -77,8 +78,18 @@ jobs:
matrix:
platform: [ "macos-latest", "ubuntu-latest", "windows-latest" ]
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
package: ["core", "travertino"]
exclude:
- package: travertino
platform: macos-latest
- package: travertino
platform: windows-latest
include:
- experimental: false
- package: "core"
tox-suffix: ""
- package: "travertino"
tox-suffix: "-trav"

steps:
- name: Checkout
Expand All @@ -97,7 +108,7 @@ jobs:
with:
requirements: tox
extra: dev
project-root: core
project-root: ${{ matrix.package }}

- name: Get Packages
uses: actions/[email protected]
Expand All @@ -110,16 +121,16 @@ jobs:
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 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 }}
TOGA_INSTALL_COMMAND="python -m pip install ../$(ls dist/toga_core-*.whl)[dev] ../$(ls dist/toga_dummy-*.whl) ../$(ls dist/travertino-*.whl)"
tox -e py-cov${{ matrix.tox-suffix }}
tox -qe coverage$(tr -dc "0-9" <<< "${{ matrix.python-version }}")${{ matrix.tox-suffix }}
mv ${{ matrix.package }}/.coverage ${{ matrix.package }}/.coverage.${{ matrix.platform }}.${{ matrix.python-version }}
- name: Store Coverage Data
uses: actions/[email protected]
with:
name: core-coverage-data-${{ matrix.platform }}-${{ matrix.python-version }}
path: "core/.coverage.*"
name: ${{ matrix.package }}-coverage-data-${{ matrix.platform }}-${{ matrix.python-version }}
path: "${{ matrix.package }}/.coverage.*"
if-no-files-found: error
include-hidden-files: true

Expand Down Expand Up @@ -159,15 +170,21 @@ jobs:
with:
python-version: "3.13"

- name: Get Packages
- name: Get Core Package
uses: actions/[email protected]
with:
name: Packages-toga-core
path: dist

- name: Get Travertino Package
uses: actions/[email protected]
with:
name: Packages-toga-travertino
path: dist

- name: Test
run: |
pip install dist/toga_core-*.whl
pip install dist/toga_core-*.whl dist/travertino-*.whl
site_packages=$(python -c '
import sys
print([path for path in sys.path if "site-packages" in path][0])
Expand All @@ -176,17 +193,20 @@ jobs:
cd core
export MICROPYPATH="$site_packages:.frozen"
echo "Stable Travertino"
${{ steps.micropython.outputs.executable }} micropython_check.py
echo "Development Travertino"
pip install git+https://github.com/beeware/travertino
${{ steps.micropython.outputs.executable }} micropython_check.py
core-coverage:
name: Coverage
needs: core
core-and-travertino-coverage:
name: "Coverage: ${{ matrix.package }}"
needs: core-and-travertino
runs-on: ubuntu-latest
strategy:
matrix:
package: ["core", "travertino"]
include:
- package: "core"
tox-suffix: ""
- package: "travertino"
tox-suffix: "-trav"
steps:
- name: Checkout
uses: actions/[email protected]
Expand All @@ -205,28 +225,29 @@ jobs:
with:
requirements: tox
extra: dev
project-root: core
project-root: ${{ matrix.package }}

- name: Retrieve Coverage Data
uses: actions/[email protected]
with:
pattern: core-coverage-data-*
path: core
pattern: ${{ matrix.package }}-coverage-data-*
path: ${{ matrix.package }}
merge-multiple: true

- name: Generate Coverage Report
run: tox -e coverage-html-fail-platform
# Even with "fail" on, Travertino will accept <100%.
run: tox -e coverage${{ matrix.tox-suffix }}-html-fail-platform

- name: Upload HTML Coverage Report
uses: actions/[email protected]
if: failure()
with:
name: html-coverage-report
path: core/htmlcov
path: ${{ matrix.package }}/htmlcov

testbed:
name: Testbed
needs: core
needs: core-and-travertino
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -321,21 +342,21 @@ jobs:
platform: "linux"
runs-on: "ubuntu-latest"
setup-python: false # Use the system Python packages
briefcase-run-args: --config 'requires=["../core","../textual"]' --config 'console_app=true'
briefcase-run-args: --config 'requires=["../core","../textual", "../travertino"]' --config 'console_app=true'
app-user-data-path: "$HOME/.local/share/testbed"
# install the meta-package build-essential since Briefcase explicitly checks for it
pre-command: sudo apt update -y && sudo apt install -y build-essential

- backend: "textual-macOS"
platform: "macOS"
runs-on: "macos-latest"
briefcase-run-args: --config 'requires=["../core","../textual"]' --config 'console_app=true'
briefcase-run-args: --config 'requires=["../core","../textual", "../travertino"]' --config 'console_app=true'
app-user-data-path: "$HOME/Library/Application Support/org.beeware.toga.testbed"

- backend: "textual-windows"
platform: "windows"
runs-on: "windows-latest"
briefcase-run-args: --config 'requires=["../core","../textual"]' --config 'console_app=true'
briefcase-run-args: --config 'requires=["../core","../textual", "../travertino"]' --config 'console_app=true'
app-user-data-path: '$HOME\AppData\Local\Tiberius Yak\Toga Testbed\Data'

- backend: "windows"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/config-file-deps-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
uses: beeware/.github/.github/workflows/dep-version-bump.yml@main
secrets: inherit
with:
subdirectory: . core dummy android cocoa demo gtk iOS testbed textual toga web winforms
subdirectory: . core dummy android cocoa demo gtk iOS testbed textual toga travertino web winforms
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
- "toga_iOS"
- "toga_web"
- "toga_winforms"
- "travertino"
steps:
- name: Get packages
uses: dsaltares/[email protected]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
- "toga_textual"
- "toga_web"
- "toga_winforms"
- "travertino"
steps:
- name: Get Packages
uses: actions/[email protected]
Expand Down
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ repos:
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
# isort for Travertino
- id: isort
args: [--settings-path=travertino]
# For some reason, providing "travertino" as an argument doesn't work to specify
# the target, like it would on the command line; it still runs against the
# whole repo. Setting it here seems to work, though.
files: travertino
# isort for the rest of the repo
- id: isort
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.10.0
Expand Down
2 changes: 2 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ python:
extra_requirements:
- dev
- docs
- method: pip
path: travertino
3 changes: 3 additions & 0 deletions changes/3086.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The Travertino library, providing the base classes for Toga's style and box model, is now managed as part of the Toga release process.

TODO: CORRECT THE RELEASE DATE ON THE TRAVERTINO RELEASE NOTES
8 changes: 5 additions & 3 deletions core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ classifiers = [
"Topic :: Software Development :: User Interfaces",
"Topic :: Software Development :: Widget Sets",
]
dependencies = [
"travertino >= 0.3.0, < 0.4.0",
]

[project.optional-dependencies]
# Extras used by developers *of* Toga are pinned to specific versions to
Expand Down Expand Up @@ -104,6 +101,11 @@ pil = "toga.plugins.image_formats.PILConverter"
[tool.setuptools_scm]
root = ".."

[tool.setuptools_dynamic_dependencies]
dependencies = [
"travertino == {version}",
]

[tool.coverage.run]
parallel = true
branch = true
Expand Down
20 changes: 7 additions & 13 deletions core/src/toga/style/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,14 @@ def __delete__(self, widget):

def style_mixin(style_cls):
mixin_dict = {
"__doc__": f"""
Allows accessing the {style_cls.__name__} {style_cls._doc_link} directly on
the widget. For example, instead of ``widget.style.color``, you can simply
write ``widget.color``.
"""
name: StyleProperty() for name in style_cls._BASE_ALL_PROPERTIES[style_cls]
}

try:
_all_properties = style_cls._BASE_ALL_PROPERTIES
except AttributeError:
# Travertino 0.3 compatibility
_all_properties = style_cls._ALL_PROPERTIES

for name in _all_properties[style_cls]:
mixin_dict[name] = StyleProperty()
mixin_dict["__doc__"] = (
f"""Allows accessing the {style_cls.__name__} {style_cls._doc_link} directly on
the widget. For example, instead of ``widget.style.color``, you can simply write
``widget.color``.
"""
)

return type(style_cls.__name__ + "Mixin", (), mixin_dict)
Loading

0 comments on commit 20e16f0

Please sign in to comment.