-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open .ksy files directly #50
Comments
You're correct, there's no built-in support for importing .ksy files directly from Python. The usual workflow is to compile the .ksy files into Python modules using @KOLANICH has written a library called kaitaiStructCompile.py, which (among other things) lets you import .ksy files as Python modules without manually compiling them first. When you import a KSY using kaitaiStructCompile, it automatically calls |
@dgelessus good start. It is technically feasible to ship compiler binary in a Python wheel. I made a fork in https://github.com/abitrolly/ksykaitai with a roadmap, but no ETA how it could be done. |
Two hours later still can't get it running. $ python ksykaitai.py
Traceback (most recent call last):
File "ksykaitai.py", line 18, in <module>
compile('../kaitai_struct_visualizer/squashfs_superblock.ksy')
File "ksykaitai.py", line 9, in compile
backend = clibackend.init(ICompilerModule,
File "/home/anatoli/h/snapsquash/ksykaitai/kaitaiStructCompile/backend/cmdline.py", line 87, in init
class CLIPrefsStorage(ICompilerModule.IPrefsStorage):
AttributeError: type object 'ICompiler' has no attribute 'IPrefsStorage' 7566f4e committed https://github.com/abitrolly/ksykaitai @KOLANICH I committed backed to repo to avoid installation hassle, and yet it doesn't work. |
|
It is an extremily bad idea. KSC depends on JVM. You are not going to also ship JVM as a wheel, are you? So it should be handled either manually, or by a system package manager. If you want to make Pip able to install JVM using system package manager, you may want to look at open-source-ideas/ideas#50 |
Going. Exactly. :D https://github.com/dgiagio/warp#quickstart-with-java
So how to import ICompiler module? The class import in |
🤦♂️
|
Answering your style - you should remove that module and the module with exception. Just saying. 🙊 Anyway, fixed in abitrolly/ksykaitai@293c892 Right now the problem I am dealing with is the path to compiler binary. The Python lib expects it to be a directory structure, and I am running the compiler using a wrapper script (which crates secure environment). |
You may be able to set |
With the latest commit I successfully compile my .ksy from Python (after downloading compiler, unpacking to current dir and stripping version suffix). The code works! Although currently I am not sure how it is better than a direct subprocess call. :D |
Added automatic import of generated file. Also committed data to be used as test and proof of concept. Except compiler, because it is too big. The rest of the work is removing hardcoded filenames and creating a wheel with compiler bundled for amd64 Linux and accessing bundled data files with https://importlib-resources.readthedocs.io/en/latest/index.html |
http://doc.kaitai.io/lang_python.html doesn't specify how exactly to import .ksy files from Python. I would expect something like this.
If I understand it right, direct loading of
.ksy
files is not supported, because.ksy
parser is not written in Python.The text was updated successfully, but these errors were encountered: