Adding cibuildwheels to build wheels (#842)

This commit is contained in:
Raivis Dejus 2024-07-30 21:00:26 +03:00 committed by GitHub
commit 9877977824
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 77 additions and 38 deletions

View file

@ -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
@ -181,6 +178,7 @@ jobs:
elif [ "$RUNNER_OS" == "Windows" ]; then
cp -r ./dll_backup ./buzz/
poetry run make bundle_windows
fi
@ -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
with:
python-version: "3.11.9"
- name: Install Poetry Action
uses: snok/install-poetry@v1.3.1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Publish to PyPI
- name: Copy Windows DLLs
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
poetry publish --build --skip-existing
if [ "$RUNNER_OS" == "Windows" ]; then
cp -r ./dll_backup ./buzz/
fi
shell: bash
- name: Build wheels
uses: pypa/cibuildwheel@v2.19.2
env:
CIBW_ARCHS_WINDOWS: "auto"
CIBW_ARCHS_MACOS: "universal2"
CIBW_ARCHS_LINUX: "auto"
- uses: actions/upload-artifact@v4
with:
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:
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 }}
@ -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/install-poetry@v1.3.1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Release
uses: softprops/action-gh-release@v2
with:

View file

@ -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

2
.gitignore vendored
View file

@ -8,6 +8,7 @@ build/
htmlcov/
coverage.xml
.idea/
.venv/
# whisper_cpp
libwhisper.*
@ -24,3 +25,4 @@ benchmarks.json
.eggs
*.egg-info
/coverage/
/wheelhouse/

View file

@ -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=[],

View file

@ -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`
@ -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`

View file

@ -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

View file

@ -1 +1 @@
VERSION = "1.0.1"
VERSION = "1.0.2"

View file

@ -26,6 +26,8 @@ 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_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():

Binary file not shown.

View file

@ -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]

4
poetry.lock generated
View file

@ -3399,5 +3399,5 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p
[metadata]
lock-version = "2.0"
python-versions = ">=3.9.13,<3.13"
content-hash = "fcdb182782521a49b7eeeff8f6c92021c48709c8f0dcac14ad8879c62987bbbe"
python-versions = ">=3.9,<3.13"
content-hash = "c62d3e0a79ed56cccbbd28548655a072ca9e144fc5700260f788f1b88057faa7"

View file

@ -1,21 +1,29 @@
[tool.poetry]
name = "buzz-captions"
version = "1.0.1"
version = "1.0.2"
description = ""
authors = ["Chidi Williams <williamschidi1@gmail.com>"]
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"
@ -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]