Skip to content

Commit

Permalink
* Adding #587 Distribute a mac app bundle (thanks to Ivan Novokhatski)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdgriffith committed Aug 9, 2024
1 parent 9ac8f7c commit 910d5f8
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 19 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ jobs:
dist/FastFlix
dist/LICENSE
- name: Build Mac App
if : ${{ startsWith(matrix.os, 'macos') }}
run: python scripts/build_mac_app.py "${{ matrix.os }}"

- name: Upload Mac App artifact
if : ${{ startsWith(matrix.os, 'macos') }}
uses: actions/upload-artifact@v4
with:
name: FastFlix_${{ env.VERSION }}_appbundle_${{ matrix.os }}_${{ env.ARCH }}
path: FastFlix.app


build-windows-2022:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
python-version: "3.12"

- run: pip install black==23.7.0
- run: pip install black==24.8.0
- run: python -m black --check .

test:
Expand Down
10 changes: 7 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: mixed-line-ending
- id: trailing-whitespace
Expand All @@ -12,14 +12,18 @@ repos:
- id: check-byte-order-marker
- id: debug-statements
- id: check-added-large-files
exclude: tests/media/.+
exclude: |
(?x)^(
tests/media/.+|
^fastflix/data/icon.icns
)$
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-toml
- id: detect-private-key
- id: end-of-file-fixer
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 24.8.0
hooks:
- id: black
# - repo: https://github.com/pre-commit/mirrors-mypy
Expand Down
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Adding #354 M1 support (thanks to Nhunz and Anton)
* Adding #536 Improve Profiles - save advanced options (thanks to CelticTaonga and DCNerds)
* Adding #568 center app on startup (thanks to Viet-Duc Le)
* Adding #587 Distribute a mac app bundle (thanks to Ivan Novokhatski)
* Adding #589 support for pydantic 2.x (thanks to dmo marillat)
* Adding #592 Add alpha channel for VP9 (thjanks to subof)
* Fixing #185 audio channels not being set properly and resetting on encoder change (thanks to Tupsi)
Expand Down
7 changes: 4 additions & 3 deletions fastflix/command_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ def change_priority(
logger.exception(f"Could not set process priority to {new_priority}")

def read_output(self):
with open(self.output_file, "r", encoding="utf-8", errors="ignore") as out_file, open(
self.error_output_file, "r", encoding="utf-8", errors="ignore"
) as err_file:
with (
open(self.output_file, "r", encoding="utf-8", errors="ignore") as out_file,
open(self.error_output_file, "r", encoding="utf-8", errors="ignore") as err_file,
):
while True:
time.sleep(0.01)
if not self.is_alive():
Expand Down
32 changes: 32 additions & 0 deletions fastflix/data/Info.plist.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>FastFlix</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleIconFile</key>
<string>icon.icns</string>
<key>CFBundleIdentifier</key>
<string>com.github.cdgriffith.FastFlix</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>PURE</string>
<key>CFBundleVersion</key>
<string>{version}</string>
<key>CFBundleName</key>
<string>FastFlix</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSDisablePersistence</key>
<true/>
<key>LSMinimumSystemVersion</key>
<string>{mac_version}</string>
</dict>
</plist>
Binary file added fastflix/data/icon.icns
Binary file not shown.
6 changes: 3 additions & 3 deletions fastflix/encoders/vceencc_av1/settings_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ def update_video_encoder_settings(self):
pa_paq=self.widgets.pa_paq.currentText(),
pa_taq=None if self.widgets.pa_taq.currentIndex() == 0 else self.widgets.pa_taq.currentText(),
pa_motion_quality=self.widgets.pa_motion_quality.currentText(),
output_depth=None
if self.widgets.output_depth.currentIndex() == 0
else self.widgets.output_depth.currentText(),
output_depth=(
None if self.widgets.output_depth.currentIndex() == 0 else self.widgets.output_depth.currentText()
),
)

encode_type, q_value = self.get_mode_settings()
Expand Down
6 changes: 3 additions & 3 deletions fastflix/encoders/vceencc_avc/settings_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ def update_video_encoder_settings(self):
pa_paq=self.widgets.pa_paq.currentText(),
pa_taq=None if self.widgets.pa_taq.currentIndex() == 0 else self.widgets.pa_taq.currentText(),
pa_motion_quality=self.widgets.pa_motion_quality.currentText(),
output_depth=None
if self.widgets.output_depth.currentIndex() == 0
else self.widgets.output_depth.currentText(),
output_depth=(
None if self.widgets.output_depth.currentIndex() == 0 else self.widgets.output_depth.currentText()
),
)

encode_type, q_value = self.get_mode_settings()
Expand Down
6 changes: 3 additions & 3 deletions fastflix/encoders/vceencc_hevc/settings_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ def update_video_encoder_settings(self):
pa_paq=self.widgets.pa_paq.currentText(),
pa_taq=None if self.widgets.pa_taq.currentIndex() == 0 else self.widgets.pa_taq.currentText(),
pa_motion_quality=self.widgets.pa_motion_quality.currentText(),
output_depth=None
if self.widgets.output_depth.currentIndex() == 0
else self.widgets.output_depth.currentText(),
output_depth=(
None if self.widgets.output_depth.currentIndex() == 0 else self.widgets.output_depth.currentText()
),
)

encode_type, q_value = self.get_mode_settings()
Expand Down
6 changes: 3 additions & 3 deletions fastflix/encoders/vp9/settings_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ def update_video_encoder_settings(self):
extra=self.ffmpeg_extras,
extra_both_passes=self.widgets.extra_both_passes.isChecked(),
fast_first_pass=self.widgets.fast_first_pass.isChecked(),
tile_columns=self.widgets.tile_columns.currentText()
if self.widgets.tile_columns.currentIndex() > 0
else "-1",
tile_columns=(
self.widgets.tile_columns.currentText() if self.widgets.tile_columns.currentIndex() > 0 else "-1"
),
tile_rows=self.widgets.tile_rows.currentText() if self.widgets.tile_rows.currentIndex() > 0 else "-1",
)
encode_type, q_value = self.get_mode_settings()
Expand Down
36 changes: 36 additions & 0 deletions scripts/build_mac_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
from pathlib import Path
import sys
import shutil
from subprocess import check_output

from fastflix.version import __version__

here = Path(__file__).parent
plist_template = here.parent / "fastflix" / "data" / "Info.plist.template"

build_folder = Path(here.parent / "FastFlix.app")
build_folder.mkdir(exist_ok=True)

content_folder = build_folder / "Contents"
content_folder.mkdir(exist_ok=True)

macos_folder = content_folder / "MacOS"
macos_folder.mkdir(exist_ok=True)

resources_folder = content_folder / "Resources"
resources_folder.mkdir(exist_ok=True)

mac_version = f"{sys.argv[1].split(" - ")[1]}.0"
assert mac_version in ("12.0", "13.0", "14.0", "15.0")

with open(plist_template) as in_file, open(content_folder / "Info.plist", "w") as out_file:
template = in_file.read().format(version=__version__, mac_version=mac_version)
out_file.write(template)

shutil.copy(here.parent / "fastflix" / "data" / "icon.icns", resources_folder / "icon.icns")

shutil.copy(here.parent / "dist" / "FastFlix", macos_folder / "FastFlix")
shutil.copy(here.parent / "LICENSE", macos_folder / "LICENSE")

check_output(["chmod", "+x", macos_folder / "FastFlix"])

0 comments on commit 910d5f8

Please sign in to comment.