Skip to main content

Locate project root via custom markers.

Project description

> find-project-root

Locate project root via custom markers.

About

find-project-root is a lightweight utility that traverses up from a given path until it finds a project marker.

  • Minimal dependencies — only uses project-markers (~4 KB module)
  • Path flexibility — accepts strings, Path objects, or current working dir
  • Customizable markers — provide your own or use defaults
  • Multi-Python support — from Python 2.6 thru 3.15+

Installation

pip install find-project-root

API usage

import find_project_root

# Find from current dir
root = find_project_root()
print(root) # e.g. => /home/user/projects/your-project

Note: Most type checkers will falsely warn find_project_root is not a callable module because they are incapable of analyzing runtime behavior (where the module is replaced w/ a function for cleaner, direct access). You can safely suppress such warnings using # type: ignore.

Available options:

Name Type Description Default Value
path str, Path or None Starting directory to search from. None (current working dir)
max_depth int Max levels to traverse up. 9
markers List[str] or None Custom marker files to look for. project-markers list

Examples:

Start from specific path:

root = find_project_root(path='assets/images')

Limit search depth:

root = find_project_root(max_depth=3)

Use custom markers:

root = find_project_root(markers=['.git', 'pyproject.toml', 'requirements.txt'])

Combine options:

root = find_project_root(path='src', max_depth=5, markers=['manifest.json'])

MIT License

Copyright © 2026 Adam Lui

Related

🏷️ project-markers - Common project root markers.
📊 get-min-py - Get the minimum Python version required for a PyPI package.

More Python utilities / Discuss / Report bug / Report vulnerability / Back to top ↑

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

find_project_root-1.0.4.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

find_project_root-1.0.4-py2.py3-none-any.whl (5.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file find_project_root-1.0.4.tar.gz.

File metadata

  • Download URL: find_project_root-1.0.4.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for find_project_root-1.0.4.tar.gz
Algorithm Hash digest
SHA256 8abec4ea45b6e992f870d0f47e1cdfb01e42ee789d57e2c78a467978add9eb0d
MD5 5a21e121f73e838026b7551f7676c7e4
BLAKE2b-256 dbcb4891bc1ee059b5a96b77f39c6804ca8a9ff29f71cbb3537fc59295234836

See more details on using hashes here.

File details

Details for the file find_project_root-1.0.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for find_project_root-1.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 32c6eb59079df26cb84f7c9eb8df0ef7466686a1bb0041c1320ddd6a251cd577
MD5 05d708dfff17fb469af3421d119656b0
BLAKE2b-256 a23bcffadde40f8b4af908ef7530a7ee93bd8485522950aa2ffbec9e7dae450b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page