python-rubymarshal
Port variant v14
Summary Read and write Ruby-marshalled data (3.14)
Package version 1.2.10
Homepage https://pypi.org/project/rubymarshal/
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants v15
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 13 NOV 2026, 13:25:52 UTC
Port created 01 APR 2018, 16:48:53 UTC
Subpackage Descriptions
single RubyMarshal =========== Read and write Ruby-marshalled data. Only basics Ruby data types can be directly read and written, but you can use any custom Python and Ruby types: * `float`, * `bool`, * `int`, * `str` (mapped to `rubymarshal.classes.RubyString` if dumped with instance variables), * `nil` (mapped to `None` in Python), * `array` (mapped to `list`), * `hash` (mapped to `dict`), * symbols and other classes are mapped to specific Python classes. Installation ------------ `python3 pip install rubymarshal ` Usage ----- ```python3 from rubymarshal.reader import loads, load from rubymarshal.writer import writes, write with open('my_file', 'rb') as fd: content = load(fd) with open('my_file', 'wb') as fd: write(fd, content) loads(b"\x04\bi\xfe\x00\xff") writes(-256) ``` You can map custom Ruby types to Python ones: ```python3 from rubymarshal.reader import loads from rubymarshal.classes import RubyObject, registry class DomainError(RubyObject): ruby_class_name = "Math::DomainError" registry.register(DomainError) loads(b'\x04\x08c\x16Math::DomainError') ``` You can use custom registries instead of the global one: ```python3 from rubymarshal.reader import loads from rubymarshal.classes import RubyObject, ClassRegistry class DomainError(RubyObject): ruby_class_name = "Math::DomainError" registry = ClassRegistry() registry.register(DomainError) loads(b'\x04\x08c\x16Math::DomainError', registry=registry) ``` You can use Ruby's symbols: ```python3 from rubymarshal.reader import loads from rubymarshal.writer import writes from rubymarshal.classes import Symbol x = Symbol("test") dump = writes(Symbol("test")) y = loads(dump) assert y is x ``` The default Writer class is customizable to write custom Python classes: ```python3 from rubymarshal.writer import writes, Writer from rubymarshal.classes import Symbol class Constant: def __init__(self, name): self.name = name class ConstantWriter(Writer): def write_python_object(self, obj): if isinstance(obj, Constant): return self.write(Symbol(obj.name)) super().write_python_object(obj) dump = writes([Constant("test")], cls=ConstantWriter) print(dump) ```
Configuration Switches (platform-specific settings discarded)
PY314 ON Build using Python 3.14 PY315 OFF Build using Python 3.15
Package Dependencies by Type
Build (only) python314:dev:std
python-pip:single:v14
autoselect-python:single:std
Build and Runtime python314:primary:std
Download groups
main mirror://PYPIWHL/7c/c2/a52d6d66a878d16e6cfa8f89ba0395540decf37e0e81fa2d7e1a80e6fb3b
Distribution File Information
0cac74725cf6024efd143dad9e7c46c9f0c3a4ffa94c53ca546640de83f54555 21638 python-src/rubymarshal-1.2.10-py3-none-any.whl
Ports that require python-rubymarshal:v14
No other ports depend on this one.