Skip to content

Commit

Permalink
fix build onefile and get dofus data
Browse files Browse the repository at this point in the history
  • Loading branch information
William Attié committed Jun 17, 2021
1 parent 1b78612 commit 01faafd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,15 @@ jobs:
- os: macos-latest
TARGET: macos
CMD_BUILD: >
pyinstaller --onedir -w -n dofus-craft-planner --add-data="util:util" --add-data="data:data" --add-data="static:static" --add-data="README.txt:." --add-data="LICENSE:." main.py &&
pyinstaller --onefile -w -n dofus-craft-planner --add-data="util:util" --add-data="data:data" --add-data="static:static" --add-data="README.txt:." --add-data="LICENSE:." main.py &&
cd dist/ &&
zip -r9 dofus-craft-planner dofus-craft-planner.app/
OUT_FILE_NAME: dofus-craft-planner.zip
ASSET_MIME: application/zip
- os: windows-latest
TARGET: windows
CMD_BUILD: >
pyinstaller --onedir -w -c -n dofus-craft-planner --add-data="util;util" --add-data="data;data" --add-data="static;static" --add-data="README.txt;." --add-data="LICENSE;." main.py
cd dist/ &&
zip -r dofus-craft-planner dofus-craft-planner.zip/
OUT_FILE_NAME: dofus-craft-planner.zip
CMD_BUILD: pyinstaller --onefile -w -c -n dofus-craft-planner --add-data="util;util" --add-data="data;data" --add-data="static;static" --add-data="README.txt;." --add-data="LICENSE;." main.py
OUT_FILE_NAME: dofus-craft-planner.exe
ASSET_MIME: application/vnd.microsoft.portable-executable
steps:
- uses: actions/checkout@v1
Expand Down
17 changes: 13 additions & 4 deletions util/datafus_search.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import logging
import json
import pkgutil


import os
import sys

def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")

return os.path.join(base_path, relative_path)
class CATEGORIES:
weapons="weapons"
equipments="equipments"
Expand All @@ -14,7 +23,7 @@ class CATEGORIES:
def openJSONdb():
global loaded
if not loaded:
with open("data/dofus.fr.json") as db:
with open(resource_path("data/dofus.fr.json")) as db:
loaded = json.load(db)
return loaded

Expand Down

0 comments on commit 01faafd

Please sign in to comment.