Skip to content

Commit

Permalink
support bundling with pyinstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryQuan committed Jun 28, 2022
1 parent 5cf248a commit ff775aa
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ content/

# environment
.env/
game.path
game.path

# pyinstaller
dist/
build/
*.spec
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ Based on [EdibleBug/WoWS-GameParams](https://github.com/EdibleBug/WoWS-GameParam
- Paste the game path into `game.path`
- Run `python3 run.py` again to unpack

## Distribution
- Install `pyinstaller` following [this guide](https://pyinstaller.org/en/stable/index.html)
- Run `pyinstaller --onefile .\run.py -p .\unpack\ --hidden-import GameParams`
- Copy `wowsunpack.exe` to `dist/`
- Ready to go!

***

# World of Warships GameParams to JSON
Expand Down
11 changes: 9 additions & 2 deletions run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
from unpack import WoWsUnpack

if __name__ == "__main__":
Expand All @@ -14,16 +15,22 @@
try:
unpack.unpackGameParams()
unpack.decodeGameParams()

# optional actions
# unpack.decodeLanguages()
# unpack.unpackGameIcons()
# unpack.unpackGameMaps()
except FileNotFoundError:
print("Make sure the game path is valid")
print("Make sure the game path is valid. It should look like C:\Games\World_of_Warships")
print("\nhttps://github.com/WoWs-Info/wows_gameparams")
sys.exit(-1)
else:
with open('game.path', 'w') as f:
print("Created game.path")
print(
"Please place your game path in it. It should look like C:\Games\World_of_Warships")
exit(-1)
print("\nhttps://github.com/WoWs-Info/wows_gameparams")
sys.exit(-1)

print("Done unpacking!")
input("Press Enter to exit...")
4 changes: 2 additions & 2 deletions unpack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unpack.unpack import WoWsUnpack
from unpack.WoWsGameParams import WoWsGameParams
import sys
import os
# this is necessary for submodules to work correctly
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from unpack.unpack import WoWsUnpack
from unpack.WoWsGameParams import WoWsGameParams
3 changes: 1 addition & 2 deletions unpack/unpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import pathlib
import os
import sys
from unpack.WoWsGameParams import WoWsGameParams

from WoWsGameParams import WoWsGameParams

class WoWsUnpack:
def __init__(self, path):
Expand Down

0 comments on commit ff775aa

Please sign in to comment.