Registry / serialization / unix-ar

unix-ar

JSON →
library0.2.1pypypi✓ verified 85d ago

This package allows the reading and writing of AR (archiver) archive files, which are commonly used in Unix-like systems for static libraries and Debian packages. It is inspired by Python's standard library `tarfile` and `zipfile` modules. The library is currently in 'Beta' development status and primarily supports the BSD variant of the common AR archive format.

pip install unix-ar
INSTALL
IMPORT
SIG · UNIX-AR
U
unix-ar
serializationpythonv0.2.1
Install
1.5s 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.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.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

ArFile
from unix_ar import ArFile
from unix_ar import Archive
ArInfo
from unix_ar import ArInfo
open
from unix_ar import open

This quickstart demonstrates how to create a new AR archive, add files to it, and then read its contents and extract specific members using `unix_ar.open()` and `Archive` methods.

import unix_ar import os # Create some dummy files with open("file1.txt", "w") as f: f.write("This is file 1.") with open("file2.txt", "w") as f: f.write("This is file 2.") # Create an AR archive with unix_ar.open("my_archive.ar", "w") as ar_file: ar_file.add("file1.txt") ar_file.add("file2.txt", arcname="renamed_file2.txt") print("Archive 'my_archive.ar' created with file1.txt and renamed_file2.txt.") # Read from the archive with unix_ar.open("my_archive.ar", "r") as ar_file: print("\nMembers in the archive:") for member in ar_file.getmembers(): print(f" - Member name: {member.name}, size: {member.size} bytes") if member.name == "renamed_file2.txt": extracted_data = ar_file.extractfile(member).read().decode('utf-8') print(f" Content of {member.name}: '{extracted_data}'") # Clean up dummy files and archive os.remove("file1.txt") os.remove("file2.txt") os.remove("my_archive.ar") print("\nCleaned up dummy files and archive.")
Debug
Known issues
deprecatedThe library has not been updated since June 2019 and is marked as 'Development Status :: 4 - Beta' on PyPI. There may be a lack of active maintenance and support for newer Python versions or bug fixes.
fix
Evaluate if the current feature set meets your needs. For critical projects, consider alternatives or be prepared to maintain a fork.
affects: <=0.2.1
gotchaThe library primarily supports the BSD variant of the AR archive format. Other variants (e.g., AIX, GNU ar, System V) may not be compatible, leading to errors or corrupted archives when reading/writing.
fix
Verify the AR archive format you are working with. If you need to handle non-BSD variants, this library may not be suitable. The `ar` command line tool itself has several variants for specific platforms.
affects: <=0.2.1
gotchaWhen interacting with AR files created by the `ar` command-line tool, especially with the GNU `ar`'s default 'deterministic mode' (`-D`), metadata like UIDs, GIDs, and modification times might be set to zero. This library may preserve or re-create full metadata, which could lead to inconsistencies if you expect 'deterministic' output.
fix
Be aware of the `ar -D` flag's implications if you're mixing Python `unix-ar` operations with external `ar` command usage. If precise metadata is crucial, explicitly check and handle it.
affects: All versions
Upgrade
Version history
0.2.1latest on PyPI · released Jun 12, 2019
Audit
Dependencies
pythonrequiredRequires Python 3.6 or later.
Agent activity
23 hits · last 30 days
node
20
Amazon
1
OpenAI (training)
1
Resources
unix-ar — pip install unix-ar · libregistry