Registry / serialization / bincopy

bincopy

JSON →
library20.1.1pypypi✓ verified 22d ago

bincopy is a Python library for manipulating various binary information file formats, including Motorola S-Record, Intel HEX, TI-TXT, Verilog VMEM, ELF, and raw binary files. The current version is 20.1.1, and the library is actively maintained with regular updates.

pip install bincopy
INSTALL
IMPORT
SIG · BINCOPY
B
bincopy
serializationpythonv20.1.1
Install
1.8s avg
Import
236ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v20.1.1 · 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.95 runs
installs and imports cleanly · install 0.0s · import 0.246s · 20.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.226s · 21MB
18MB installed
● package 18MB
Code
Verified usage

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

BinFile
from bincopy import BinFile
from bincopy import File
The class for handling binary files was renamed from 'File' to 'BinFile' in more recent versions. Using 'File' will result in an AttributeError or NameError.

This quickstart demonstrates how to parse Intel HEX data from a string, add it to a `bincopy.BinFile` object, and then convert it to Motorola S-Record format. It also shows how to access basic information like memory addresses.

import bincopy import io # Example Intel HEX content as a string intel_hex_content = ( ":10010000214601360121470136007EFE09D219012146017E17C20001FF5F16002148011973\n" ":0C011000194E79234623965778239EDA3F0199\n" ":00000001FF" ) # Create an in-memory file-like object from the string hex_file_stream = io.StringIO(intel_hex_content) # Initialize BinFile and add the Intel HEX data bin_file = bincopy.BinFile() bin_file.add_ihex(hex_file_stream) # Convert to Motorola S-Record format srec_output = bin_file.as_srec() print("Motorola S-Record output:") print(srec_output) # Access properties like minimum and maximum address print(f"Minimum address: {bin_file.minimum_address:#x}") print(f"Maximum address: {bin_file.maximum_address:#x}")
bincopy --version
Debug
Known issues
breakingbincopy versions 20.x.x and newer require Python 3.9 or higher. Attempting to install or run these versions on Python 2.x will result in installation errors or runtime exceptions due to syntax incompatibility and dropped support.
fix
Upgrade your Python environment to Python 3.9 or a newer version (e.g., `python3.9 -m pip install bincopy`).
affects: >=20.0.0
gotchaThe primary class for handling binary files was `bincopy.File` in older versions. It has been renamed to `bincopy.BinFile` in current versions. Using `bincopy.File()` will raise an `AttributeError` or `NameError` if the older class is not available or if you're following outdated examples.
fix
Always use `bincopy.BinFile()` for instantiating the binary file object.
affects: All versions >=17.0.0 (approx.)
gotchaWhen adding data, methods like `add_ihex()` expect a file-like object. For directly adding a string containing Intel HEX or S-Record data, it's generally best to create an `io.StringIO` object from the string and pass that, or check for specific `add_*_string` methods if available (though `add_ihex` with `StringIO` is robust). Incorrectly passing a raw string to methods expecting a file object can lead to unexpected parsing errors.
fix
Wrap string content in `io.StringIO(your_string_data)` before passing it to methods like `add_ihex()` or `add_srec()`.
affects: All versions
Errors
Common errors & fixes
ERROR: Command errored out with exit status 1: python setup.py egg_info
Newer versions of bincopy (20.x.x and later) require Python 3.9 or higher, and this error often indicates an attempt to install or run it on an unsupported Python 2.x environment, leading to syntax incompatibilities during setup.
fix
Upgrade your Python environment to version 3.9 or newer (e.g., `python3.9 -m pip install bincopy`) to meet the library's minimum version requirements.
AttributeError: module 'bincopy' has no attribute 'File'
The primary class for handling binary files in older bincopy versions (`bincopy.File`) has been renamed to `bincopy.BinFile` in current versions.
fix
Always use `bincopy.BinFile()` for instantiating the binary file object instead of `bincopy.File()`.
AttributeError: 'str' object has no attribute 'read'
Methods like `bincopy.add_ihex()` or `bincopy.add_srec()` expect a file-like object, but a raw string containing the data was passed instead.
fix
Wrap the string content in an `io.StringIO` object before passing it to methods expecting a file-like object (e.g., `bincopy_object.add_ihex(io.StringIO(your_string_data))`).
ImportError: No module named 'bincopy'
The bincopy library is either not installed, installed in a different Python environment, or there's a Python path issue preventing the interpreter from finding the installed package.
fix
Ensure bincopy is installed for your active Python environment using `pip install bincopy`, and verify that the Python interpreter being used has access to the installation path.
Upgrade
Version history
20.1.1latest on PyPI · released Feb 24, 2026
Audit
Dependencies
argparse-addonsrequiredCommand-line argument parsing enhancements.
humanfriendlyrequiredHuman-readable data formatting (e.g., sizes).
pyelftoolsrequiredRequired for parsing and manipulating ELF files.
Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
1
Resources
bincopy — pip install bincopy · libregistry