From 0fc87bb1c477bd587c43c8e354298fc16b144e40 Mon Sep 17 00:00:00 2001 From: NextFire Date: Tue, 15 Oct 2024 21:38:33 +0200 Subject: [PATCH] move cli to separate package --- README.md | 2 +- pyproject.toml | 19 +++++--- uv.lock | 45 ++++++++++++++----- yohane-cli/.python-version | 1 + yohane-cli/pyproject.toml | 16 +++++++ yohane-cli/yohane_cli/__init__.py | 5 +++ {yohane => yohane-cli/yohane_cli}/__main__.py | 2 +- {yohane => yohane-cli/yohane_cli}/app.py | 0 yohane/__init__.py | 2 - yohane/utils.py | 2 +- 10 files changed, 73 insertions(+), 21 deletions(-) create mode 100644 yohane-cli/.python-version create mode 100644 yohane-cli/pyproject.toml create mode 100644 yohane-cli/yohane_cli/__init__.py rename {yohane => yohane-cli/yohane_cli}/__main__.py (55%) rename {yohane => yohane-cli/yohane_cli}/app.py (100%) diff --git a/README.md b/README.md index ddeeebec..d4d55a39 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ The full pipeline will be completed in less than a minute in their environment. - [FFmpeg](https://ffmpeg.org): optional, for better codecs support on macOS/Linux (only versions [>=4.4,<7 are supported by torchaudio](https://pytorch.org/audio/main/installation.html#optional-dependencies)) ```sh -uvx --from git+https://github.com/Japan7/yohane.git --python 3.11 yohane --help +uvx --from git+https://github.com/Japan7/yohane.git[cli] --python 3.11 yohane --help ``` ## Caveats diff --git a/pyproject.toml b/pyproject.toml index 4db187ac..153d8f00 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,27 +4,34 @@ version = "2024.10.7-dev" description = "Forced alignment for karaokes" readme = "README.md" license = { file = "LICENSE" } -requires-python = ">=3.10,<4" +authors = [ + { name = "NextFire", email = "git@yuru.moe" }, + { name = "Voltini", email = "slimen3@hotmail.fr" }, +] +requires-python = ">=3.10" dependencies = [ "torch>=2.1,<3", "torchaudio>=2.1,<3", "vocal-remover", "pysubs2==1.7.3", "regex==2024.9.11", - "typer-slim[standard]==0.12.5", ] +[project.optional-dependencies] +cli = ["yohane-cli"] + [tool.uv] dev-dependencies = ["pyright==1.1.384", "ruff==0.6.9"] [tool.uv.sources] +yohane-cli = { workspace = true } vocal-remover = { git = "https://github.com/Japan7/vocal-remover.git", branch = "6.0.0b4" } -[project.urls] -homepage = "https://github.com/Japan7/yohane" +[tool.uv.workspace] +members = ["yohane-cli"] -[project.scripts] -yohane = "yohane:app" +[project.urls] +Homepage = "https://github.com/Japan7/yohane" [build-system] requires = ["hatchling"] diff --git a/uv.lock b/uv.lock index f1856d4f..b10133a5 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,5 @@ version = 1 -requires-python = ">=3.10, <4" +requires-python = ">=3.10" resolution-markers = [ "python_full_version < '3.11' and platform_system == 'Darwin'", "python_full_version < '3.11' and platform_machine == 'aarch64' and platform_system == 'Linux'", @@ -9,6 +9,12 @@ resolution-markers = [ "(python_full_version >= '3.11' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version >= '3.11' and platform_system != 'Darwin' and platform_system != 'Linux')", ] +[manifest] +members = [ + "yohane", + "yohane-cli", +] + [[package]] name = "audioread" version = "3.0.1" @@ -769,7 +775,7 @@ name = "nvidia-cudnn-cu12" version = "9.1.0.70" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "nvidia-cublas-cu12" }, + { name = "nvidia-cublas-cu12", marker = "(platform_machine != 'aarch64' and platform_system != 'Darwin') or (platform_system != 'Darwin' and platform_system != 'Linux')" }, ] wheels = [ { url = "https://files.pythonhosted.org/packages/9f/fd/713452cd72343f682b1c7b9321e23829f00b842ceaedcda96e742ea0b0b3/nvidia_cudnn_cu12-9.1.0.70-py3-none-manylinux2014_x86_64.whl", hash = "sha256:165764f44ef8c61fcdfdfdbe769d687e06374059fbb388b6c89ecb0e28793a6f", size = 664752741 }, @@ -796,9 +802,9 @@ name = "nvidia-cusolver-cu12" version = "11.4.5.107" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "nvidia-cublas-cu12" }, - { name = "nvidia-cusparse-cu12" }, - { name = "nvidia-nvjitlink-cu12" }, + { name = "nvidia-cublas-cu12", marker = "(platform_machine != 'aarch64' and platform_system != 'Darwin') or (platform_system != 'Darwin' and platform_system != 'Linux')" }, + { name = "nvidia-cusparse-cu12", marker = "(platform_machine != 'aarch64' and platform_system != 'Darwin') or (platform_system != 'Darwin' and platform_system != 'Linux')" }, + { name = "nvidia-nvjitlink-cu12", marker = "(platform_machine != 'aarch64' and platform_system != 'Darwin') or (platform_system != 'Darwin' and platform_system != 'Linux')" }, ] wheels = [ { url = "https://files.pythonhosted.org/packages/bc/1d/8de1e5c67099015c834315e333911273a8c6aaba78923dd1d1e25fc5f217/nvidia_cusolver_cu12-11.4.5.107-py3-none-manylinux1_x86_64.whl", hash = "sha256:8a7ec542f0412294b15072fa7dab71d31334014a69f953004ea7a118206fe0dd", size = 124161928 }, @@ -809,7 +815,7 @@ name = "nvidia-cusparse-cu12" version = "12.1.0.106" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "nvidia-nvjitlink-cu12" }, + { name = "nvidia-nvjitlink-cu12", marker = "(platform_machine != 'aarch64' and platform_system != 'Darwin') or (platform_system != 'Darwin' and platform_system != 'Linux')" }, ] wheels = [ { url = "https://files.pythonhosted.org/packages/65/5b/cfaeebf25cd9fdec14338ccb16f6b2c4c7fa9163aefcf057d86b9cc248bb/nvidia_cusparse_cu12-12.1.0.106-py3-none-manylinux1_x86_64.whl", hash = "sha256:f3b50f42cf363f86ab21f720998517a659a48131e8d538dc02f8768237bd884c", size = 195958278 }, @@ -1384,7 +1390,7 @@ name = "triton" version = "3.0.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "filelock" }, + { name = "filelock", marker = "(platform_machine != 'aarch64' and platform_system != 'Darwin') or (platform_system != 'Darwin' and platform_system != 'Linux')" }, ] wheels = [ { url = "https://files.pythonhosted.org/packages/45/27/14cc3101409b9b4b9241d2ba7deaa93535a217a211c86c4cc7151fb12181/triton-3.0.0-1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:e1efef76935b2febc365bfadf74bcb65a6f959a9872e5bddf44cc9e0adce1e1a", size = 209376304 }, @@ -1445,17 +1451,21 @@ dependencies = [ [[package]] name = "yohane" -version = "2024.10.6.dev0" +version = "2024.10.7.dev0" source = { editable = "." } dependencies = [ { name = "pysubs2" }, { name = "regex" }, { name = "torch" }, { name = "torchaudio" }, - { name = "typer-slim", extra = ["standard"] }, { name = "vocal-remover" }, ] +[package.optional-dependencies] +cli = [ + { name = "yohane-cli" }, +] + [package.dev-dependencies] dev = [ { name = "pyright" }, @@ -1468,8 +1478,8 @@ requires-dist = [ { name = "regex", specifier = "==2024.9.11" }, { name = "torch", specifier = ">=2.1,<3" }, { name = "torchaudio", specifier = ">=2.1,<3" }, - { name = "typer-slim", extras = ["standard"], specifier = "==0.12.5" }, { name = "vocal-remover", git = "https://github.com/Japan7/vocal-remover.git?branch=6.0.0b4" }, + { name = "yohane-cli", marker = "extra == 'cli'", editable = "yohane-cli" }, ] [package.metadata.requires-dev] @@ -1477,3 +1487,18 @@ dev = [ { name = "pyright", specifier = "==1.1.384" }, { name = "ruff", specifier = "==0.6.9" }, ] + +[[package]] +name = "yohane-cli" +version = "0.1.0" +source = { editable = "yohane-cli" } +dependencies = [ + { name = "typer-slim", extra = ["standard"] }, + { name = "yohane" }, +] + +[package.metadata] +requires-dist = [ + { name = "typer-slim", extras = ["standard"], specifier = "==0.12.5" }, + { name = "yohane", editable = "." }, +] diff --git a/yohane-cli/.python-version b/yohane-cli/.python-version new file mode 100644 index 00000000..2c073331 --- /dev/null +++ b/yohane-cli/.python-version @@ -0,0 +1 @@ +3.11 diff --git a/yohane-cli/pyproject.toml b/yohane-cli/pyproject.toml new file mode 100644 index 00000000..db818fb9 --- /dev/null +++ b/yohane-cli/pyproject.toml @@ -0,0 +1,16 @@ +[project] +name = "yohane-cli" +version = "0.1.0" +authors = [{ name = "NextFire", email = "git@yuru.moe" }] +requires-python = ">=3.10" +dependencies = ["yohane", "typer-slim[standard]==0.12.5"] + +[tool.uv.sources] +yohane = { workspace = true } + +[project.scripts] +yohane = "yohane_cli:app" + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" diff --git a/yohane-cli/yohane_cli/__init__.py b/yohane-cli/yohane_cli/__init__.py new file mode 100644 index 00000000..9a7d069e --- /dev/null +++ b/yohane-cli/yohane_cli/__init__.py @@ -0,0 +1,5 @@ +from yohane_cli.app import app + +__all__ = [ + "app", +] diff --git a/yohane/__main__.py b/yohane-cli/yohane_cli/__main__.py similarity index 55% rename from yohane/__main__.py rename to yohane-cli/yohane_cli/__main__.py index 2bb786ce..935c6540 100644 --- a/yohane/__main__.py +++ b/yohane-cli/yohane_cli/__main__.py @@ -1,4 +1,4 @@ -from yohane.app import app +from yohane_cli.app import app if __name__ == "__main__": app() diff --git a/yohane/app.py b/yohane-cli/yohane_cli/app.py similarity index 100% rename from yohane/app.py rename to yohane-cli/yohane_cli/app.py diff --git a/yohane/__init__.py b/yohane/__init__.py index 68739bc0..19e905af 100644 --- a/yohane/__init__.py +++ b/yohane/__init__.py @@ -1,7 +1,5 @@ -from yohane.app import app from yohane.pipeline import Yohane __all__ = [ - "app", "Yohane", ] diff --git a/yohane/utils.py b/yohane/utils.py index 2f593d29..6c96c353 100644 --- a/yohane/utils.py +++ b/yohane/utils.py @@ -8,6 +8,6 @@ def get_identifier(): pkg_meta = metadata(__package__) identifier = f"{pkg_meta['Name']} {pkg_meta['Version']}" if urls := pkg_meta["Project-URL"]: - if parsed := re.search(r"homepage, (\S+)\b", urls): + if parsed := re.search(r"Homepage, (\S+)\b", urls): identifier += f" ({parsed.group(1)})" return identifier