pathspec
Utility library for gitignore style pattern matching of file paths.
Install
pathspec on PyPI
pip
pip install pathspecuv
uv add pathspecpoetry
poetry add pathspecPackage facts
| License | not declared (copyleft) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 108 days since the last release |
| Last repo commit | |
| First released | |
| Popularity | one of the 100 most-downloaded packages on PyPI (30-day window, as of 2026-08-13) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-13) |
Evidence: pathspec-1.1.1-py3-none-any.whl
About pathspec
from the package's own PyPI description — quoted content, verbatim
PathSpec
pathspec is a utility library for pattern matching of file paths. So far this
only includes Git's gitignore_ pattern matching.
.. _gitignore: http://git-scm.com/docs/gitignore
Tutorial
Say you have a "Projects" directory and you want to back it up, but only certain files, and ignore others depending on certain conditions::
>>> from pathspec import PathSpec
>>> # The gitignore-style patterns for files to select, but we're including
>>> # instead of ignoring.
>>> spec_text = """
...
... # This is a comment because the line begins with a hash: "#"
...
... # Include several project directories (and all descendants) relative to
... # the current directory. To reference only a directory you must end with a
... # slash: "/"
... /project-a/
... /project-b/
... /project-c/
...
... # Patterns can be negated by prefixing with exclamation mark: "!"
...
... # Ignore temporary files beginning or ending with "~" and ending with
... # ".swp".
... !~*
... !*~
... !*.swp
...
... # These are python projects so ignore compiled python files from
... # testing.
... !*.pyc
...
... # Ignore the build directories but only directly under...
AI interpretation — verify before relying
AI-generated interpretation of the package facts above; every digit, version, license, or vulnerability id it cites is grounded in the facts already shown on this page
pathspec matches file paths against gitignore-style patterns, enabling selective file filtering for backup, build, and version-control workflows.
Installs cleanly with no runtime dependencies and low friction; actively maintained with a recent release (108 days ago) and steady repository activity.
Licensed under Mozilla Public License 2.0 (copyleft), requiring you to release custom changes to pathspec itself, but permitting use in closed or open source projects without affecting the larger work's license.
Usage
pip install pathspec
from pathspec import PathSpec
spec = PathSpec.from_lines('gitignore', ['*.pyc', '*.swp'])
matches = set(spec.match_files(['file.py', 'file.pyc', 'file.swp']))
Requires Python 3.9 or later.
Verdict: A stable, well-maintained utility in the top 100 PyPI packages with zero known vulnerabilities, zero dependencies, and straightforward installation. The copyleft license is permissive for most use cases but requires releasing modifications to pathspec itself.
Needs verification
- Performance characteristics when matching thousands of files against complex pattern sets without optional backends (google-re2, hyperscan).
- Real-world adoption rate and integration patterns in popular build and CI/CD tools.
Similar packages
permissive · top 1,000 on PyPI
packageurl-pythonpermissive · top 1,000 on PyPI
dateparserpermissive · top 1,000 on PyPI
unidiffpermissive · top 1,000 on PyPI
regexpermissive · top 100 on PyPI
yamllintcopyleft · top 1,000 on PyPI
pytokenspermissive · top 1,000 on PyPI
platformdirspermissive · top 100 on PyPI
SQLAlchemy-Utilspermissive · top 1,000 on PyPI
bcryptpermissive · top 1,000 on PyPI