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,
Pathobjects, 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
Config file
Run find-project-root --init to create .project-root.config.json5 in your project root to set default options.
Example defaults:
{
"path": "", // starting dir to search for project root (default: CWD)
"max_depth": 9, // max levels to traverse up
"markers": "" // custom marker files to look for
}
Note: CLI arguments always override config file.
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file find_project_root-2.2.0.tar.gz.
File metadata
- Download URL: find_project_root-2.2.0.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a32cc43794cc3e2c26a021a44a598aef88ddc78b7527881c6dddd078e6bc9b09
|
|
| MD5 |
77d8f46a7890c9088618a8edc1a59fb6
|
|
| BLAKE2b-256 |
3e6739e917239ea556758e24085ce6dfbc8812e82a2879a93dc036e737017e19
|
Provenance
The following attestation bundles were made for find_project_root-2.2.0.tar.gz:
Publisher:
publish-to-pypi-on-new-tag.yml on adamlui/python-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
find_project_root-2.2.0.tar.gz -
Subject digest:
a32cc43794cc3e2c26a021a44a598aef88ddc78b7527881c6dddd078e6bc9b09 - Sigstore transparency entry: 1396110117
- Sigstore integration time:
-
Permalink:
adamlui/python-utils@f6c733a6d7cf8b6d2c69b271088566fea27729c5 -
Branch / Tag:
refs/tags/find-project-root-2.2.0 - Owner: https://github.com/adamlui
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi-on-new-tag.yml@f6c733a6d7cf8b6d2c69b271088566fea27729c5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file find_project_root-2.2.0-py3-none-any.whl.
File metadata
- Download URL: find_project_root-2.2.0-py3-none-any.whl
- Upload date:
- Size: 21.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ef1371593b6ad762d7c0bc550e22834919978f0d6e4ea706864a2305817e5c4
|
|
| MD5 |
b7c0188382bd701b376f50a17a9142f7
|
|
| BLAKE2b-256 |
fd4071727fa0e39612c255d32411ada0c025c1a48eee72c27288dbf3ce227f3c
|
Provenance
The following attestation bundles were made for find_project_root-2.2.0-py3-none-any.whl:
Publisher:
publish-to-pypi-on-new-tag.yml on adamlui/python-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
find_project_root-2.2.0-py3-none-any.whl -
Subject digest:
6ef1371593b6ad762d7c0bc550e22834919978f0d6e4ea706864a2305817e5c4 - Sigstore transparency entry: 1396110122
- Sigstore integration time:
-
Permalink:
adamlui/python-utils@f6c733a6d7cf8b6d2c69b271088566fea27729c5 -
Branch / Tag:
refs/tags/find-project-root-2.2.0 - Owner: https://github.com/adamlui
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi-on-new-tag.yml@f6c733a6d7cf8b6d2c69b271088566fea27729c5 -
Trigger Event:
release
-
Statement type: