rootpath
Python project/package root path detection.
What it is and what it does
Rootpath is a utility library that automatically detects the root directory of a Python project by looking for common marker files and folders such as `.git`, `requirements.txt`, `setup.py`, and others. It works from any nested module within the project and returns the detected root path. The package also provides a helper function to prepend the root path to `sys.path`, which can simplify module imports across a project without relying on relative imports.
The library is designed to solve the problem of Python's import system becoming fragile when scripts are run from different working directories. By detecting and adding the project root to the module search path, it allows imports to work consistently regardless of where a script is executed from. The detection logic can be overridden if the default markers don't match your project structure.
Use it for:
- Detect project root in a multi-level package structure to enable consistent absolute imports from any nested module.
- Add project root to sys.path in test runners or utility scripts to avoid import errors when executed from different directories.
- Resolve import paths in research or data-science projects where scripts may be run from various working directories.
- Configure logging or resource paths relative to the detected project root rather than the current working directory.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Detects a Python project or package root directory by scanning for typical marker files and folders, and optionally adds that path to sys.path to resolve import issues.
No. While the package is simple and has low install friction, it is abandoned (last release 2019, last commit 2022) and will not receive updates. For new projects, consider using modern alternatives like `importlib.resources` or `pathlib` with `__file__` inspection, or rely on proper package installation and relative imports. Only install if you are maintaining legacy code that already depends on it.
Install
rootpath on PyPI
pip
pip install rootpathuv
uv add rootpathpoetry
poetry add rootpathInstalling rootpath
Before you install
Low install friction with a pure-Python wheel. However, the package is abandoned—last release was in 2019 and last commit in 2022—so it will not receive updates or security patches if issues arise.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
import rootpath
# Detect project root from any nested module
root = rootpath.detect()
print(root) # e.g., '/home/me/projects/py-foo'
# Optionally add root to sys.path for easier imports
rootpath.append()
Verify before relying
- Whether the package correctly handles monorepos or projects with non-standard root markers.
- Performance impact when scanning deeply nested directory structures for root markers.
- Compatibility with modern Python versions beyond what classifiers declare.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 9 — six, coloredlogs, termcolor, colour-runner, deepdiff, pygments, tox, coverage, codecov |
| Maintenance | abandoned — 2,714 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 203,079/month — #9,638 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: rootpath-0.1.1-py3-none-any.whl
Keywords: python, utlity, common, root, rootpath, root-path, detect, autodetect, auto-detect, project-root, project-root-path, package-root, package-root-path
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
rootutilsFinds your project root directory and…
permissive · top 15,000 on PyPI
pyrootutilsFinds your project root directory and…
permissive · top 5,000 on PyPI
urllib3-secure-extraDetects whether urllib3 was installed with the…
permissive · top 5,000 on PyPI
locateProvides utilities to locate the current Python…
unclear · top 5,000 on PyPI
emportEmport provides a single function to import…
permissive · top 15,000 on PyPI
lib-detect-testenvDetects whether code is running in a test…
permissive · top 5,000 on PyPI
pyinvokeInvokes Python functions by full module path…
permissive · top 15,000 on PyPI
conda-injectInjects a conda environment's packages into the…
unclear · top 15,000 on PyPI
deptryScans Python projects to detect unused,…
permissive · top 5,000 on PyPI
codefindCodefind locates code objects by filename and…
unclear · top 15,000 on PyPI