From 0a1b1e17eedaa345201c7a149978d4a1694ec6f8 Mon Sep 17 00:00:00 2001 From: OleSTEEP Date: Thu, 1 May 2025 02:57:37 +0300 Subject: [PATCH] rpatool: pack as python module and executable --- build.bat | 2 ++ build.sh | 2 ++ pyproject.toml | 4 +++- rpatool/__init__.py | 0 rpatool/__main__.py | 6 ++++++ rpatool/rpatool.py | 10 ++++++---- 6 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 rpatool/__init__.py create mode 100644 rpatool/__main__.py diff --git a/build.bat b/build.bat index 821ed6c..9c097ac 100755 --- a/build.bat +++ b/build.bat @@ -12,6 +12,8 @@ python -m nuitka --jobs=%NUMBER_OF_PROCESSORS% --output-dir=output --follow-impo move /Y output\unrenapk.exe output\bin python -m nuitka --jobs=%NUMBER_OF_PROCESSORS% --output-dir=output --follow-imports --onefile --output-filename=vnds2renpy vnds2renpy || goto :exit move /Y output\vnds2renpy.exe output\bin +python -m nuitka --jobs=%NUMBER_OF_PROCESSORS% --output-dir=output --follow-imports --onefile --output-filename=rpatool rpatool || goto :exit +move /Y output\rpatool.exe output\bin echo "Done! You can get binaries into output\bin directory" :venv_error diff --git a/build.sh b/build.sh index ffbd2b4..83e0e1c 100755 --- a/build.sh +++ b/build.sh @@ -21,4 +21,6 @@ python3 -m nuitka "${jobs}" --output-dir=output --onefile --follow-imports --out mv output/unrenapk output/bin python3 -m nuitka "${jobs}" --output-dir=output --onefile --follow-imports --output-filename=vnds2renpy vnds2renpy mv output/vnds2renpy output/bin +python3 -m nuitka "${jobs}" --output-dir=output --onefile --follow-imports --output-filename=rpatool rpatool +mv output/rpatool output/bin echo "Done! You can get binaries into output/bin directory" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index a195225..e6c677c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,18 +5,20 @@ requires = [ build-backend = "setuptools.build_meta" [tool.setuptools] -packages = ["vnrecode", "unrenapk", "vnds2renpy"] +packages = ["vnrecode", "unrenapk", "vnds2renpy", "rpatool"] include-package-data = true [tool.setuptools.package-data] 'vnrecode' = ['*.py'] 'vnds2renpy' = ['*.py'] 'unrenapk' = ['*.py'] +'rpatool' = ['*.py'] [project.scripts] vnrecode = "vnrecode.__main__:init" vnds2renpy = "vnds2renpy.__main__:main" unrenapk = "unrenapk.application:launch" +rpatool = "rpatool.rpatool:main" [project] name = "vntools" diff --git a/rpatool/__init__.py b/rpatool/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rpatool/__main__.py b/rpatool/__main__.py new file mode 100644 index 0000000..b76bbbb --- /dev/null +++ b/rpatool/__main__.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +from rpatool import rpatool + +if __name__ == '__main__': + rpatool.main() \ No newline at end of file diff --git a/rpatool/rpatool.py b/rpatool/rpatool.py index aaf0a48..e24ed5b 100644 --- a/rpatool/rpatool.py +++ b/rpatool/rpatool.py @@ -1,11 +1,9 @@ #!/usr/bin/env python3 from __future__ import print_function - import sys import os import codecs -import pickle import errno import random try: @@ -39,6 +37,7 @@ if sys.version_info[0] >= 3: def _unpickle(data): # Specify latin1 encoding to prevent raw byte values from causing an ASCII decode error. return pickle.loads(data, encoding='latin1') + elif sys.version_info[0] == 2: def _unicode(text): if isinstance(text, unicode): @@ -162,7 +161,6 @@ class RenPyArchive: if self.verbose: print(message) - # List files in archive and current internal storage. def list(self): return list(self.indexes.keys()) + list(self.files.keys()) @@ -304,7 +302,8 @@ class RenPyArchive: # Reload the file in our internal database. self.load(filename) -if __name__ == "__main__": + +def main(): import argparse parser = argparse.ArgumentParser( @@ -490,3 +489,6 @@ if __name__ == "__main__": else: print('No operation specified :(') print('Use {} --help for usage details.'.format(sys.argv[0])) + +if __name__ == "__main__": + main() \ No newline at end of file