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.

  • Lightweight — < 100 KB
  • Path flexibility — accepts strings, Path objects, or current working dir
  • Customizable markers — provide your own or use defaults
  • Multi-env support — use via API or CLI

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'])

Command line usage

find-project-root  # or projectroot
# e.g. => 'e:\python\utils\translate-messages'

Command line options:

Option Description
-p, --path Starting dir to search for project root (default: CWD)
-d, --max-depth Max levels to traverse up (default: 9)
-m, --markers Custom marker files to look for (default: project-markers list)
-h, --help Show help screen
-v, --version Show version
--docs Open docs URL

Examples:

Start from specific path:

find-project-root --path="assets/images"

Limit search depth:

find-project-root --max_depth=3

Use custom markers:

find-project-root --markers=.git,pyproject.toml,requirements.txt

Combine options:

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-2.1.1.tar.gz (17.3 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-2.1.1-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: find_project_root-2.1.1.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for find_project_root-2.1.1.tar.gz
Algorithm Hash digest
SHA256 c650c6a40d5701889c5894f7b987ebc8e62b3a38d145a8acd07f4ab0bc5681e5
MD5 abbdbf3f65671b7c298c877c200c5668
BLAKE2b-256 c88dbb153a40371b6b9a92bded294c9fc9d18481af20d3f1ac6f9a73b3dcfeae

See more details on using hashes here.

Provenance

The following attestation bundles were made for find_project_root-2.1.1.tar.gz:

Publisher: publish-to-pypi-on-new-tag.yml on adamlui/python-utils

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file find_project_root-2.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for find_project_root-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d8241fe60e5ab9904e94be8d2d06e95d1c147df2b36e064d2289b702e3d9ae6f
MD5 14300aa4e55b37976c0ff779c1a553b1
BLAKE2b-256 928cf8169fac798081257cbc49d08fc43b0c9ae7a6ec3b94768f0544f17a0260

See more details on using hashes here.

Provenance

The following attestation bundles were made for find_project_root-2.1.1-py3-none-any.whl:

Publisher: publish-to-pypi-on-new-tag.yml on adamlui/python-utils

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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