Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 16 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ jobs:
echo "\n\nStarting CLI..."
echo "gtimeout 10 ${{ steps.build-exe.outputs.out-filepath }}/Contents/MacOS/${{ steps.build-exe.outputs.out-filename }} --user-interface=cli" | bash || true

zip -r9 ${{ steps.build-exe.outputs.zip-filepath }} ${{ steps.build-exe.outputs.out-filepath }} || true
rm -rf ${{ steps.build-exe.outputs.out-filepath }}

- name: Test executable [Windows]
if: runner.os == 'Windows'
shell: bash
Expand Down Expand Up @@ -120,7 +123,6 @@ jobs:

deploy:
name: Create release
continue-on-error: true
needs: build
runs-on: "ubuntu-latest"
permissions:
Expand Down Expand Up @@ -163,9 +165,22 @@ jobs:

- name: Upload
uses: "softprops/action-gh-release@v2"
id: release
with:
tag_name: ${{github.ref_name}}
make_latest: ${{github.event_name == 'push'}}
generate_release_notes: true
files: |
build/*/exe/TiLiA-v*

- name: Check output
run: |
echo "Counting assets released..."
if [ -n "${{ fromJSON(steps.release.outputs.assets)[3].id }}" ] && [ -z "${{ fromJSON(steps.release.outputs.assets)[4].id }}" ];
then
echo "4 assets found!"
else
echo "::error::Incorrect number of assets! Potential errors in build."
echo assets: ${{ steps.release.outputs.assets }}
exit 1;
fi;
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ You need Python >=3.10 to build and test TiLiA. You will also need to have ffmpe
# Developing for TiLiA
For a better development experience, we recommend the installation of a few more packages:
```
pip install --group dev --group testing
pip install --group dev
pre-commit install
```
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ description = "A GUI for creating and visualizing annotations over audio and vid
readme = "README.md"
requires-python = ">=3.10,<3.14"
dependencies = [
"chardet<6.0.0",
"colorama~=0.4.6",
"httpx~=0.28.1",
"isodate~=0.7.2",
Expand Down Expand Up @@ -58,10 +59,12 @@ ci-tests = [
"coverage-badge>=1.0.0",
"ruff>=0.15.0",
"pytest-cov>=6.0.0",
"pytest-timeout",
]
dev = [
"icecream>=2.1.0",
"pre-commit",
{include-group = "testing"},
]
testing = [
"pytest>=8.0.0",
Expand Down Expand Up @@ -90,6 +93,7 @@ env = [
"ENVIRONMENT=test",
"QT_QPA_PLATFORM=offscreen",
]
timeout = 10

[tool.ruff]
exclude = ["tilia/dev"]
Expand Down
28 changes: 23 additions & 5 deletions scripts/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,23 @@ def _create_lib() -> Path:
return lib / tilia


def _get_implicit_imports():
from tilia.utils import get_sibling_packages

tls = [
tl + ".timeline"
for tl in get_sibling_packages(
"tilia.timelines.base.timeline",
(Path(__file__).parent.parent / "tilia/timelines/base/timeline").as_posix(),
)
]
tluis = get_sibling_packages(
"tilia.ui.timelines.base.timeline",
(Path(__file__).parent.parent / "tilia/ui/timelines/base/timeline").as_posix(),
)
return tls + tluis


def _update_yml():
if not Path(pkg_cfg).exists():
return
Expand All @@ -191,6 +208,7 @@ def _update_yml():
},
{"include-metadata": ["TiLiA"]},
],
"implicit-imports": [{"depends": _get_implicit_imports()}],
}
)

Expand Down Expand Up @@ -255,16 +273,16 @@ def build():
_build_exe()
if os.environ.get("GITHUB_OUTPUT"):
if "mac" in build_os:
os.rename(
outdir / "exe" / "tilia.app",
outdir / "exe" / (out_filename + ".app"),
)
out_filepath = outdir / "exe" / (out_filename + ".app")
out_filepath = outdir / "exe" / "tilia.app"
else:
out_filepath = outdir / "exe" / out_filename
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write(f"out-filepath={out_filepath.as_posix()}\n")
f.write(f"out-filename={out_filename}\n")
if "mac" in build_os:
f.write(
f"zip-filepath={outdir.as_posix()}/exe/{out_filename}.zip\n"
)
os.chdir(old_dir)
dotenv.set_key(".tilia.env", "ENVIRONMENT", old_env_var)
except Exception as e:
Expand Down
12 changes: 3 additions & 9 deletions tilia/timelines/base/timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import functools
import bisect
import importlib
import os
from abc import ABC
from enum import Enum, auto
from pathlib import Path
from typing import Any, Callable, TYPE_CHECKING, TypeVar, Generic, Set

from tilia.timelines import serialize
Expand All @@ -16,6 +14,7 @@
SetTimelineDataError,
GetTimelineDataError,
)
from tilia.utils import get_sibling_packages
from .validators import (
validate_string,
validate_read_only,
Expand Down Expand Up @@ -137,15 +136,10 @@ def subclasses(cls):

@classmethod
def ensure_subclasses_are_available(cls):
timelines_dir = Path(os.path.dirname(__file__)).parent
packages = [
"tilia.timelines." + d.name + ".timeline"
for d in timelines_dir.iterdir()
if d.is_dir() and d.name not in ["base", "__pycache__", "collection"]
]
packages = get_sibling_packages(__name__, __file__)
for pkg in packages:
try:
importlib.import_module(pkg)
importlib.import_module(pkg + ".timeline")
except ModuleNotFoundError:
print(f"Could not find timeline class in {pkg}.")

Expand Down
10 changes: 2 additions & 8 deletions tilia/ui/timelines/base/timeline.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from __future__ import annotations
import functools
import importlib
import os
from abc import ABC
from pathlib import Path
from typing import (
Any,
TYPE_CHECKING,
Expand All @@ -30,6 +28,7 @@
get_copy_data_from_element,
)
from tilia.ui import commands
from tilia.utils import get_sibling_packages
from ..view import TimelineView
from ...coords import time_x_converter
from ...windows import WindowKind
Expand Down Expand Up @@ -118,12 +117,7 @@ def subclasses(cls):

@classmethod
def ensure_subclasses_are_available(cls):
timelines_dir = Path(os.path.dirname(__file__)).parent
packages = [
"tilia.ui.timelines." + d.name
for d in timelines_dir.iterdir()
if d.is_dir() and d.name not in ["base", "__pycache__"]
]
packages = get_sibling_packages(__name__, __file__)
for pkg in packages:
importlib.import_module(pkg)

Expand Down
11 changes: 11 additions & 0 deletions tilia/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,24 @@
import subprocess
import sys
from pathlib import Path
from pkgutil import iter_modules
from typing import Any


def get_tilia_class_string(self: Any) -> str:
return self.__class__.__name__ + "-" + str(id(self))


def get_sibling_packages(m_name: str, m_file: str):
parent_path = Path(os.path.dirname(m_file)).parent
parent_package = ".".join(m_name.split(".")[:-2])
return [
".".join([parent_package, d.name])
for d in iter_modules([parent_path])
if d.ispkg and d.name not in ["base", "collection", "__pycache__"]
]


def open_with_os(path: Path) -> None:
if not os.path.exists(path):
raise FileNotFoundError(f"File not found: {path}")
Expand Down
Loading