From 1b9ec4bc0721bae3917f0cee2c779242555cc1c8 Mon Sep 17 00:00:00 2001 From: Chidi Williams Date: Sun, 24 Mar 2024 18:12:14 +0000 Subject: [PATCH 1/5] feat: add macOS build --- .github/workflows/ci.yml | 21 ++++++++++++++++++ Buzz.spec | 4 ++-- buzz/assets.py | 10 ++++++--- buzz/buzz.py | 9 ++++---- poetry.lock | 47 +++++++++++++++++++++++----------------- pyproject.toml | 4 ++-- 6 files changed, 64 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b4ea0d318..f9961eb384 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,7 @@ jobs: fail-fast: false matrix: include: + - os: macos-latest - os: windows-latest - os: ubuntu-20.04 - os: ubuntu-22.04 @@ -85,6 +86,7 @@ jobs: fail-fast: false matrix: include: + - os: macos-latest - os: windows-latest steps: - uses: actions/checkout@v3 @@ -216,6 +218,7 @@ jobs: fail-fast: false matrix: include: + - os: macos-latest - os: windows-latest needs: [ build, test ] if: startsWith(github.ref, 'refs/tags/') @@ -239,3 +242,21 @@ jobs: Buzz*-unix.tar.gz Buzz*-windows.exe Buzz*-mac.dmg + + deploy_brew_cask: + runs-on: macos-latest + needs: [ release ] + if: startsWith(github.ref, 'refs/tags/') + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + - name: Install Poetry Action + uses: snok/install-poetry@v1.3.1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + - name: Upload to Brew + run: make upload_brew + env: + HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} diff --git a/Buzz.spec b/Buzz.spec index c4bf7d611c..8619c0d59b 100644 --- a/Buzz.spec +++ b/Buzz.spec @@ -79,8 +79,8 @@ exe = EXE( disable_windowed_traceback=False, argv_emulation=False, target_arch=None, - codesign_identity=None, - entitlements_file=None, + codesign_identity=os.environ.get("BUZZ_CODESIGN_IDENTITY"), + entitlements_file="entitlements.plist" if platform.system() == "Darwin" else None, ) coll = COLLECT( exe, diff --git a/buzz/assets.py b/buzz/assets.py index cefea00c75..1b752a18b3 100644 --- a/buzz/assets.py +++ b/buzz/assets.py @@ -1,8 +1,12 @@ import os import sys +APP_BASE_DIR = ( + getattr(sys, "_MEIPASS", os.path.dirname(os.path.abspath(__file__))) + if getattr(sys, "frozen", False) + else os.path.dirname(__file__) +) + def get_path(path: str): - if getattr(sys, "frozen", False): - return os.path.join(os.path.dirname(sys.executable), path) - return os.path.join(os.path.dirname(__file__), path) + return os.path.join(APP_BASE_DIR, path) diff --git a/buzz/buzz.py b/buzz/buzz.py index 256bcd0dfb..6a648ae885 100644 --- a/buzz/buzz.py +++ b/buzz/buzz.py @@ -8,6 +8,8 @@ from platformdirs import user_log_dir +from buzz.assets import APP_BASE_DIR + # Check for segfaults if not running in frozen mode if getattr(sys, "frozen", False) is False: faulthandler.enable() @@ -19,12 +21,11 @@ # Adds the current directory to the PATH, so the ffmpeg binary get picked up: # https://stackoverflow.com/a/44352931/9830227 -app_dir = getattr(sys, "_MEIPASS", os.path.dirname(os.path.abspath(__file__))) -os.environ["PATH"] += os.pathsep + app_dir +os.environ["PATH"] += os.pathsep + APP_BASE_DIR # Add the app directory to the DLL list: https://stackoverflow.com/a/64303856 if platform.system() == "Windows": - os.add_dll_directory(app_dir) + os.add_dll_directory(APP_BASE_DIR) def main(): @@ -47,7 +48,7 @@ def main(): format=log_format, ) - logging.debug("app_dir: %s", app_dir) + logging.debug("app_dir: %s", APP_BASE_DIR) if getattr(sys, "frozen", False) is False: stdout_handler = logging.StreamHandler(sys.stdout) diff --git a/poetry.lock b/poetry.lock index 31b4a11713..d86b2d5677 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1972,48 +1972,55 @@ typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0" [[package]] name = "pyinstaller" -version = "5.13.2" +version = "6.5.0" description = "PyInstaller bundles a Python application and all its dependencies into a single package." optional = false -python-versions = "<3.13,>=3.7" +python-versions = "<3.13,>=3.8" files = [ - { file = "pyinstaller-5.13.2-py3-none-macosx_10_13_universal2.whl", hash = "sha256:16cbd66b59a37f4ee59373a003608d15df180a0d9eb1a29ff3bfbfae64b23d0f" }, - { file = "pyinstaller-5.13.2-py3-none-manylinux2014_aarch64.whl", hash = "sha256:8f6dd0e797ae7efdd79226f78f35eb6a4981db16c13325e962a83395c0ec7420" }, - { file = "pyinstaller-5.13.2-py3-none-manylinux2014_i686.whl", hash = "sha256:65133ed89467edb2862036b35d7c5ebd381670412e1e4361215e289c786dd4e6" }, - { file = "pyinstaller-5.13.2-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:7d51734423685ab2a4324ab2981d9781b203dcae42839161a9ee98bfeaabdade" }, - { file = "pyinstaller-5.13.2-py3-none-manylinux2014_s390x.whl", hash = "sha256:2c2fe9c52cb4577a3ac39626b84cf16cf30c2792f785502661286184f162ae0d" }, - { file = "pyinstaller-5.13.2-py3-none-manylinux2014_x86_64.whl", hash = "sha256:c63ef6133eefe36c4b2f4daf4cfea3d6412ece2ca218f77aaf967e52a95ac9b8" }, - { file = "pyinstaller-5.13.2-py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:aadafb6f213549a5906829bb252e586e2cf72a7fbdb5731810695e6516f0ab30" }, - { file = "pyinstaller-5.13.2-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:b2e1c7f5cceb5e9800927ddd51acf9cc78fbaa9e79e822c48b0ee52d9ce3c892" }, - { file = "pyinstaller-5.13.2-py3-none-win32.whl", hash = "sha256:421cd24f26144f19b66d3868b49ed673176765f92fa9f7914cd2158d25b6d17e" }, - { file = "pyinstaller-5.13.2-py3-none-win_amd64.whl", hash = "sha256:ddcc2b36052a70052479a9e5da1af067b4496f43686ca3cdda99f8367d0627e4" }, - { file = "pyinstaller-5.13.2-py3-none-win_arm64.whl", hash = "sha256:27cd64e7cc6b74c5b1066cbf47d75f940b71356166031deb9778a2579bb874c6" }, - { file = "pyinstaller-5.13.2.tar.gz", hash = "sha256:c8e5d3489c3a7cc5f8401c2d1f48a70e588f9967e391c3b06ddac1f685f8d5d2" }, + { file = "pyinstaller-6.5.0-py3-none-macosx_10_13_universal2.whl", hash = "sha256:81ec15c0deb8c7a0f95bea85b49eecc2df1bdeaf5fe487a41d97de6b0ad29dff" }, + { file = "pyinstaller-6.5.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:5f432f3fdef053989e0a44134e483131c533dab7637e6afd80c3f7c26e6dbcc9" }, + { file = "pyinstaller-6.5.0-py3-none-manylinux2014_i686.whl", hash = "sha256:6ffd76a0194dac4df5e66dcfccc7b597f3eaa40ef9a3f63548f260aa2c187512" }, + { file = "pyinstaller-6.5.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:a54968df2228f0128607b1dced41bbff94149d459987fb5cd1a41893e9bb85df" }, + { file = "pyinstaller-6.5.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:0dae0edbe6d667b6b0ccd8c97a148f86474a82da7ce582296f9025f4c7242ec6" }, + { file = "pyinstaller-6.5.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:7c76bfcb624803c311fa8fb137e4780d0ec86d11b7d90a8f43f185e2554afdcc" }, + { file = "pyinstaller-6.5.0-py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:6cfee8a74ea2d3a1dc8e99e732a87b314739dc14363778143caac31f8aee9039" }, + { file = "pyinstaller-6.5.0-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:9d828213aea5401bb33a36ca396f8dc76a59a25bce1d76a13c9ad94ba29fbe42" }, + { file = "pyinstaller-6.5.0-py3-none-win32.whl", hash = "sha256:61865eee5e0d8f8252722f6d001baec497b7cee79ebe62c33a6ba86ba0c7010d" }, + { file = "pyinstaller-6.5.0-py3-none-win_amd64.whl", hash = "sha256:e1266498893ce1d6cc7337e8d2acbf7905a10ed2b7c8377270117d6b7b922fc4" }, + { file = "pyinstaller-6.5.0-py3-none-win_arm64.whl", hash = "sha256:1b3b7d6d3b18d76a833fd5a4d7f4544c5e2c2a4db4a728ea191e62f69d5cc33c" }, + { file = "pyinstaller-6.5.0.tar.gz", hash = "sha256:b1e55113c5a40cb7041c908a57f212f3ebd3e444dbb245ca2f91d86a76dabec5" }, ] [package.dependencies] altgraph = "*" +importlib-metadata = { version = ">=4.6", markers = "python_version < \"3.10\"" } macholib = { version = ">=1.8", markers = "sys_platform == \"darwin\"" } +packaging = ">=22.0" pefile = { version = ">=2022.5.30", markers = "sys_platform == \"win32\"" } -pyinstaller-hooks-contrib = ">=2021.4" +pyinstaller-hooks-contrib = ">=2024.3" pywin32-ctypes = { version = ">=0.2.1", markers = "sys_platform == \"win32\"" } setuptools = ">=42.0.0" [package.extras] -encryption = ["tinyaes (>=1.0.0)"] +completion = ["argcomplete"] hook-testing = ["execnet (>=1.5.0)", "psutil", "pytest (>=2.7.3)"] [[package]] name = "pyinstaller-hooks-contrib" -version = "2023.11" +version = "2024.3" description = "Community maintained hooks for PyInstaller" optional = false python-versions = ">=3.7" files = [ - { file = "pyinstaller-hooks-contrib-2023.11.tar.gz", hash = "sha256:5dd7a8a054a65c19cdaa381cabcfbe76f44d5f88d18214b0c570a0cd139be77f" }, - { file = "pyinstaller_hooks_contrib-2023.11-py2.py3-none-any.whl", hash = "sha256:f2a75dac2968ec81f92dcd3768906f654fa4204bc496126ae8483e87a5d89602" }, + { file = "pyinstaller-hooks-contrib-2024.3.tar.gz", hash = "sha256:d18657c29267c63563a96b8fc78db6ba9ae40af6702acb2f8c871df12c75b60b" }, + { file = "pyinstaller_hooks_contrib-2024.3-py2.py3-none-any.whl", hash = "sha256:6701752d525e1f4eda1eaec2c2affc206171e15c7a4e188a152fcf3ed3308024" }, ] +[package.dependencies] +importlib-metadata = { version = ">=4.6", markers = "python_version < \"3.10\"" } +packaging = ">=22.0" +setuptools = ">=42.0.0" + [[package]] name = "pylint" version = "2.17.7" @@ -3375,4 +3382,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = ">=3.9.13,<3.11" -content-hash = "7a5d40b2f80f2f420312043cbc08b6da7303149c0a29044b17949cdfe39162e9" +content-hash = "76310fff48b11c0760d9e8e67978ff720f4893a3756d00a89aed2f5a5baafdf1" diff --git a/pyproject.toml b/pyproject.toml index 0ecaedea8f..39bc647358 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,10 +32,10 @@ transformers = { version = "^4.39.1", markers = "sys_platform != 'linux'" } [tool.poetry.group.dev.dependencies] autopep8 = "^1.7.0" -pyinstaller = "^5.4.1" +pyinstaller = "^6.5.0" # Lock to 2023.11 to fix error in 2023.12: # AttributeError: module 'dataclasses' has no attribute '__version__' -pyinstaller-hooks-contrib = "2023.11" +pyinstaller-hooks-contrib = "^2024.3" six = "^1.16.0" pytest = "^7.1.3" pytest-cov = "^4.0.0" From 60fc446c34147c64fdd8c5ed7d3ef86fad1128c5 Mon Sep 17 00:00:00 2001 From: Chidi Williams Date: Sun, 24 Mar 2024 20:31:51 +0000 Subject: [PATCH 2/5] feat: add macOS build --- tests/transformers_whisper_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/transformers_whisper_test.py b/tests/transformers_whisper_test.py index ef700f3026..552bb77e96 100644 --- a/tests/transformers_whisper_test.py +++ b/tests/transformers_whisper_test.py @@ -1,3 +1,4 @@ +import platform import sys import pytest @@ -6,7 +7,10 @@ from tests.audio import test_audio_path -@pytest.mark.skipif(sys.platform == "linux", reason="Not supported on Linux") +@pytest.mark.skipif( + sys.platform == "linux" or platform.system() == "Darwin", + reason="Not supported on Linux", +) class TestTransformersWhisper: def test_should_transcribe(self): model = load_model("openai/whisper-tiny") From c4ae8cb5a2b8ac847171b4733bcf874ba6ed173b Mon Sep 17 00:00:00 2001 From: Chidi Williams Date: Sun, 24 Mar 2024 20:35:02 +0000 Subject: [PATCH 3/5] feat: add macOS build --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f9961eb384..18256495e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,7 @@ jobs: matrix: include: - os: macos-latest + - os: macos-14 - os: windows-latest - os: ubuntu-20.04 - os: ubuntu-22.04 @@ -87,6 +88,7 @@ jobs: matrix: include: - os: macos-latest + - os: macos-14 - os: windows-latest steps: - uses: actions/checkout@v3 From 136d6bfe6103fb077da06992cbc7c17d266283bc Mon Sep 17 00:00:00 2001 From: Chidi Williams Date: Sun, 24 Mar 2024 20:46:00 +0000 Subject: [PATCH 4/5] feat: add macOS build --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18256495e0..ae95c0ab9e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: "3.10.7" + python-version: "3.10.11" - name: Install Poetry Action uses: snok/install-poetry@v1.3.1 @@ -96,7 +96,7 @@ jobs: submodules: recursive - uses: actions/setup-python@v4 with: - python-version: "3.10.7" + python-version: "3.10.11" - name: Install Poetry Action uses: snok/install-poetry@v1.3.1 @@ -203,7 +203,7 @@ jobs: submodules: recursive - uses: actions/setup-python@v4 with: - python-version: "3.10.7" + python-version: "3.10.11" - name: Install Poetry Action uses: snok/install-poetry@v1.3.1 with: From c40f8ee5df2f6a657793612bba8f352bd073e5b0 Mon Sep 17 00:00:00 2001 From: Chidi Williams Date: Sun, 24 Mar 2024 20:50:24 +0000 Subject: [PATCH 5/5] feat: add macOS build --- .github/workflows/ci.yml | 8 +++----- Makefile | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae95c0ab9e..f9961eb384 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,6 @@ jobs: matrix: include: - os: macos-latest - - os: macos-14 - os: windows-latest - os: ubuntu-20.04 - os: ubuntu-22.04 @@ -31,7 +30,7 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: "3.10.11" + python-version: "3.10.7" - name: Install Poetry Action uses: snok/install-poetry@v1.3.1 @@ -88,7 +87,6 @@ jobs: matrix: include: - os: macos-latest - - os: macos-14 - os: windows-latest steps: - uses: actions/checkout@v3 @@ -96,7 +94,7 @@ jobs: submodules: recursive - uses: actions/setup-python@v4 with: - python-version: "3.10.11" + python-version: "3.10.7" - name: Install Poetry Action uses: snok/install-poetry@v1.3.1 @@ -203,7 +201,7 @@ jobs: submodules: recursive - uses: actions/setup-python@v4 with: - python-version: "3.10.11" + python-version: "3.10.7" - name: Install Poetry Action uses: snok/install-poetry@v1.3.1 with: diff --git a/Makefile b/Makefile index 37faa4299d..68aef38726 100644 --- a/Makefile +++ b/Makefile @@ -28,9 +28,9 @@ clean: rm -f buzz/whisper_cpp.py rm -rf dist/* || true -COVERAGE_THRESHOLD := 79 +COVERAGE_THRESHOLD := 80 ifeq ($(UNAME_S),Linux) - COVERAGE_THRESHOLD := 73 + COVERAGE_THRESHOLD := 74 endif test: buzz/whisper_cpp.py translation_mo