th3w1zard1 / KOTORModSync

A flexible multi-mod installer for KOTOR games.
GNU General Public License v3.0
19 stars 0 forks source link

pykotorcli is an ELF binary in the Mac release #26

Closed Paisseon closed 1 year ago

Paisseon commented 1 year ago

Saw your comment on my issue in PyKotor so decided to check this out, but I'm getting an error on macOS 13.5, arm64. Weird permissions error aside (chmod 0755 and disabling Gatekeeper fixes that) and it succeeded on JC's Minor Fixes, but failed on Character Startup Changes due to not being able to execute the pykotorcli file. Error message: [Error] FAILED Instruction #2 Action 'TSLPatcher'

The pykotorcli file is an ELF binary for Linux, not Mach-O binary as is used on macOS. This should be a pretty easy fix, but I'm not sure how to compile the pykotorcli from your PyKotor fork into a binary.

th3w1zard1 commented 1 year ago

Ah, I see. Honestly I was hoping the linux binary would work as is on mac as they're both Unix, but I see now that unfortunately isn't the case.

I don't have a Mac, and I'm not sure how I can build the necessary pykotorcli binary without it. There are services such as MacStadium available as cloud providers for this kind of thing but I just haven't had time to look into it.

The easiest way to get this working on Mac is to do ONE of the following:

  1. Install pyinstaller by following these instructions. Then, fork over PyKotor from https://github.com/th3w1zard1/PyKotor. Then, in a terminal, run the command: pyinstaller --console --onefile pykotorcli.py. And that's it! This should create the binary you need in the PyKotor\dist directory.

  2. Create a shell script in the KOTORModSync 'Resources' directory named 'pykotorcli', without any extension. This will be used as a proxy. Then, write a script to pass any command-line arguments directly to PyKotorCLI.py which you can download from my fork at https://github.com/th3w1zard1/PyKotor

If those aren't an option for you, the last solution I have is a lot more complicated and tedious:

  1. In the TOML instructions file you've downloaded, modify all instances of Action = TSLPatcher to Action = Execute, then modify the Arguments to work with the pykotorcli.py directly. The Source field is the actual command to execute, which would be the literal string python <<modDirectory>>\\pykotorcli.py. The Arguments field would be three parts separated by spaces. The first part needs to be the literal string: "<<kotorDirectory>>". The second would be "<<modDirectory>>\\path\\to\\tslpatchdata's parent folder" which is a path to the folder holding tslpatchdata. Do not include tslpatchdata in the path itself. The third is the option index of the tslpatcher option to run, found in namespaces.ini. You'd need to make these changes for every instruction. I don't recommend this, but it'll work if all else fails. See the documentation provided for more information.

Please keep me updated, I'd very much like to nail in Mac support in an upcoming release. If you find anything out, please let me know.

PS: If you get any ModuleNotFound errors while running pykotorcli, or while compiling it with pyinstaller, you can simply pip install the module it names. IIRC you need Ply and chardet which can be installed like pip install chardet. Everything else can be installed from pip install -r requirements.txt like the main PyKotor page explains.

Paisseon commented 1 year ago

Working now, thanks! Here's the Mac-compiled binary (zipped for GH upload) if you want to add it to the release pykotorcli.zip

th3w1zard1 commented 1 year ago

Fantastic! I'm glad you got this working! :smile:

I'm going to reopen this issue as I think it'll be an ongoing issue

th3w1zard1 commented 1 year ago

Fixed by v0.10.23