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
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibcpy 3.10–3.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.fixSwitch 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 ...`.fixGlobally 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`.fixCarefully 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.fixEnsure 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.