Metadata-Version: 2.4
Name: env-dir-bootstrap
Version: 1.0.0
Summary: A Python package that provides a simple way to bootstrap a directory environment variable with the content coming from the distribution package.
License: MIT License
         
         Copyright (c) 2026 Ronaldo Webb
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
License-File: LICENSE
Author: Ronaldo Webb
Author-email: ron@ronella.xyz
Requires-Python: >=3.14
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: logenrich (>=1.0.0,<2.0.0)
Description-Content-Type: text/markdown

# env-dir-bootstrap 1.0.0

> A Python library that bootstraps a directory from a distribution package into a path driven by an environment variable.

On first run the target directory is created and the specified package resources are copied into it. Subsequent runs are no-ops when the directory already exists.

## Prerequisites

- Python `^3.14`
- [Poetry](https://python-poetry.org/) `2.x`

## Installation

```bash
poetry add env-dir-bootstrap
```

## Usage

```python
from env_dir_bootstrap import EnvDirBootstrap

# Point MY_APP_DIR at a writable directory path via environment variable.
bootstrapper = EnvDirBootstrap(
    env_var="MY_APP_DIR",
    resources=["config.yaml", "templates/"],
    package="my_app.data",
)

# Create the directory and copy resources once (no-op if it already exists).
bootstrapper.setup()

# Resolve a resource path under the bootstrapped directory.
config_path = bootstrapper.resolve("config.yaml")
```

## Configuration

`EnvDirBootstrap` is configured through its constructor:

| Parameter   | Type              | Description                                                                   |
|-------------|-------------------|-------------------------------------------------------------------------------|
| `env_var`   | `str`             | Environment variable whose value is the target directory path.                |
| `resources` | `Sequence[str]`   | File or sub-directory names within `package` to copy on first bootstrap.      |
| `package`   | `str`             | Fully-qualified name of the package that contains the resources.              |

Logging is configured via `logging.ini` at the project root. The log file is written to `env_dir_bootstrap.log`.

## Development

### Architecture

```mermaid
graph TD
    A[Application] -->|instantiates| B[EnvDirBootstrap]
    B -->|reads| C[ENV_VAR]
    C -->|resolves to| D[Target Directory]
    B -->|first run: copies from| E[Distribution Package Resources]
    E -->|into| D
    B -->|resolve| F[Resource Path]
    D -->|contains| F
```

### Install dependencies

```bash
poetry install
```

### Run tests

```bash
poetry run pytest --cov=env_dir_bootstrap tests --cov-report html
```

### Format and lint

```bash
poetry run black env_dir_bootstrap
poetry run pylint env_dir_bootstrap
```

## Publishing to PyPI

### Prerequisites

- A [PyPI](https://pypi.org/) account with an API token.

### Configure the token

```bash
poetry config pypi-token.pypi <your-token>
```

### Build and publish

```bash
poetry publish --build
```

This builds the source distribution and wheel, then uploads them to PyPI in one step.

> **Note:** PyPI releases are immutable. Once a version is published, it cannot be overwritten.  
> To fix a mistake, yank the release via the PyPI web UI and publish a new version.

## [Changelog](CHANGELOG.md)

## Author(s)

**Ronaldo Webb** — ron@ronella.xyz

