A Python package that provides a simple way to bootstrap a directory environment variable with the content coming from the distribution package.
Project description
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
2.x
Installation
poetry add env-dir-bootstrap
Usage
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
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
poetry install
Run tests
poetry run pytest --cov=env_dir_bootstrap tests --cov-report html
Format and lint
poetry run black env_dir_bootstrap
poetry run pylint env_dir_bootstrap
Publishing to PyPI
Prerequisites
- A PyPI account with an API token.
Configure the token
poetry config pypi-token.pypi <your-token>
Build and publish
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
Author(s)
Ronaldo Webb — ron@ronella.xyz
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file env_dir_bootstrap-1.0.0.tar.gz.
File metadata
- Download URL: env_dir_bootstrap-1.0.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.14.4 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b704a27d6acf9fe173f001bc93af8dc5d9beb7bf9ca00c885d13a3c64bfb4091
|
|
| MD5 |
0e37dbbf1d1d70022283b9c3e6c25b09
|
|
| BLAKE2b-256 |
06c13bf3ed4cc0e559ab64ca882a6012f01552c51c0c2c28513088e68b09f4da
|
File details
Details for the file env_dir_bootstrap-1.0.0-py3-none-any.whl.
File metadata
- Download URL: env_dir_bootstrap-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.14.4 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
600aeabdd507056edd897b7e64a4f718c7d34e91ff8a27b06a36ec8eb8a49664
|
|
| MD5 |
a2cfcced06d69c01a713fc165b06e563
|
|
| BLAKE2b-256 |
86d408b3d68fc9210462d2ec49bf3cfaf9512e89532cd690dbc7bbd4eef0c51b
|