Metadata-Version: 2.4
Name: path_cfg_manager
Version: 0.0.2
Summary: Auto-detect project root and provide convenient path accessors for data, models, conf, and logs directories
Author: zxh
License: MIT
Project-URL: Homepage, https://github.com/zxh1993/path_cfg_manager
Project-URL: Repository, https://github.com/zxh1993/path_cfg_manager.git
Project-URL: Issues, https://github.com/zxh1993/path_cfg_manager/issues
Keywords: path,project,directory,path-management,project-structure
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: OS Independent
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 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 `PROJECTPATH` environment variable, or
2. Locating the `/src/` segment in the running script's path and using the parent as the project root.

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

## Installation

```bash
pip install path_cfg_manager
```

Or install from source:

```bash
pip install .
```

## Usage

```python
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
