Skip to content
Draft
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
11 changes: 7 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ jobs:
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -75,16 +76,18 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: |
type=gha,scope=deadbot-build-master
type=gha,scope=deadbot-build-${{ env.BRANCH_NAME }}
cache-to: type=gha,mode=max,scope=deadbot-build-${{ env.BRANCH_NAME }}

- name: Build deadbot executable
run: |
docker run --rm \
-v ${{ github.workspace }}/dist:/repo/dist \
--entrypoint bash \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} \
-c "poetry run pyinstaller --onefile src/deadbot.py"
-c "poetry run nuitka ./src/deadbot.py --static-libpython=no"

- name: Get version from pyproject.toml
if: github.event_name != 'pull_request'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ docker-compose-local.yml
exceptions.txt
dist
game-data
deadbot.bin
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM python:3.11-slim

RUN apt update && \
apt install -y --no-install-recommends wget unzip libicu-dev binutils git dos2unix && \
apt install -y --no-install-recommends wget unzip libicu-dev binutils git dos2unix gcc patchelf ccache && \
rm -rf /var/lib/apt/lists/*

WORKDIR /tools
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ The data flow is as follows:
The recommended way to use Deadbot is by downloading the pre-built executable. This method does not require Python, Poetry, or any other development tools.

1. **Download the executable** for your operating system from the [**latest release**](https://github.com/deadlock-wiki/deadbot/releases/latest).
2. (On macOS/Linux) Make the file executable: `chmod +x ./deadbot`
3. Run commands from your terminal. For example, to parse a local Deadlock installation:
2. (On macOS/Linux) May need to make the file executable: `chmod +x ./deadbot`
3. `cd ./dist`
4. Run commands from your terminal. For example, to parse a local Deadlock installation:

```sh
# On macOS/Linux
Expand Down
38 changes: 38 additions & 0 deletions deadbot.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- mode: python ; coding: utf-8 -*-


a = Analysis(
['src/deadbot.py'],
pathex=[],
binaries=[],
datas=[('src/steam/steam_db_download_deadlock.sh', 'steam')],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='deadbot',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
1,468 changes: 785 additions & 683 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ feedparser = "^6.0.11"
requests = "^2.32.3"
bs4 = "^0.0.2"
loguru = "^0.7.2"
nuitka = "^4.0.5"
zstandard = "^0.25.0"

[tool.poetry.group.dev.dependencies]
pyinstaller = "^6.15.0"
[tool.nuitka]
enable-plugin = ["numpy"]
include-data-files = ["src/steam/steam_db_download_deadlock.sh=steam/steam_db_download_deadlock.sh"]
include-module = ["_json", "_bisect", "pydantic"]

[tool.ruff]
line-length = 150
Expand Down
5 changes: 3 additions & 2 deletions src/deadbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import constants
from changelogs import parse_changelogs, fetch_changelogs
from parser import parser
from utils.meta_utils import get_deadbot_version
from utils.parameters import Args
from utils.process import run_process
from wiki.upload import WikiUpload
Expand All @@ -31,11 +32,11 @@ def main():
format='<white><dim>{time:YYYY-MM-DD HH:mm:ss.SSS} | </dim>' '</white><level>{level:<7} <dim>|</dim> <normal>{message}</normal></level>',
)

logger.info(f'Running Deadbot v{get_deadbot_version()}')
# import game files from steamdb github and localization files using depot downloader
if args.import_files:
logger.info('Importing game files...')
script_path = os.path.join(os.path.dirname(__file__), 'steam/steam_db_download_deadlock.sh')
run_process(script_path, name='download-deadlock-files')
run_process('steam/steam_db_download_deadlock.sh', name='download-deadlock-files')
# non-english localizations are imported using depot downloader
if not args.english_only:
logger.info('Downloading non-english localizations...')
Expand Down
12 changes: 5 additions & 7 deletions src/utils/meta_utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import tomllib
from importlib.metadata import version


def get_deadbot_version():
# Read the file and parse the version
with open('pyproject.toml', 'rb') as f:
pyproject_data = tomllib.load(f)

deadbot_version = pyproject_data.get('tool', {}).get('poetry', {}).get('version')
return deadbot_version
try:
return version('Deadbot')
except Exception as e:
raise Exception('Deadbot package version not found') from e
32 changes: 27 additions & 5 deletions src/utils/process.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import subprocess
import os
import sys
from loguru import logger


Expand All @@ -11,14 +12,26 @@ def run_process(params, name=''):
name (str, optional): An optional name to identify the process in logs. Defaults to ''
"""
try:
# Resolve resource path for string params before any wrapping
if isinstance(params, str):
process_path = get_resource_path(params)
else:
process_path = params

# Handle shell scripts on Windows by explicitly using bash
if isinstance(params, str) and params.endswith('.sh') and os.name == 'nt':
params = ['bash', params]
elif isinstance(params, list) and len(params) > 0 and params[0].endswith('.sh') and os.name == 'nt':
params = ['bash'] + params
if isinstance(process_path, str) and process_path.endswith('.sh') and os.name == 'nt':
process_path = ['bash', process_path]
elif (
isinstance(process_path, list)
and len(process_path) > 0
and isinstance(process_path[0], str)
and process_path[0].endswith('.sh')
and os.name == 'nt'
):
process_path = ['bash'] + process_path

process = subprocess.Popen( # noqa: F821
params, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True
process_path, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True
)

with process.stdout:
Expand All @@ -31,3 +44,12 @@ def run_process(params, name=''):
exit_code = process.wait()
if exit_code != 0:
raise Exception(f'Process {name} exited with code {exit_code}')


_SRC_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


def get_resource_path(script_params):
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, script_params)
return os.path.join(_SRC_ROOT, script_params)
Loading