Skip to main content

Lightweight project root discovery for Python projects and CLI workflows

Project description

rootscope-finder

A lightweight, dependency-free project root finder for Python and CLI usage.

Why

This package discovers a project root by walking upward from a start path and matching common project marker files/directories (for example .git, pyproject.toml, package.json).

Install

From PyPI

pip install rootscope-finder

From GitHub

pip install "git+https://github.com/LoganJinDev/rootscope-finder.git"

CLI

find-root
find-root /path/to/any/subdir
find-root /tmp --strict
find-root --json

Python API

from rootscope_finder import find_project_root, require_project_root

root = find_project_root()
# or
root = require_project_root()

Python Usage Examples

from rootscope_finder import find_project_root

# Find from current dir
root = find_project_root()

# Start from a 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"],
)

# Priority search by project name (searches only in provided workspace roots)
root = find_project_root(
    project_name="TestProject",
    workspace_roots=["/Users/xxx/Desktop/LoganJinDev"],
)

Behavior

  • PROJECT_ROOT env var can override detection (default enabled).
  • --no-env disables env override.
  • --marker can add custom markers.
  • --strict returns exit code 1 when not found.

CLI Usage Examples

# Find from current dir
find-root

# Start from specific path
find-root assets/images

# Limit search depth
find-root --max-depth 3

# Add custom markers (repeat --marker)
find-root --marker .git --marker pyproject.toml --marker requirements.txt

# Combine options
find-root src --max-depth 5 --marker manifest.json

# Priority search by project name (no full-disk scan)
find-root --project-name TestProject --workspace-root /Users/xxx/Desktop/LoganJinDev

Development

python -m pip install -e .
pytest
python -m build

License

MIT

Copyright © 2026 https://github.com/LoganJinDev

Publish to PyPI

This repository includes .github/workflows/publish-pypi.yml.

  1. In PyPI, create project rootscope-finder and configure Trusted Publisher for this GitHub repo.
  2. Create and push a version tag:
git tag v0.1.1
git push origin v0.1.1
  1. After workflow success, users can install directly:
pip install rootscope-finder

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

rootscope_finder-0.2.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

rootscope_finder-0.2.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file rootscope_finder-0.2.0.tar.gz.

File metadata

  • Download URL: rootscope_finder-0.2.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for rootscope_finder-0.2.0.tar.gz
Algorithm Hash digest
SHA256 585b5432fba1ef19cd5f6ecbb677a6adeebe1858bc53508041aa2d57cd374559
MD5 65ad7289cb285dc06ca57bc297befa5a
BLAKE2b-256 5f3275a634cfa2b075991bc7ad62d1c71c147f1aa466f053b928582fc441682b

See more details on using hashes here.

File details

Details for the file rootscope_finder-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rootscope_finder-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70b2ed275fc16a3b3f95c4aea3c5d3f18e144c3c9807d7c9e62e52fccb7945ba
MD5 334aeea9f7299bbc3db4fadb49e633e9
BLAKE2b-256 99e4b67e253c8e022f3b4bf7723f6d41636d71d7161d1f9e27496865821ecd17

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