Skip to content

Conversation

@oleksiy-korniychuk
Copy link

@oleksiy-korniychuk oleksiy-korniychuk commented Jul 4, 2025

Outline

  • Converts the repository into a python package that can be installed and imported.
  • Adds scripts for fetching protobuf files from the DFHack Github repo, and generating the protobuf python files for the client to use.
  • Fleshes out the README with detailed instructions for using the newly added scripts.

Details

This new project structure separates the python protobuf generation from the resulting dfhack_client_python package which can be installed using pip and used by a client application.

  • ./cmake/ contains the CMakeLists.txt and also temporarily houses the intermediate cmake/make files that get generated when generating the protobuf python code.
  • ./examples/ contains the blendwarf.py file. This is a good example for how dfhack_client_python can be imported and used.
  • ./proto/<tag>/ contains all proto files for the <tag> version of DFHack. These files are not necessary for the package to work but are a useful reference when using the client.
  • ./scripts/ contains:
    • fetch_proto_files.py - a convenient script for automating the .proto file retrieval for a given DFHack <tag>.
    • generate_python.py - a convenient script for automating the generation of protobuf python code necessary for the package to work (still using cmake and make). This script should work on both Linux and Windows.
  • ./src/dfhack_client_python/ contains the py_export/ directory (with its generated protobuf python files) and the dfhack_remote.py core package file.
  • pyproject.toml contains the package definition
  • README.md was updated to explain how to generate protobuf python files for other/new DFHack versions and how to install/use the dfhack_client_python package

…alled and imported. Adds scripts for fetching protobuf files from DFHack git repo, and generating the python protobuf files for the client to use. Fleshes out the README with for detailed instructions using the newly added scripts.
…on from CoreProtocal and one from the RemoteFortressReader plugin. Properly imports protobuff types from the _pb2 files.
- Introduced DFHackError class for better error management in DFHack commands.
- Enhanced get_header function to handle RPC_REPLY_FAIL and raise DFHackError.
- Updated remote function to process RPC_REPLY_TEXT and RPC_REPLY_RESULT messages and log text notifications to standard output.
- Adjusted byte size handling in get_header for consistency (python slice is non inclusive for the end).
…he from async_lru. This fixes a bug where the cache was storing coroutines instead of the final result of the function execution which caused an issue whenever you called the same method twice in one session.
@McArcady
Copy link
Owner

McArcady commented Jul 6, 2025

Thanks for the PR! Looks great.
Sadly I will not be able to test it, since I don't have time to play or hack with DF anymore.
Would you be interested to maintain the repo ?

@oleksiy-korniychuk
Copy link
Author

Thanks for the PR! Looks great. Sadly I will not be able to test it, since I don't have time to play or hack with DF anymore. Would you be interested to maintain the repo ?

Hey @McArcady, thanks for taking a look. I would be happy to maintain it! I haven't tested it on Linux yet but I plan to do that next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants