Skip to content

Commit 20e16f0

Browse files
authored
Add Travertino to Toga repository (#3086)
Migrates the Travertino codebase into the Toga repository to allow for coordinated releases and version locking with new features.
1 parent e400294 commit 20e16f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+5370
-207
lines changed

.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ updates:
7373
day: "sunday"
7474
time: "20:00"
7575

76+
- package-ecosystem: "pip"
77+
directory: "/travertino"
78+
schedule:
79+
# Check for updates on Sunday, 8PM UTC
80+
interval: "weekly"
81+
day: "sunday"
82+
time: "20:00"
83+
7684
- package-ecosystem: "pip"
7785
directory: "/testbed"
7886
ignore:

.github/workflows/ci.yml

+49-28
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959
- "gtk"
6060
- "iOS"
6161
- "toga"
62+
- "travertino"
6263
- "textual"
6364
- "web"
6465
- "winforms"
@@ -67,8 +68,8 @@ jobs:
6768
build-subdirectory: ${{ matrix.subdir }}
6869
attest: ${{ inputs.attest-package }}
6970

70-
core:
71-
name: Test core
71+
core-and-travertino:
72+
name: Test ${{ matrix.package }} (${{ matrix.platform }}, ${{ matrix.python-version }})
7273
runs-on: ${{ matrix.platform }}
7374
needs: [ pre-commit, towncrier, package ]
7475
continue-on-error: ${{ matrix.experimental }}
@@ -77,8 +78,18 @@ jobs:
7778
matrix:
7879
platform: [ "macos-latest", "ubuntu-latest", "windows-latest" ]
7980
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
81+
package: ["core", "travertino"]
82+
exclude:
83+
- package: travertino
84+
platform: macos-latest
85+
- package: travertino
86+
platform: windows-latest
8087
include:
8188
- experimental: false
89+
- package: "core"
90+
tox-suffix: ""
91+
- package: "travertino"
92+
tox-suffix: "-trav"
8293

8394
steps:
8495
- name: Checkout
@@ -97,7 +108,7 @@ jobs:
97108
with:
98109
requirements: tox
99110
extra: dev
100-
project-root: core
111+
project-root: ${{ matrix.package }}
101112

102113
- name: Get Packages
103114
uses: actions/[email protected]
@@ -110,16 +121,16 @@ jobs:
110121
run: |
111122
# The $(ls ...) shell expansion is done in the Github environment;
112123
# the value of TOGA_INSTALL_COMMAND will be a literal string without any shell expansions to perform
113-
TOGA_INSTALL_COMMAND="python -m pip install ../$(ls dist/toga_core-*.whl)[dev] ../$(ls dist/toga_dummy-*.whl)" \
114-
tox -e py-cov
115-
tox -qe coverage$(tr -dc "0-9" <<< "${{ matrix.python-version }}")
116-
mv core/.coverage core/.coverage.${{ matrix.platform }}.${{ matrix.python-version }}
124+
TOGA_INSTALL_COMMAND="python -m pip install ../$(ls dist/toga_core-*.whl)[dev] ../$(ls dist/toga_dummy-*.whl) ../$(ls dist/travertino-*.whl)"
125+
tox -e py-cov${{ matrix.tox-suffix }}
126+
tox -qe coverage$(tr -dc "0-9" <<< "${{ matrix.python-version }}")${{ matrix.tox-suffix }}
127+
mv ${{ matrix.package }}/.coverage ${{ matrix.package }}/.coverage.${{ matrix.platform }}.${{ matrix.python-version }}
117128
118129
- name: Store Coverage Data
119130
uses: actions/[email protected]
120131
with:
121-
name: core-coverage-data-${{ matrix.platform }}-${{ matrix.python-version }}
122-
path: "core/.coverage.*"
132+
name: ${{ matrix.package }}-coverage-data-${{ matrix.platform }}-${{ matrix.python-version }}
133+
path: "${{ matrix.package }}/.coverage.*"
123134
if-no-files-found: error
124135
include-hidden-files: true
125136

@@ -159,15 +170,21 @@ jobs:
159170
with:
160171
python-version: "3.13"
161172

162-
- name: Get Packages
173+
- name: Get Core Package
163174
uses: actions/[email protected]
164175
with:
165176
name: Packages-toga-core
166177
path: dist
167178

179+
- name: Get Travertino Package
180+
uses: actions/[email protected]
181+
with:
182+
name: Packages-toga-travertino
183+
path: dist
184+
168185
- name: Test
169186
run: |
170-
pip install dist/toga_core-*.whl
187+
pip install dist/toga_core-*.whl dist/travertino-*.whl
171188
site_packages=$(python -c '
172189
import sys
173190
print([path for path in sys.path if "site-packages" in path][0])
@@ -176,17 +193,20 @@ jobs:
176193
cd core
177194
export MICROPYPATH="$site_packages:.frozen"
178195
179-
echo "Stable Travertino"
180196
${{ steps.micropython.outputs.executable }} micropython_check.py
181197
182-
echo "Development Travertino"
183-
pip install git+https://github.com/beeware/travertino
184-
${{ steps.micropython.outputs.executable }} micropython_check.py
185-
186-
core-coverage:
187-
name: Coverage
188-
needs: core
198+
core-and-travertino-coverage:
199+
name: "Coverage: ${{ matrix.package }}"
200+
needs: core-and-travertino
189201
runs-on: ubuntu-latest
202+
strategy:
203+
matrix:
204+
package: ["core", "travertino"]
205+
include:
206+
- package: "core"
207+
tox-suffix: ""
208+
- package: "travertino"
209+
tox-suffix: "-trav"
190210
steps:
191211
- name: Checkout
192212
uses: actions/[email protected]
@@ -205,28 +225,29 @@ jobs:
205225
with:
206226
requirements: tox
207227
extra: dev
208-
project-root: core
228+
project-root: ${{ matrix.package }}
209229

210230
- name: Retrieve Coverage Data
211231
uses: actions/[email protected]
212232
with:
213-
pattern: core-coverage-data-*
214-
path: core
233+
pattern: ${{ matrix.package }}-coverage-data-*
234+
path: ${{ matrix.package }}
215235
merge-multiple: true
216236

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

220241
- name: Upload HTML Coverage Report
221242
uses: actions/[email protected]
222243
if: failure()
223244
with:
224245
name: html-coverage-report
225-
path: core/htmlcov
246+
path: ${{ matrix.package }}/htmlcov
226247

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

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

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

341362
- backend: "windows"

.github/workflows/config-file-deps-bump.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ jobs:
1111
uses: beeware/.github/.github/workflows/dep-version-bump.yml@main
1212
secrets: inherit
1313
with:
14-
subdirectory: . core dummy android cocoa demo gtk iOS testbed textual toga web winforms
14+
subdirectory: . core dummy android cocoa demo gtk iOS testbed textual toga travertino web winforms

.github/workflows/publish.yml

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
- "toga_iOS"
2828
- "toga_web"
2929
- "toga_winforms"
30+
- "travertino"
3031
steps:
3132
- name: Get packages
3233
uses: dsaltares/[email protected]

.github/workflows/release.yml

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ jobs:
7070
- "toga_textual"
7171
- "toga_web"
7272
- "toga_winforms"
73+
- "travertino"
7374
steps:
7475
- name: Get Packages
7576
uses: actions/[email protected]

.pre-commit-config.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ repos:
1717
- repo: https://github.com/PyCQA/isort
1818
rev: 5.13.2
1919
hooks:
20+
# isort for Travertino
21+
- id: isort
22+
args: [--settings-path=travertino]
23+
# For some reason, providing "travertino" as an argument doesn't work to specify
24+
# the target, like it would on the command line; it still runs against the
25+
# whole repo. Setting it here seems to work, though.
26+
files: travertino
27+
# isort for the rest of the repo
2028
- id: isort
2129
- repo: https://github.com/psf/black-pre-commit-mirror
2230
rev: 24.10.0

.readthedocs.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ python:
3535
extra_requirements:
3636
- dev
3737
- docs
38+
- method: pip
39+
path: travertino

changes/3086.feature.rst

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The Travertino library, providing the base classes for Toga's style and box model, is now managed as part of the Toga release process.
2+
3+
TODO: CORRECT THE RELEASE DATE ON THE TRAVERTINO RELEASE NOTES

core/pyproject.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ classifiers = [
5555
"Topic :: Software Development :: User Interfaces",
5656
"Topic :: Software Development :: Widget Sets",
5757
]
58-
dependencies = [
59-
"travertino >= 0.3.0, < 0.4.0",
60-
]
6158

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

104+
[tool.setuptools_dynamic_dependencies]
105+
dependencies = [
106+
"travertino == {version}",
107+
]
108+
107109
[tool.coverage.run]
108110
parallel = true
109111
branch = true

core/src/toga/style/mixin.py

+7-13
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,14 @@ def __delete__(self, widget):
1717

1818
def style_mixin(style_cls):
1919
mixin_dict = {
20-
"__doc__": f"""
21-
Allows accessing the {style_cls.__name__} {style_cls._doc_link} directly on
22-
the widget. For example, instead of ``widget.style.color``, you can simply
23-
write ``widget.color``.
24-
"""
20+
name: StyleProperty() for name in style_cls._BASE_ALL_PROPERTIES[style_cls]
2521
}
2622

27-
try:
28-
_all_properties = style_cls._BASE_ALL_PROPERTIES
29-
except AttributeError:
30-
# Travertino 0.3 compatibility
31-
_all_properties = style_cls._ALL_PROPERTIES
32-
33-
for name in _all_properties[style_cls]:
34-
mixin_dict[name] = StyleProperty()
23+
mixin_dict["__doc__"] = (
24+
f"""Allows accessing the {style_cls.__name__} {style_cls._doc_link} directly on
25+
the widget. For example, instead of ``widget.style.color``, you can simply write
26+
``widget.color``.
27+
"""
28+
)
3529

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

0 commit comments

Comments
 (0)