Skip to main content

Project level environment variable management utility.

Project description

Envidia

Unit Tests Python Versions PyPI

Envidia is a command-line interface (CLI) tool for loading project-level environment variables and simplifying the setting of long environment variables with aliases.

Table of Contents

Install

To install Envidia, use pip:

pip install envidia

Features

1. Loading .env from a directory

Envidia allows you to load environment variables from a directory, replacing long and verbose declarations with simple commands.

load-demo

2. Set Environment Variables via Alias

Setting environment variables manually can be cumbersome. Envidia provides a convenient way to set them via alias.

❌: export CUDA_VISIBLE_DEVICES="0" ✅: source <(e --cuda 0) or simply es --cuda 0 if you have eval $(envidia install) in your .bashrc or .zshrc.

Put the following line in your .bashrc or .zshrc:

eval "$(envidia install --alias es)"

Specify which option is related to which environment variable in env.d/bootstrap.py:

from envidia import register_option

register_option("cuda", "CUDA_VISIBLE_DEVICES", default="0")

Use es to set environment variables specified in env.d. ( es is short for "env set").

alias-demo

3. Integration with Cookiecutter

Pack your project environment variables as a cookiecutter template to reuse them across different projects.

cookiecutter-demo

4. Pre-load and Post-load Hooks

Use hooks to verify path variables or add extra variables into the environment.

# env.d/bootstrap.py
from pathlib import Path

from envidia import Loader, register_option

register_option("cuda", "CUDA_VISIBLE_DEVICES", default="0")
register_option("foo", "FOO_PATH", default=".")


def pre_load(loader: Loader):
    # add extra variable into the environment
    # if hf_transfer is installed, set HF_TRANSFER=1
    if is_package_installed("hf_transfer"):
        loader.env_registry["HF_TRANSFER"] = "1"
    else:
        loader.env_registry["HF_TRANSFER"] = "0"


def post_load(loader: Loader):
    # validate a path must exist
    if not Path(loader.env_registry.get("FOO_PATH", "")).exists():
        raise RuntimeError("FOO_PATH must exist")

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

envidia-0.1.0.tar.gz (211.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

envidia-0.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file envidia-0.1.0.tar.gz.

File metadata

  • Download URL: envidia-0.1.0.tar.gz
  • Upload date:
  • Size: 211.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for envidia-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c2760245c184e18a6b0079f04b68905a024fda70b461a0666923bcf708739dc2
MD5 9b3e1ed1838e70dad3cb84d2318e85e0
BLAKE2b-256 8da7f16fd7f90be3b5e90f2e467e4028ec0acb7ff134862420894f9fd2f5f234

See more details on using hashes here.

Provenance

The following attestation bundles were made for envidia-0.1.0.tar.gz:

Publisher: release.yml on fkcptlst/envidia

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file envidia-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: envidia-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for envidia-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22ff80724a7c161e289f46fab788d1935f7092020f777e580e0a83a8fd4d01e2
MD5 5a0da3105e725af962c9b1bff3b9dafb
BLAKE2b-256 9cc353c715f9487ad23cbfdbb01476d4b332ce8b5293f390fe2cace01305a79b

See more details on using hashes here.

Provenance

The following attestation bundles were made for envidia-0.1.0-py3-none-any.whl:

Publisher: release.yml on fkcptlst/envidia

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page