skillfed

rootpath

Python project/package root path detection.

rootpath v0.1.1 203.1K downloads/30d#9,638 on PyPI23
Permissive license MIT Abandoned released

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 rootpath

uv

uv add rootpath

poetry

poetry add rootpath

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: POSIXProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 3Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries

Tags

python project root detectionfind package root pathauto-detect project rootresolve python import pathssys.path helper utilityproject root marker detectionpython module import resolution
path-detectionimport-resolutionproject-utilities

More Libraries packages