pyxattr
Filesystem extended attributes for python
What it is and what it does
pyxattr is a Python extension module that exposes the extended attributes API available on Linux and macOS filesystems. It wraps the underlying C functions to let you read, write, list, and delete metadata attributes attached to files and directories—attributes that live outside the standard Unix permission model. These are commonly used for storing MIME types, custom tags, access control lists, and other filesystem-level metadata.
The module is a thin, direct binding to the OS-level calls, with no runtime dependencies beyond the Python standard library. It requires compilation against your system's C headers and a C compiler at install time, which makes it less portable than pure-Python packages but necessary for direct filesystem access. It supports Python 3.7+ and PyPy 3.7+, is marked Production/Stable, and has no known vulnerabilities.
Use it for:
- Store and retrieve custom metadata (MIME types, tags, comments) on files without modifying the files themselves
- Implement filesystem-level access control or security labels on Linux systems
- Build backup or archival tools that preserve extended attributes across systems
- Develop file management utilities that tag or annotate files with searchable attributes
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides Python access to extended attributes (xattr) on filesystem objects in Linux and macOS, allowing you to read, write, list, and remove metadata beyond standard file permissions.
Yes, if you need direct access to extended file attributes on Linux or macOS and are willing to handle the compilation requirement. The package is stable and production-ready with no known vulnerabilities. No, if you cannot install a C compiler or Python development headers in your environment, or if your filesystem does not support extended attributes. Consider pre-built distributions from your OS package manager to avoid building from source.
Install
pyxattr on PyPI
pip
pip install pyxattruv
uv add pyxattrpoetry
poetry add pyxattrInstalling pyxattr
Before you install
High install friction: requires a C compiler and Python development headers to build from source. The package is aging (last release 2023-04-17), though the repository remains active with recent commits. Pre-built distributions may be available from your OS package manager, which sidesteps compilation.
License in practice
Licensed under LGPL 2.1 or later (copyleft). You may use and modify the package freely, but any derivative works must also be distributed under LGPL 2.1 or a compatible license. Linking against this library in a proprietary application requires careful license review.
Quickstart
pip install pyxattr
import xattr
xattr.setxattr('file.txt', 'user.comment', 'My note')
print(xattr.getxattr('file.txt', 'user.comment'))
Requires a C compiler and Python development libraries installed before pip install will succeed. Linux (kernel v2.4 or later) or macOS with xattr-supporting filesystems (XFS, ext2/ext3/ext4, etc.) required at runtime.
Verify before relying
- Whether pre-built wheels are available for common platforms to avoid compilation
- Current compatibility with Python versions beyond 3.12 (description notes testing up to 3.12)
- Whether the aging maintenance status (1215 days since last release) affects reliability for new use cases
Package facts
| License | LGPL (copyleft) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | aging — 1,215 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 86,334/month — #13,870 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyxattr-0.8.1.tar.gz
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
xattrxattr is a Python wrapper for reading and…
permissive · top 5,000 on PyPI
fusepyfusepy provides Python bindings to FUSE…
permissive · top 15,000 on PyPI
pathlib-abcProvides abstract base classes for implementing…
permissive · top 1,000 on PyPI
xrootdProvides Python bindings to XRootD, a…
copyleft · top 5,000 on PyPI
pathlib2Backport of Python's standard pathlib module…
permissive · top 5,000 on PyPI
fatfs-ngfatfs-ng wraps ChaN's FatFS library to create,…
permissive · top 5,000 on PyPI
morefsmorefs provides fsspec-based filesystem…
permissive · top 15,000 on PyPI
argparse-extExtends Python's standard argparse module with…
copyleft · top 15,000 on PyPI
pyobjc-framework-NetFSProvides Python bindings to macOS's NetFS…
permissive · top 15,000 on PyPI
littlefs-pythonlittlefs-python provides a Python interface to…
unclear · top 5,000 on PyPI