Skip to content

Commit

Permalink
Download binary_deps in workflow
Browse files Browse the repository at this point in the history
Add: praw.ini so we don't have to rely on a specific site-package
     path when using the default one
  • Loading branch information
nilfoer committed Nov 6, 2023
1 parent 5450406 commit 4b8b18a
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 20 deletions.
47 changes: 39 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,56 @@ jobs:
mkdir dist/
python3 dev_tools/build_zip_dist.py . dist/GWARipper-${{github.ref_name}}.zip
# output will be in src/dist/windows
- name: Get date
run: echo "date_year=$(date +'%Y')" >> "$GITHUB_ENV"

- name: Cache binary deps
id: cache-binary-deps
uses: actions/cache@v3
with:
path: binary_deps/
key: ${{ runner.os }}-build-${{ env.date_year }}
restore-keys: |
${{ runner.os }}-build-${{ env.date_year }}
${{ runner.os }}-build-
${{ runner.os }}-
# only download deps if we don't have a cached version
- if: ${{ steps.cache-binary-deps.outputs.cache-hit != 'true' }}
name: Download binary deps Windows
run: |
mkdir binary_deps
wget -O ffmpeg.zip https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip
unzip ffmpeg.zip -d binary_deps/
find binary_deps/ffmpeg*-essentials_build/ -name ffmpeg.exe -exec cp {} binary_deps/ \;
rm -rf binary_deps/ffmpeg*-essentials_build/
rm ffmpeg.zip
# output (dir named 'gwaripper') will be in dist/windows
- name: Package Application on Windows
uses: JackMcKew/pyinstaller-action-windows@main
with:
path: .
spec: gwaripper.spec

- name: Rename output Windows
run: mv src/dist/windows src/dist/GWARipper-${{github.ref_name}}_single-folder_win-x64
- name: Bundle Windows
run: |
pushd dist/windows/gwaripper
zip -r ../../GWARipper-${{github.ref_name}}_single-folder_win-x64.zip .
popd
# output will be in src/dist/linux
# output (dir named 'gwaripper') will be in dist/linux
- name: Package Application on Linux
uses: JackMcKew/pyinstaller-action-linux@main
with:
path: .
spec: gwaripper.spec

- name: Rename output Linux
run: mv src/dist/linux src/dist/GWARipper-${{github.ref_name}}_single-folder_lin-x64
- name: Bundle Linux
run: |
pushd dist/linux/gwaripper
zip -r ../../GWARipper-${{github.ref_name}}_single-folder_lin-x64.zip .
popd
- name: Release
uses: softprops/action-gh-release@v1
Expand All @@ -42,5 +73,5 @@ jobs:
generate_release_notes: true
files: |
dist/GWARipper-${{github.ref_name}}.zip
src/dist/GWARipper-${{github.ref_name}}_single-folder_win-x64
src/dist/GWARipper-${{github.ref_name}}_single-folder_lin-x64
dist/GWARipper-${{github.ref_name}}_single-folder_win-x64.zip
dist/GWARipper-${{github.ref_name}}_single-folder_lin-x64.zip
30 changes: 18 additions & 12 deletions gwaripper.spec
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
# -*- mode: python -*-
import os
from sys import platform

block_cipher = None

data_files = [
# praw needs praw.ini (which it looks for in 3 places appdata etc. including cwd)
# -> pyinstaller automatically changes __file__ refs to be relative to the bundle
# praw was looking praw.ini in ./praw/ because thats were the __file__ presumably
# was
("praw.ini", "praw/"),
# also include webgui files
("gwaripper_webGUI/static", "static"),
("gwaripper_webGUI/templates", "templates"),
("gwaripper/migrations/*.py", "gwaripper/migrations"),
]

if platform == "win32" and os.path.exists(os.path.join("binary_deps", "ffmpeg.exe")):
data_files.append(("binary_deps/ffmpeg.exe", "./"))

# IMPORTANT: pyinstaller will apparently just bundle everything it finds in the current python
# env so use a venv with only the required additional packages installed
# pyinstaller needs to be installed in the venv as well and then started (on Win) using
# Scripts\pyinstaller.exe
a = Analysis(['gwaripper-runner.py'],
pathex=['gwaripper', 'gwaripper_webGUI'],
binaries=[],
# praw needs praw.ini (which it looks for in 3 places appdata etc. including cwd)
# -> pyinstaller automatically changes __file__ refs to be relative to the bundle
# praw was looking praw.ini in ./praw/ because thats were the __file__ presumably
# was
datas=[
("venv/Lib/site-packages/praw/praw.ini", "praw/"),
# also include webgui files
("gwaripper_webGUI/static", "static"),
("gwaripper_webGUI/templates", "templates"),
("gwaripper/migrations/*.py", "gwaripper/migrations"),
("binary_deps/ffmpeg.exe", "./"),
],
datas=data_files,
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
Expand Down
26 changes: 26 additions & 0 deletions praw.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[DEFAULT]
# A boolean to indicate whether or not to check for package updates.
check_for_updates=True

# Object to kind mappings
comment_kind=t1
message_kind=t4
redditor_kind=t2
submission_kind=t3
subreddit_kind=t5
trophy_kind=t6

# The URL prefix for OAuth-related requests.
oauth_url=https://oauth.reddit.com

# The amount of seconds of ratelimit to sleep for upon encountering a specific type of 429 error.
ratelimit_seconds=5

# The URL prefix for regular requests.
reddit_url=https://www.reddit.com

# The URL prefix for short URLs.
short_url=https://redd.it

# The timeout for requests to Reddit in number of seconds
timeout=16

0 comments on commit 4b8b18a

Please sign in to comment.