Skip to main content

path_cfg_manager

A lightweight Python package that auto-detects your project root directory and provides convenience functions for accessing common subdirectories (data/, models/, conf/, logs/).

How It Works

On import, path_cfg_manager determines the project root by:

  1. Checking the ENTRY_FILEPATH environment variable, or
  2. Locating the /src/ segment in sys.argv[0] and using the parent as the project root.

It then automatically adds <project_root>/src to sys.path.

ENTRY_FILEPATH is parsed with the same logic as sys.argv[0], so it should point to a file path under <project_root>/src/.

Optional Path Override Config

If ~/.config/path_cfg_manager.json exists, the package reads it on import and uses any provided path overrides for data/, models/, conf/, and logs/. Omitted keys keep the default project-relative paths.

{
  "data_path": "/mnt/shared/data",
  "models_path": "/mnt/shared/models",
  "conf_path": "~/project-conf",
  "logs_path": "~/project-logs"
}

Installation

pip install path_cfg_manager

Or install from source:

pip install .

Usage

from path_cfg_manager import relative_data_path, relative_conf_path, local_config

# Get absolute path to a file in the data/ directory
csv_path = relative_data_path('input', 'data.csv')

# Get absolute path to a file in the conf/ directory
cfg_path = relative_conf_path('settings.yaml')

# Load and cache a JSON config from conf/
config = local_config('config.json')

API Reference

Path Functions

All path functions accept *args path components and return an absolute path.

Function Base directory
relative_project_path(*args) Project root
relative_data_path(*args) <project>/data/
relative_models_path(*args) <project>/models/
relative_conf_path(*args) <project>/conf/
relative_logs_path(*args) <project>/logs/

local_config(config_name='config.json') -> dict

Loads a JSON file from the conf/ directory and caches it. Subsequent calls with the same filename return the cached result.

License

MIT

Metadata

Release files for path-cfg-manager 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for path-cfg-manager 0.0.7
File Interpreter ABI Platform
path_cfg_manager-0.0.7-py3-none-any.whl Python 3 none any Details

Release files / path_cfg_manager-0.0.7-py3-none-any.whl

Download URL path_cfg_manager-0.0.7-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a41cf024e9d69da686b86657e051fa690a36f08e7c9d8e09f60629dfa910905
BLAKE2b-256 checksum
How to use checksums
428a83f2a82ffb66e5d45ef7c476ed38fa27ac54983aedf5135452904d52db11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release history Release notifications | RSS feed

This release

0.0.7 This release

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page