Skip to content

Commit

Permalink
Adding cibuildwheels to build wheels (#842)
Browse files Browse the repository at this point in the history
  • Loading branch information
raivisdejus authored Jul 30, 2024
1 parent 490aa7f commit 9877977
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 38 deletions.
65 changes: 44 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ jobs:
run: gem install fpm
if: "startsWith(matrix.os, 'ubuntu-')"

- name: Build Wheels
run: poetry build

- name: Bundle
run: |
if [ "$RUNNER_OS" == "macOS" ]; then
Expand Down Expand Up @@ -181,6 +178,7 @@ jobs:
elif [ "$RUNNER_OS" == "Windows" ]; then
cp -r ./dll_backup ./buzz/
poetry run make bundle_windows
fi
Expand All @@ -201,35 +199,57 @@ jobs:
path: |
dist/Buzz*-windows.exe
dist/Buzz*-mac.dmg
dist/buzz_*.whl
publish-pypi:
build_wheels:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
- os: windows-latest
- os: ubuntu-20.04
needs: [ build, test ]
if: startsWith(github.ref, 'refs/tags/')
# macos-13 is an intel runner, macos-14 is apple silicon
os: [ubuntu-latest, windows-latest, macos-13, macos-14]

steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-python@v5

- name: Copy Windows DLLs
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
cp -r ./dll_backup ./buzz/
fi
shell: bash

- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_WINDOWS: "auto"
CIBW_ARCHS_MACOS: "universal2"
CIBW_ARCHS_LINUX: "auto"

- uses: actions/upload-artifact@v4
with:
python-version: "3.11.9"
- name: Install Poetry Action
uses: snok/[email protected]
name: cibw-wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl

publish_pypi:
needs: [ build_wheels, test ]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v4
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Publish to PyPI
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
poetry publish --build --skip-existing
pattern: cibw-*
path: dist
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
password: ${{ secrets.PYPI_TOKEN }}

release:
runs-on: ${{ matrix.os }}
Expand All @@ -245,14 +265,17 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/download-artifact@v4
with:
name: Buzz-${{ runner.os }}

- name: Install Poetry Action
uses: snok/[email protected]
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Release
uses: softprops/action-gh-release@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snapcraft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
id: snapcraft
- run: |
sudo apt-get update
sudo apt-get install libportaudio2
sudo apt-get install libportaudio2 libtbb-dev
- run: sudo snap install --devmode *.snap
- run: |
cd $HOME
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ build/
htmlcov/
coverage.xml
.idea/
.venv/

# whisper_cpp
libwhisper.*
Expand All @@ -24,3 +25,4 @@ benchmarks.json
.eggs
*.egg-info
/coverage/
/wheelhouse/
8 changes: 8 additions & 0 deletions Buzz.spec
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ binaries = [
(shutil.which("ffprobe"), "."),
]

# Include dll_backup folder and its contents on Windows
if platform.system() == "Windows":
datas += [("dll_backup", "dll_backup")]

binaries.append(("dll_backup/SDL2.dll", "dll_backup"))
binaries.append(("dll_backup/whisper.dll", "dll_backup"))
binaries.append(("dll_backup/win32/whisper.dll", "dll_backup/win32"))

a = Analysis(
["main.py"],
pathex=[],
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Linux versions get also pushed to the snap. To install latest development versio
5. Install the dependencies `poetry install`
6. Install system dependencies you may be missing
```
sudo apt-get install --no-install-recommends libyaml-dev libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-shape0 libxcb-cursor0 libportaudio2 gettext libpulse0 ffmpeg
sudo apt-get install --no-install-recommends libyaml-dev libtbb-dev libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-shape0 libxcb-cursor0 libportaudio2 gettext libpulse0 ffmpeg
```
On versions prior to Ubuntu 24.04 install `sudo apt-get install --no-install-recommends libegl1-mesa`
7. Build Buzz `poetry build`
Expand Down Expand Up @@ -86,7 +86,7 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
7. Enter repo folder `cd buzz`
8. Copy `whisper.dll` from the repo backup to `buzz` folder.
```
cp .\dll_backup\*.dll .\buzz\
cp -r .\dll_backup\ .\buzz\
```
9. Activate the virtual environment `poetry shell`
10. Install the dependencies `poetry install`
Expand Down
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,10 @@ else
endif

buzz/$(LIBWHISPER):
ifeq ($(OS),Windows_NT)
cp dll_backup/whisper.dll buzz || true
cp dll_backup/SDL2.dll buzz || true
else
cmake -S whisper.cpp -B whisper.cpp/build/ $(CMAKE_FLAGS)
cmake --build whisper.cpp/build --verbose
cp whisper.cpp/build/bin/Debug/$(LIBWHISPER) buzz || true
cp whisper.cpp/build/$(LIBWHISPER) buzz || true
endif

buzz/whisper_cpp.py: buzz/$(LIBWHISPER) translation_mo
cd buzz && ctypesgen ../whisper.cpp/whisper.h -lwhisper -o whisper_cpp.py
Expand Down
2 changes: 1 addition & 1 deletion buzz/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "1.0.1"
VERSION = "1.0.2"
2 changes: 2 additions & 0 deletions buzz/buzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
# Add the app directory to the DLL list: https://stackoverflow.com/a/64303856
if platform.system() == "Windows":
os.add_dll_directory(APP_BASE_DIR)
os.add_dll_directory(os.path.join(APP_BASE_DIR, "dll_backup"))
os.add_dll_directory(os.path.join(APP_BASE_DIR, "dll_backup", "win32"))


def main():
Expand Down
Binary file added dll_backup/win32/whisper.dll
Binary file not shown.
1 change: 1 addition & 0 deletions installer.iss
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{

[Files]
Source: {#AppSourcePath}; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "dll_backup"; DestDir: "{app}\dll_backup"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Expand Down
4 changes: 2 additions & 2 deletions poetry.lock

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

20 changes: 14 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
[tool.poetry]
name = "buzz-captions"
version = "1.0.1"
version = "1.0.2"
description = ""
authors = ["Chidi Williams <[email protected]>"]
license = "MIT"
readme = "README.md"
include = ["buzz/libwhisper.*", "buzz/whisper_cpp.py", "buzz/locale/*/LC_MESSAGES/buzz.mo"]
include = [
"buzz/libwhisper.*", "buzz/*.dll", "buzz/whisper_cpp.py", "buzz/locale/*/LC_MESSAGES/buzz.mo",
"buzz/dll_backup/*",
]
repository = "https://github.com/chidiwilliams/buzz"
packages = [
{ include = "buzz" },
]

[project]
requires-python = ">=3.9,<3.13"

[tool.poetry.dependencies]
python = ">=3.9.13,<3.13"
python = ">=3.9,<3.13"
sounddevice = "^0.4.5"
humanize = "^4.4.0"
PyQt6 = "^6.4.0"
PyQt6 = "6.6.1"
PyQt6-Qt6 = "6.6.2"
PyQt6-sip = "13.6.0"
openai = "^1.14.2"
keyring = "^25.0.0"
platformdirs = "^4.2.0"
Expand All @@ -24,9 +32,9 @@ numpy = "^1.21.2"
requests = "^2.31.0"
yt-dlp = "2024.3.10"
stable-ts = "2.15.9"
faster-whisper = "^1.0.1"
faster-whisper = "1.0.1"
openai-whisper = "v20231117"
transformers = "^4.39.1"
transformers = "4.39.1"
polib = "^1.2.0"

[tool.poetry.group.dev.dependencies]
Expand Down

0 comments on commit 9877977

Please sign in to comment.