Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add macOS build #711

Merged
merged 5 commits into from
Mar 24, 2024
Merged
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
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: macos-latest
- os: windows-latest
- os: ubuntu-20.04
- os: ubuntu-22.04
Expand Down Expand Up @@ -85,6 +86,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: macos-latest
- os: windows-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -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/')
Expand All @@ -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/[email protected]
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 }}
4 changes: 2 additions & 2 deletions Buzz.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions buzz/assets.py
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 5 additions & 4 deletions buzz/buzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from platformdirs import user_log_dir

from buzz.assets import APP_BASE_DIR

Check warning on line 11 in buzz/buzz.py

View check run for this annotation

Codecov / codecov/patch

buzz/buzz.py#L11

Added line #L11 was not covered by tests

# Check for segfaults if not running in frozen mode
if getattr(sys, "frozen", False) is False:
faulthandler.enable()
Expand All @@ -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

Check warning on line 24 in buzz/buzz.py

View check run for this annotation

Codecov / codecov/patch

buzz/buzz.py#L24

Added line #L24 was not covered by tests

# 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)

Check warning on line 28 in buzz/buzz.py

View check run for this annotation

Codecov / codecov/patch

buzz/buzz.py#L28

Added line #L28 was not covered by tests


def main():
Expand All @@ -47,7 +48,7 @@
format=log_format,
)

logging.debug("app_dir: %s", app_dir)
logging.debug("app_dir: %s", APP_BASE_DIR)

Check warning on line 51 in buzz/buzz.py

View check run for this annotation

Codecov / codecov/patch

buzz/buzz.py#L51

Added line #L51 was not covered by tests

if getattr(sys, "frozen", False) is False:
stdout_handler = logging.StreamHandler(sys.stdout)
Expand Down
47 changes: 27 additions & 20 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion tests/transformers_whisper_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import platform
import sys

import pytest
Expand All @@ -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")
Expand Down
Loading