skillfed

pathspec

Utility library for gitignore style pattern matching of file paths.

pathspec Copyleft license Active 232 v1.1.1 released

Install

pathspec on PyPI

pip

pip install pathspec

uv

uv add pathspec

poetry

poetry add pathspec

Package 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

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

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...

Read as markdown · JSON record · Source repository · Docs

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.
gitignore pattern matchingfile path filteringgitignore-style patternsselective file matchingpath specification libraryexclude files by patterngit ignore patterns python

Similar packages