diff --git a/.gitignore b/.gitignore index 09723b9..cb81972 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ __pycache__ .coverage .coverage.* htmlcov +*.egg-info # Zig *.so diff --git a/Makefile b/Makefile index f810152..eb2ca87 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ check: typecheck test lintcheck # Build the Zig library for development. build-zig: - cd rose_zig && zig build -Doptimize=Debug + cd rose-zig && zig build -Doptimize=Debug typecheck: mypy . diff --git a/conftest.py b/conftest.py index b693b49..f277c0c 100644 --- a/conftest.py +++ b/conftest.py @@ -9,7 +9,6 @@ import pytest from click.testing import CliRunner - from rose.cache import CACHE_SCHEMA_PATH, process_string_for_fts, update_cache from rose.common import VERSION from rose.config import Config, VirtualFSConfig diff --git a/flake.nix b/flake.nix index 7dbdf41..5bed246 100644 --- a/flake.nix +++ b/flake.nix @@ -14,8 +14,9 @@ flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; - python = pkgs.python311; - uuid6-python = python.pkgs.buildPythonPackage { + python-pin = pkgs.python311; + version = nixpkgs.lib.strings.removeSuffix "\n" (builtins.readFile ./rose-py/rose/.version); + uuid6 = python-pin.pkgs.buildPythonPackage { pname = "uuid6-python"; version = "2023.5.2"; src = pkgs.fetchFromGitHub { @@ -26,28 +27,31 @@ }; doCheck = false; }; - prod-py-deps = with python.pkgs; [ - appdirs - cffi - click - jinja2 - llfuse - mutagen - send2trash - setuptools - tomli-w - uuid6-python - watchdog - ]; - dev-py-deps = with python.pkgs; [ - mypy - pytest - pytest-timeout - pytest-cov - pytest-xdist - snapshottest - ]; - version = nixpkgs.lib.strings.removeSuffix "\n" (builtins.readFile ./rose/.version); + py-deps = with python-pin.pkgs; { + inherit + # Runtime deps. + appdirs + cffi + click + jinja2 + llfuse + mutagen + send2trash + setuptools + tomli-w + uuid6 + watchdog + # Dev tools. + mypy + pytest + pytest-timeout + pytest-cov + pytest-xdist + snapshottest; + }; + python-with-deps = python-pin.withPackages (_: + pkgs.lib.attrsets.mapAttrsToList (a: b: b) py-deps + ); in { devShells.default = pkgs.mkShell { @@ -60,13 +64,17 @@ echo "$path" } export ROSE_ROOT="$(find-up flake.nix)" - export ROSE_SO_PATH="$ROSE_ROOT/rose_zig/zig-out/lib/librose.so" + export ROSE_SO_PATH="$ROSE_ROOT/rose-zig/zig-out/lib/librose.so" + export PYTHONPATH="$ROSE_ROOT/rose-py:''${PYTHONPATH:-}" + export PYTHONPATH="$ROSE_ROOT/rose-watchdog:$PYTHONPATH" + export PYTHONPATH="$ROSE_ROOT/rose-vfs:$PYTHONPATH" + export PYTHONPATH="$ROSE_ROOT/rose-cli:$PYTHONPATH" ''; buildInputs = [ (pkgs.buildEnv { name = "rose-devshell"; paths = with pkgs; [ - (python.withPackages (_: prod-py-deps ++ dev-py-deps)) + python-with-deps ruff nodePackages.pyright nodePackages.prettier @@ -77,29 +85,14 @@ ]; }; packages = rec { - rose-zig = pkgs.callPackage ./rose_zig { inherit version; }; - # TODO: Split up into multiple packages. - rose-py = python.pkgs.buildPythonPackage { - pname = "rose"; - version = version; - src = ./.; - propagatedBuildInputs = prod-py-deps ++ [ rose-zig ]; - nativeBuildInputs = [ pkgs.makeWrapper ]; - postInstall = '' - wrapProgram $out/bin/rose --set ROSE_SO_PATH "${rose-zig}/lib/librose.so" - ''; - doCheck = false; - }; - # CLI is currently rose-py... - rose-cli = rose-py; - # Mainly for building everything in CI. + rose-zig = pkgs.callPackage ./rose-zig { inherit version; }; + rose-py = pkgs.callPackage ./rose-py { inherit version python-pin py-deps rose-zig; }; + rose-watchdog = pkgs.callPackage ./rose-watchdog { inherit version python-pin py-deps rose-py; }; + rose-vfs = pkgs.callPackage ./rose-vfs { inherit version python-pin py-deps rose-py; }; + rose-cli = pkgs.callPackage ./rose-cli { inherit version python-pin py-deps rose-py rose-vfs rose-watchdog; }; all = pkgs.buildEnv { name = "rose-all"; - paths = [ - rose-zig - rose-py - rose-cli - ]; + paths = [ rose-zig rose-py rose-watchdog rose-vfs rose-cli ]; }; }; }); diff --git a/pyproject.toml b/pyproject.toml index 859a262..12698bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,6 +61,9 @@ unfixable = [ strict = true strict_optional = true explicit_package_bases = true +exclude = [ + "setup.py" +] [[tool.mypy.overrides]] module = "fuse" diff --git a/rose/.version b/rose-cli/.version similarity index 100% rename from rose/.version rename to rose-cli/.version diff --git a/rose-cli/default.nix b/rose-cli/default.nix new file mode 100644 index 0000000..9893e73 --- /dev/null +++ b/rose-cli/default.nix @@ -0,0 +1,20 @@ +{ python-pin +, version +, py-deps +, rose-py +, rose-vfs +, rose-watchdog +}: + +python-pin.pkgs.buildPythonPackage { + pname = "rose-cli"; + version = version; + src = ./.; + propagatedBuildInputs = [ + rose-py + rose-vfs + rose-watchdog + py-deps.click + ]; + doCheck = false; +} diff --git a/rose_cli/__init__.py b/rose-cli/rose_cli/__init__.py similarity index 100% rename from rose_cli/__init__.py rename to rose-cli/rose_cli/__init__.py diff --git a/rose_cli/__main__.py b/rose-cli/rose_cli/__main__.py similarity index 89% rename from rose_cli/__main__.py rename to rose-cli/rose_cli/__main__.py index 38acd1e..293759c 100644 --- a/rose_cli/__main__.py +++ b/rose-cli/rose_cli/__main__.py @@ -1,13 +1,12 @@ import sys import click +from rose import RoseExpectedError from rose_cli.cli import CliExpectedError, cli def main() -> None: - from rose import RoseExpectedError - try: cli() except (RoseExpectedError, CliExpectedError) as e: diff --git a/rose_cli/cli.py b/rose-cli/rose_cli/cli.py similarity index 100% rename from rose_cli/cli.py rename to rose-cli/rose_cli/cli.py index d68dc61..cfd25e8 100644 --- a/rose_cli/cli.py +++ b/rose-cli/rose_cli/cli.py @@ -15,7 +15,6 @@ from pathlib import Path import click - from rose import ( VERSION, Action, @@ -51,6 +50,9 @@ toggle_release_new, update_cache, ) +from rose_vfs import mount_virtualfs +from rose_watchdog import start_watchdog + from rose_cli.dump import ( dump_all_artists, dump_all_collages, @@ -70,8 +72,6 @@ dump_track, ) from rose_cli.templates import preview_path_templates -from rose_vfs import mount_virtualfs -from rose_watchdog import start_watchdog logger = logging.getLogger(__name__) diff --git a/rose_cli/cli_test.py b/rose-cli/rose_cli/cli_test.py similarity index 100% rename from rose_cli/cli_test.py rename to rose-cli/rose_cli/cli_test.py index 18236cf..fc50e36 100644 --- a/rose_cli/cli_test.py +++ b/rose-cli/rose_cli/cli_test.py @@ -5,9 +5,10 @@ import pytest from click.testing import CliRunner - from rose import AudioTags, Config from rose.ffi import get_release +from rose_vfs.virtualfs_test import start_virtual_fs + from rose_cli.cli import ( Context, InvalidReleaseArgError, @@ -19,7 +20,6 @@ unwatch, watch, ) -from rose_vfs.virtualfs_test import start_virtual_fs @pytest.mark.usefixtures("seeded_cache") diff --git a/rose_cli/dump.py b/rose-cli/rose_cli/dump.py similarity index 100% rename from rose_cli/dump.py rename to rose-cli/rose_cli/dump.py diff --git a/rose_cli/dump_test.py b/rose-cli/rose_cli/dump_test.py similarity index 100% rename from rose_cli/dump_test.py rename to rose-cli/rose_cli/dump_test.py index 302fbc6..125f20c 100644 --- a/rose_cli/dump_test.py +++ b/rose-cli/rose_cli/dump_test.py @@ -2,8 +2,8 @@ from typing import Any import pytest - from rose import Config, Matcher + from rose_cli.dump import ( dump_all_artists, dump_all_collages, diff --git a/rose_cli/snapshots/__init__.py b/rose-cli/rose_cli/snapshots/__init__.py similarity index 100% rename from rose_cli/snapshots/__init__.py rename to rose-cli/rose_cli/snapshots/__init__.py diff --git a/rose_cli/snapshots/snap_dump_test.py b/rose-cli/rose_cli/snapshots/snap_dump_test.py similarity index 100% rename from rose_cli/snapshots/snap_dump_test.py rename to rose-cli/rose_cli/snapshots/snap_dump_test.py diff --git a/rose_cli/templates.py b/rose-cli/rose_cli/templates.py similarity index 99% rename from rose_cli/templates.py rename to rose-cli/rose_cli/templates.py index 31f7d74..d7419de 100644 --- a/rose_cli/templates.py +++ b/rose-cli/rose_cli/templates.py @@ -1,5 +1,4 @@ import click - from rose import ( Config, PathTemplate, diff --git a/rose_cli/templates_test.py b/rose-cli/rose_cli/templates_test.py similarity index 100% rename from rose_cli/templates_test.py rename to rose-cli/rose_cli/templates_test.py index 2dea070..6fc9c1b 100644 --- a/rose_cli/templates_test.py +++ b/rose-cli/rose_cli/templates_test.py @@ -1,7 +1,7 @@ import click from click.testing import CliRunner - from rose import Config + from rose_cli.templates import ( preview_path_templates, ) diff --git a/rose-cli/setup.py b/rose-cli/setup.py new file mode 100644 index 0000000..344605c --- /dev/null +++ b/rose-cli/setup.py @@ -0,0 +1,21 @@ +import setuptools + +with open(".version") as f: + version = f.read().strip() + +setuptools.setup( + name="rose-cli", + version=version, + python_requires=">=3.11.0", + author="blissful", + author_email="blissful@sunsetglow.net", + license="Apache-2.0", + entry_points={"console_scripts": ["rose = rose_cli.__main__:main"]}, + packages=["rose_cli"], + install_requires=[ + "click", + "rose", + "rose-vfs", + "rose-watchdog", + ], +) diff --git a/rose-py/default.nix b/rose-py/default.nix new file mode 100644 index 0000000..2c56594 --- /dev/null +++ b/rose-py/default.nix @@ -0,0 +1,23 @@ +{ python-pin +, version +, py-deps +, rose-zig +}: + +python-pin.pkgs.buildPythonPackage { + pname = "rose"; + version = version; + src = ./.; + propagatedBuildInputs = [ + rose-zig + py-deps.appdirs + py-deps.click + py-deps.jinja2 + py-deps.mutagen + py-deps.send2trash + py-deps.tomli-w + py-deps.uuid6 + ]; + doCheck = false; + ROSE_SO_PATH = "${rose-zig}/lib/librose.so"; +} diff --git a/rose-py/rose/.version b/rose-py/rose/.version new file mode 100644 index 0000000..8f0916f --- /dev/null +++ b/rose-py/rose/.version @@ -0,0 +1 @@ +0.5.0 diff --git a/rose/__init__.py b/rose-py/rose/__init__.py similarity index 100% rename from rose/__init__.py rename to rose-py/rose/__init__.py diff --git a/rose/audiotags.py b/rose-py/rose/audiotags.py similarity index 100% rename from rose/audiotags.py rename to rose-py/rose/audiotags.py diff --git a/rose/audiotags_test.py b/rose-py/rose/audiotags_test.py similarity index 100% rename from rose/audiotags_test.py rename to rose-py/rose/audiotags_test.py diff --git a/rose/cache.py b/rose-py/rose/cache.py similarity index 100% rename from rose/cache.py rename to rose-py/rose/cache.py diff --git a/rose/cache.sql b/rose-py/rose/cache.sql similarity index 100% rename from rose/cache.sql rename to rose-py/rose/cache.sql diff --git a/rose/cache_test.py b/rose-py/rose/cache_test.py similarity index 100% rename from rose/cache_test.py rename to rose-py/rose/cache_test.py diff --git a/rose/collages.py b/rose-py/rose/collages.py similarity index 100% rename from rose/collages.py rename to rose-py/rose/collages.py diff --git a/rose/collages_test.py b/rose-py/rose/collages_test.py similarity index 100% rename from rose/collages_test.py rename to rose-py/rose/collages_test.py diff --git a/rose/common.py b/rose-py/rose/common.py similarity index 100% rename from rose/common.py rename to rose-py/rose/common.py diff --git a/rose/config.py b/rose-py/rose/config.py similarity index 100% rename from rose/config.py rename to rose-py/rose/config.py diff --git a/rose/config_test.py b/rose-py/rose/config_test.py similarity index 100% rename from rose/config_test.py rename to rose-py/rose/config_test.py diff --git a/rose/ffi.py b/rose-py/rose/ffi.py similarity index 100% rename from rose/ffi.py rename to rose-py/rose/ffi.py diff --git a/rose/genre_hierarchy.py b/rose-py/rose/genre_hierarchy.py similarity index 100% rename from rose/genre_hierarchy.py rename to rose-py/rose/genre_hierarchy.py diff --git a/rose/playlists.py b/rose-py/rose/playlists.py similarity index 100% rename from rose/playlists.py rename to rose-py/rose/playlists.py diff --git a/rose/playlists_test.py b/rose-py/rose/playlists_test.py similarity index 100% rename from rose/playlists_test.py rename to rose-py/rose/playlists_test.py diff --git a/rose/releases.py b/rose-py/rose/releases.py similarity index 100% rename from rose/releases.py rename to rose-py/rose/releases.py diff --git a/rose/releases_test.py b/rose-py/rose/releases_test.py similarity index 100% rename from rose/releases_test.py rename to rose-py/rose/releases_test.py diff --git a/rose/rule_parser.py b/rose-py/rose/rule_parser.py similarity index 100% rename from rose/rule_parser.py rename to rose-py/rose/rule_parser.py diff --git a/rose/rule_parser_test.py b/rose-py/rose/rule_parser_test.py similarity index 100% rename from rose/rule_parser_test.py rename to rose-py/rose/rule_parser_test.py diff --git a/rose/rules.py b/rose-py/rose/rules.py similarity index 100% rename from rose/rules.py rename to rose-py/rose/rules.py diff --git a/rose/rules_test.py b/rose-py/rose/rules_test.py similarity index 100% rename from rose/rules_test.py rename to rose-py/rose/rules_test.py diff --git a/rose/templates.py b/rose-py/rose/templates.py similarity index 100% rename from rose/templates.py rename to rose-py/rose/templates.py diff --git a/rose/templates_test.py b/rose-py/rose/templates_test.py similarity index 100% rename from rose/templates_test.py rename to rose-py/rose/templates_test.py diff --git a/rose/tracks.py b/rose-py/rose/tracks.py similarity index 100% rename from rose/tracks.py rename to rose-py/rose/tracks.py diff --git a/rose/tracks_test.py b/rose-py/rose/tracks_test.py similarity index 100% rename from rose/tracks_test.py rename to rose-py/rose/tracks_test.py diff --git a/setup.py b/rose-py/setup.py similarity index 78% rename from setup.py rename to rose-py/setup.py index 49aafa9..6b6d7d3 100644 --- a/setup.py +++ b/rose-py/setup.py @@ -10,8 +10,7 @@ author="blissful", author_email="blissful@sunsetglow.net", license="Apache-2.0", - entry_points={"console_scripts": ["rose = rose_cli.__main__:main"]}, - packages=setuptools.find_namespace_packages(where="."), + packages=["rose"], package_data={"rose": ["*.sql", ".version"]}, install_requires=[ "appdirs", diff --git a/rose-vfs/.version b/rose-vfs/.version new file mode 100644 index 0000000..8f0916f --- /dev/null +++ b/rose-vfs/.version @@ -0,0 +1 @@ +0.5.0 diff --git a/rose-vfs/default.nix b/rose-vfs/default.nix new file mode 100644 index 0000000..8e9bbb1 --- /dev/null +++ b/rose-vfs/default.nix @@ -0,0 +1,16 @@ +{ python-pin +, version +, py-deps +, rose-py +}: + +python-pin.pkgs.buildPythonPackage { + pname = "rose-vfs"; + version = version; + src = ./.; + propagatedBuildInputs = [ + rose-py + py-deps.llfuse + ]; + doCheck = false; +} diff --git a/rose_vfs/__init__.py b/rose-vfs/rose_vfs/__init__.py similarity index 99% rename from rose_vfs/__init__.py rename to rose-vfs/rose_vfs/__init__.py index e342445..30b1a01 100644 --- a/rose_vfs/__init__.py +++ b/rose-vfs/rose_vfs/__init__.py @@ -1,4 +1,5 @@ from rose import initialize_logging + from rose_vfs.virtualfs import mount_virtualfs, unmount_virtualfs __all__ = [ diff --git a/rose_vfs/virtualfs.py b/rose-vfs/rose_vfs/virtualfs.py similarity index 99% rename from rose_vfs/virtualfs.py rename to rose-vfs/rose_vfs/virtualfs.py index eb52ea1..b1d86b8 100644 --- a/rose_vfs/virtualfs.py +++ b/rose-vfs/rose_vfs/virtualfs.py @@ -54,7 +54,6 @@ from typing import Any, Generic, Literal, TypeVar import llfuse - from rose import ( SUPPORTED_AUDIO_EXTENSIONS, AudioTags, diff --git a/rose_vfs/virtualfs_test.py b/rose-vfs/rose_vfs/virtualfs_test.py similarity index 100% rename from rose_vfs/virtualfs_test.py rename to rose-vfs/rose_vfs/virtualfs_test.py index 4a145a6..b04d4de 100644 --- a/rose_vfs/virtualfs_test.py +++ b/rose-vfs/rose_vfs/virtualfs_test.py @@ -8,9 +8,9 @@ from pathlib import Path import pytest +from rose import AudioTags, Config from conftest import retry_for_sec -from rose import AudioTags, Config from rose_vfs.virtualfs import ALL_TRACKS, mount_virtualfs, unmount_virtualfs R1_VNAME = "Techno Man & Bass Man - 2023. Release 1" diff --git a/rose-vfs/setup.py b/rose-vfs/setup.py new file mode 100644 index 0000000..35ba269 --- /dev/null +++ b/rose-vfs/setup.py @@ -0,0 +1,18 @@ +import setuptools + +with open(".version") as f: + version = f.read().strip() + +setuptools.setup( + name="rose-vfs", + version=version, + python_requires=">=3.11.0", + author="blissful", + author_email="blissful@sunsetglow.net", + license="Apache-2.0", + packages=["rose_vfs"], + install_requires=[ + "rose", + "llfuse", + ], +) diff --git a/rose-watchdog/.version b/rose-watchdog/.version new file mode 100644 index 0000000..8f0916f --- /dev/null +++ b/rose-watchdog/.version @@ -0,0 +1 @@ +0.5.0 diff --git a/rose-watchdog/default.nix b/rose-watchdog/default.nix new file mode 100644 index 0000000..11877b1 --- /dev/null +++ b/rose-watchdog/default.nix @@ -0,0 +1,16 @@ +{ python-pin +, version +, py-deps +, rose-py +}: + +python-pin.pkgs.buildPythonPackage { + pname = "rose-watchdog"; + version = version; + src = ./.; + propagatedBuildInputs = [ + rose-py + py-deps.watchdog + ]; + doCheck = false; +} diff --git a/rose_watchdog/__init__.py b/rose-watchdog/rose_watchdog/__init__.py similarity index 99% rename from rose_watchdog/__init__.py rename to rose-watchdog/rose_watchdog/__init__.py index 4744230..77dfbde 100644 --- a/rose_watchdog/__init__.py +++ b/rose-watchdog/rose_watchdog/__init__.py @@ -1,4 +1,5 @@ from rose import initialize_logging + from rose_watchdog.watcher import start_watchdog __all__ = [ diff --git a/rose_watchdog/watcher.py b/rose-watchdog/rose_watchdog/watcher.py similarity index 99% rename from rose_watchdog/watcher.py rename to rose-watchdog/rose_watchdog/watcher.py index 5317a11..8cdd6d9 100644 --- a/rose_watchdog/watcher.py +++ b/rose-watchdog/rose_watchdog/watcher.py @@ -29,13 +29,6 @@ from queue import Empty, Queue from typing import Literal -from watchdog.events import ( - FileSystemEvent, - FileSystemEventHandler, - FileSystemMovedEvent, -) -from watchdog.observers import Observer - from rose import ( Config, update_cache_evict_nonexistent_collages, @@ -45,6 +38,12 @@ update_cache_for_playlists, update_cache_for_releases, ) +from watchdog.events import ( + FileSystemEvent, + FileSystemEventHandler, + FileSystemMovedEvent, +) +from watchdog.observers import Observer logger = logging.getLogger(__name__) diff --git a/rose_watchdog/watcher_test.py b/rose-watchdog/rose_watchdog/watcher_test.py similarity index 99% rename from rose_watchdog/watcher_test.py rename to rose-watchdog/rose_watchdog/watcher_test.py index ba0af11..a0c1337 100644 --- a/rose_watchdog/watcher_test.py +++ b/rose-watchdog/rose_watchdog/watcher_test.py @@ -4,9 +4,10 @@ from contextlib import contextmanager from multiprocessing import Process -from conftest import TEST_COLLAGE_1, TEST_PLAYLIST_1, TEST_RELEASE_2, TEST_RELEASE_3, retry_for_sec from rose import Config from rose.cache import connect + +from conftest import TEST_COLLAGE_1, TEST_PLAYLIST_1, TEST_RELEASE_2, TEST_RELEASE_3, retry_for_sec from rose_watchdog.watcher import start_watchdog diff --git a/rose-watchdog/setup.py b/rose-watchdog/setup.py new file mode 100644 index 0000000..a718478 --- /dev/null +++ b/rose-watchdog/setup.py @@ -0,0 +1,18 @@ +import setuptools + +with open(".version") as f: + version = f.read().strip() + +setuptools.setup( + name="rose-watchdog", + version=version, + python_requires=">=3.11.0", + author="blissful", + author_email="blissful@sunsetglow.net", + license="Apache-2.0", + packages=["rose_watchdog"], + install_requires=[ + "rose", + "watchdog", + ], +) diff --git a/rose_zig/build.zig b/rose-zig/build.zig similarity index 100% rename from rose_zig/build.zig rename to rose-zig/build.zig diff --git a/rose_zig/default.nix b/rose-zig/default.nix similarity index 100% rename from rose_zig/default.nix rename to rose-zig/default.nix diff --git a/rose_zig/src/ffi.zig b/rose-zig/src/ffi.zig similarity index 100% rename from rose_zig/src/ffi.zig rename to rose-zig/src/ffi.zig diff --git a/rose_zig/src/rose.zig b/rose-zig/src/rose.zig similarity index 100% rename from rose_zig/src/rose.zig rename to rose-zig/src/rose.zig diff --git a/bump_version.sh b/scripts/bump_version.sh similarity index 86% rename from bump_version.sh rename to scripts/bump_version.sh index fbd0da7..677ad90 100755 --- a/bump_version.sh +++ b/scripts/bump_version.sh @@ -9,7 +9,7 @@ message="$2" # Fail if the branch is dirty. git diff --exit-code -echo "$version" > "$ROSE_ROOT/rose/.version" +fd -u '^.version$' | xargs -I{} sh -c "echo $version > "'"$1"' -- {} git add . git commit -am "[Release] v$version - $message" git tag "v$version" HEAD -m "v$version" diff --git a/scripts/rym-genres/generate.py b/scripts/rym-genres/generate.py index 8bb8511..531f90d 100755 --- a/scripts/rym-genres/generate.py +++ b/scripts/rym-genres/generate.py @@ -1,6 +1,8 @@ #!/usr/bin/env python import logging +import os +import subprocess import sys from dataclasses import dataclass from pathlib import Path @@ -135,7 +137,8 @@ def __repr__(self) -> str: continue IMMEDIATE_CHILDREN[g.name] = sorted({x.name for x in g.children} - BLACKLISTED) -with open("genres.gen.py", "w") as fp: +OUT_PATH = Path(os.environ["ROSE_ROOT"]) / "rose-py" / "rose" / "genre_hierarchy.py" +with OUT_PATH.open("w") as fp: fp.write(f"""\ # THIS FILE WAS GENERATED BY scripts/rym-genres/generate.py. DO NOT EDIT. @@ -145,3 +148,4 @@ def __repr__(self) -> str: IMMEDIATE_CHILD_GENRES: dict[str, list[str]] = {repr(IMMEDIATE_CHILDREN)} """) +subprocess.run(["ruff", "format", str(OUT_PATH)])