pathspec
Utility library for gitignore style pattern matching of file paths.
Decision gist · record as of 2026-08-14
Yes. Pathspec is a stable, actively maintained library with zero dependencies, no known vulnerabilities, and broad Python version support. It solves a concrete problem (gitignore-style pattern matching) that many tools need. The copyleft license is permissive for most use cases as long as you credit the library and release any modifications. Install it if you need to match files against gitignore patterns.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low install friction with no runtime dependencies.
- Actively maintained; last commit 2026-06-04, 109 days since latest release.
- Supports Python 3.9 through 3.14 and PyPy.
License · maintenance · safety
copyleft license (copyleft) — Licensed under Mozilla Public License 2.0 (copyleft). You may use pathspec in any project without affecting the larger work's license, provided you give credit and release any custom changes made to pathspec itself.
last release 2026-04-27 (109 days) · last repo commit 2026-06-04 · 232 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 742,847,330 downloads/mo, #40 on PyPI
Alternatives
Verify before relying
pip install pathspec
from pathspec import PathSpec
spec = PathSpec.from_lines('gitignore', ['*.pyc', '!important.pyc'])
matches = spec.match_files(['test.pyc', 'important.pyc'])- Whether optional backends (google-re2, hyperscan) are pre-installed or must be added separately for performance gains
- Specific performance characteristics when matching against large directory trees (thousands of files)
What it is and what it does
Pathspec is a utility library that compiles and applies gitignore-style patterns to file paths. It wraps pattern implementations and provides a high-level interface for matching individual files, sets of files, or entire directory trees against a set of patterns. The library supports both standard gitignore semantics (as documented) and GitIgnoreSpec, which replicates Git's actual behavior more closely, including edge cases where Git allows including files from excluded directories.
The package has no required runtime dependencies and installs as a pure Python wheel. It supports optional backends (google-re2 and hyperscan) to accelerate pattern matching when processing many files, though the default Python re module works out of the box. The library is actively maintained, supports Python 3.9 through 3.14, and is widely used (top 100 on PyPI).
Use it for
- Implement selective file backup by loading gitignore patterns to determine which files to include or exclude
- Build a file linter or formatter that respects project .gitignore rules to skip ignored files
- Create a deployment tool that filters files to upload based on gitignore-style patterns
- Validate or test that a directory tree matches expected ignore patterns before processing
- Replicate Git's file-matching behavior in non-Git tools without shelling out to git commands
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Pathspec is a stable, actively maintained library with zero dependencies, no known vulnerabilities, and broad Python version support. It solves a concrete problem (gitignore-style pattern matching) that many tools need. The copyleft license is permissive for most use cases as long as you credit the library and release any modifications. Install it if you need to match files against gitignore patterns.
Install
pathspec on PyPI
Before you install
Low install friction with no runtime dependencies. Actively maintained; last commit 2026-06-04, 109 days since latest release. Supports Python 3.9 through 3.14 and PyPy.
License in practice
Licensed under Mozilla Public License 2.0 (copyleft). You may use pathspec in any project without affecting the larger work's license, provided you give credit and release any custom changes made to pathspec itself.
Quickstart
pip install pathspec
from pathspec import PathSpec
spec = PathSpec.from_lines('gitignore', ['*.pyc', '!important.pyc'])
matches = spec.match_files(['test.pyc', 'important.pyc'])
Verify before relying
- Whether optional backends (google-re2, hyperscan) are pre-installed or must be added separately for performance gains
- Specific performance characteristics when matching against large directory trees (thousands of files)
Package facts
| License | copyleft license copyleft |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 109 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 742,847,330 / month, #40 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)Operating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python ModulesTopic :: Utilities |
Evidence: pathspec-1.1.1-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “gitignore pattern matching”
- pathspecMatches file paths against gitignore-style patterns, supporting both…
- gitmatchGitmatch implements gitignore-style pattern matching for file paths,…
- gitignorantParses .gitignore files and matches file paths against the parsed…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also gitmatch · py-walk · gitignorant · gitignorefile · gitignore-parser · igittigitt · ignore-python · gemfileparser2 · google-re2-stubs · dirsync