--- id: pathspec version: "1.1.1" license: unclear license_treatment: copyleft maintenance: active --- # pathspec — Utility library for gitignore style pattern matching of file paths. License: copyleft · Maintenance: active · Popularity: top 100 on PyPI ## Install pip install pathspec uv add pathspec poetry add pathspec ## Description 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 pathspec matches file paths against gitignore-style patterns, enabling selective file filtering for backup, build, and version-control workflows. 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. [View on SkillFed](https://skillfed.io/packages/pathspec) · [View on PyPI](https://pypi.org/project/pathspec/)