Registry / serialization / mda-xdrlib

mda-xdrlib

JSON →
library0.2.0pypypi✓ verified 83d ago

mda-xdrlib is a stand-alone Python module that provides the functionality of the `xdrlib` module, as it existed in CPython 3.10.8. It enables conversion between Python data types and the XDR (External Data Representation) format, which is useful for platform-independent binary data exchange. Currently at version 0.2.0, its releases are infrequent and primarily driven by the need to maintain XDR compatibility for projects like MDAnalysis after the standard library's `xdrlib` module was deprecated.

pip install mda-xdrlib
INSTALL
IMPORT
SIG · MDA-XDRLIB
M
mda-xdrlib
serializationpythonv0.2.0
Install
1.7s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.7s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

xdrlib
from mda_xdrlib import xdrlib
from mda_xdrlib import Packer

Demonstrates basic XDR packing of an integer, a string, and a double, followed by unpacking them in the correct order.

import mda_xdrlib # 1. Pack data packer = mda_xdrlib.Packer() packer.pack_int(123) packer.pack_string(b"hello xdr") packer.pack_double(3.14159) packed_data = packer.get_buffer() print(f"Packed data (hex): {packed_data.hex()}") # 2. Unpack data unpacker = mda_xdrlib.Unpacker(packed_data) unpacked_int = unpacker.unpack_int() unpacked_string = unpacker.unpack_string() unpacked_double = unpacker.unpack_double() unpacker.done() # Verify all data has been unpacked print(f"Unpacked int: {unpacked_int}") print(f"Unpacked string: {unpacked_string.decode('utf-8')}") print(f"Unpacked double: {unpacked_double}")
Debug
Known issues
deprecatedThe `xdrlib` module in the Python standard library is deprecated in Python 3.11 and will be removed entirely in Python 3.13. `mda-xdrlib` serves as a drop-in replacement, and users on Python 3.11+ must use this standalone package or similar solutions to retain `xdrlib` functionality.
fix
Switch imports from `import xdrlib` to `import mda_xdrlib`. Ensure your codebase explicitly uses `mda_xdrlib`.
affects: Python 3.11+
breakingFor projects previously using the standard `xdrlib` module (especially those developed with Python versions prior to 3.11), migrating to `mda-xdrlib` requires updating all import statements to `from mda_xdrlib import ...` instead of `from xdrlib import ...`.
fix
Globally replace `import xdrlib` with `import mda_xdrlib` (and similar for specific classes like `Packer` or `Unpacker`).
affects: <=0.2.0 (when migrating from stdlib xdrlib)
gotchaThe XDR format and its Python API (`xdrlib`/`mda-xdrlib`) can be unintuitive for developers accustomed to more modern serialization formats. Incorrect usage of packing/unpacking methods (e.g., mismatching types or order) or improper buffer management (e.g., `get_position`, `set_position`) can lead to `mda_xdrlib.Error` or `mda_xdrlib.ConversionError`.
fix
Carefully consult the Python 3.10 standard library documentation for `xdrlib` for detailed API usage and best practices. Implement robust error handling (try-except `mda_xdrlib.Error`).
affects: All
gotchaWhen `mda-xdrlib` is used by other libraries (e.g., MDAnalysis for reading GROMACS XDR files), issues can arise from external factors such as corrupted auxiliary files (e.g., offset files) or concurrent access in multiprocessing environments. These can manifest as `ValueError` (e.g., for pickled data) or other file I/O errors.
fix
Ensure that file handling is robust, particularly for frequently accessed or modified auxiliary files. Implement proper locking or synchronization mechanisms if files are accessed concurrently across multiple processes or threads. Consider regenerating potentially corrupted offset files if errors persist.
affects: All
Upgrade
Version history
0.2.0latest on PyPI · released Aug 28, 2023
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
mda-xdrlib — pip install mda-xdrlib · libregistry