skillfed

pyxattr

Filesystem extended attributes for python

pyxattr v0.8.1 86.3K downloads/30d#13,870 on PyPI33
Copyleft license LGPL AGING released

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 pyxattr

uv

uv add pyxattr

poetry

poetry add pyxattr

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)Operating System :: MacOS :: MacOS XOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python ModulesTopic :: System :: Filesystems

Tags

extended attributes filesystemxattr pythonfile metadata attributeslinux xattr accessfilesystem extended attributespython xattr modulefile attribute manipulation
filesystem-metadatac-extension

More Python Modules packages