This repository has been archived by the owner on May 1, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
95 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
[misc] | ||
stable_version = "0.5.0" | ||
|
||
[tool.poetry] | ||
name = "whispering" | ||
version = "0.1.0" | ||
description = "" | ||
version = "0.5.0" | ||
description = "Streaming transcriber with whisper" | ||
license = "MIT" | ||
authors = ["Yuta Hayashibe <[email protected]>"] | ||
readme = "README.md" | ||
repository = "https://github.com/shirayu/whispering.git" | ||
packages = [{include = "whispering"}] | ||
|
||
[tool.poetry.dependencies] | ||
|
@@ -22,6 +27,7 @@ black = ">=22.8.0" | |
isort = ">=5.10.1" | ||
flake8 = ">=5.0.4" | ||
pydocstyle = ">=6.1.1" | ||
toml = "^0.10.2" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
|
@@ -30,3 +36,10 @@ build-backend = "poetry.core.masonry.api" | |
[tool.poetry.scripts] | ||
whispering = "whispering.cli:main" | ||
|
||
[tool.pyright] | ||
pythonVersion = "3.8" | ||
typeCheckingMode = "basic" | ||
exclude = [".venv", "**/node_modules", "**/__pycache__",] | ||
reportPrivateImportUsage = "information" | ||
reportUnusedVariable="warning" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import sys | ||
from pathlib import Path | ||
from typing import Final, Tuple | ||
|
||
import toml | ||
|
||
|
||
def get_stable_version(obj) -> str: | ||
stable_version: Final[str] = obj["misc"]["stable_version"] | ||
return f"v{stable_version}" | ||
|
||
|
||
def check_version(path_in: Path, path_pyproject_toml: Path) -> Tuple[bool, str]: | ||
with path_pyproject_toml.open() as f: | ||
obj = toml.load(f) | ||
stable_version: Final[str] = get_stable_version(obj) | ||
repository: Final[str] = obj["tool"]["poetry"]["repository"] | ||
cmd: Final[str] = f"pip install -U git+{repository}@{stable_version}" | ||
|
||
with path_in.open() as f: | ||
for line in f: | ||
if line.strip() == cmd: | ||
return True, stable_version | ||
|
||
sys.stderr.write(f"The following command not found in {path_in}: {cmd}\n") | ||
return False, stable_version | ||
|
||
|
||
def get_opts() -> argparse.Namespace: | ||
oparser = argparse.ArgumentParser() | ||
oparser.add_argument("--input", "-i", type=Path) | ||
oparser.add_argument("--toml", "-t", type=Path, required=True) | ||
oparser.add_argument("--tags", type=Path) | ||
return oparser.parse_args() | ||
|
||
|
||
def main() -> None: | ||
opts = get_opts() | ||
|
||
assert opts.input is not None | ||
ok, stable_version = check_version(opts.input, opts.toml) | ||
if not ok: | ||
sys.exit(1) | ||
|
||
if opts.tags: | ||
tags = [] | ||
with opts.tags.open() as f: | ||
for line in f: | ||
tags.append(line[:-1]) | ||
|
||
if stable_version not in tags: | ||
sys.stderr.write(f"Tag {stable_version} not in git tags: {tags}\n") | ||
sys.exit(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |