fpr
Find Project Root — heuristically detect the root of a project directory.
Installation
pip install modularizer-fpr
Usage
Command Line
# From current directory
fpr
# From a specific path
fpr /path/to/some/nested/folder
# Show scoring for all candidate directories
fpr --verbose
# Output relative path
fpr --rel
# Custom weights (repeatable)
fpr -w "./Cargo.toml:100" -w "target:-50"
# Weights as JSON string
fpr --weights-json '{"./Cargo.toml": 100, "target": -50}'
# Weights from JSON file
fpr --weights-file my-weights.json
# Skip default weights entirely
fpr --no-defaults -w "./package.json:100"
# Combine sources (priority: defaults < file < json < -w)
fpr --weights-file base.json -w "./my-marker:200"
Python API
from fpr import find_project_root, score_all, score_directory, WEIGHTS
# Find the project root (returns a Path)
root = find_project_root()
root = find_project_root("/some/nested/path")
root = find_project_root(verbose=True) # prints all scores
# Get scores for all candidate directories
best_path, best_score, all_scores = score_all("/some/nested/path")
# best_path: Path to highest-scoring directory
# best_score: int score of that directory
# all_scores: dict mapping Path -> score for all candidates
# Score a single directory
score = score_directory("/my/project")
# Use custom weights
custom_weights = {
"./Cargo.toml": 100, # strongly prefer Rust projects
"target": -50, # penalize being inside target/
}
root = find_project_root(weights=custom_weights)
How It Works
fpr walks up from the starting directory, scoring each ancestor based on common project markers.
Pattern Types
Weights use glob-like patterns with * (any except /) and ** (any including /):
| Pattern | Matches |
|---|---|
./foo |
Directory contains a child named foo |
foo |
Directory itself is named foo |
**/foo/**/ |
foo appears anywhere in ancestry |
**/foo/ |
Direct parent is foo |
**/foo/*/ |
Grandparent is foo |
Default Weights
Positive weights (project indicators):
- Config files:
./pyproject.toml,./package.json,./Cargo.toml,./go.mod, etc. - VCS directories:
./.git,./.hg,./.svn - Lock files:
./poetry.lock,./yarn.lock,./package-lock.json - Dev tooling:
./Dockerfile,./Makefile,./.editorconfig
Negative weights (penalties):
- Name patterns:
src,dist,node_modules,venv, etc. - Parent patterns:
**/venv/**/,**/node_modules/**/, etc.
Returns the highest-scoring directory, or the starting directory if no strong signals are found.
License
Unlicense
Metadata
Release files for modularizer-fpr 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| modularizer_fpr-0.1.0.tar.gz | 6.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| modularizer_fpr-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.1 kB
Release files / modularizer_fpr-0.1.0.tar.gz
| Download URL | modularizer_fpr-0.1.0.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
018e4faf8fc1c1442e0f05a63f3c9f33f107f2c54b27eb65987531d609899cd6
|
|
BLAKE2b-256 checksum How to use checksums |
33bedb34d6b88a8473fa49552d363c1a7fc079f6e4211f95f3325cd278fedefd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 10, 2025.
Transparency logRelease files / modularizer_fpr-0.1.0-py3-none-any.whl
| Download URL | modularizer_fpr-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d6f4402df53b64d2c9c17a9e7d9507ddaf52bc9085a93cacb67d10f69fa51e1
|
|
BLAKE2b-256 checksum How to use checksums |
82a8fdc142d8903f3881aab8b30ac894d0113bbd315b632038fcf6d0bad62a6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 10, 2025.
Transparency log