Skip to main content

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.

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.3.tar.gz (9.7 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.3-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: envidia-0.1.3.tar.gz
  • Upload date:
  • Size: 9.7 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.3.tar.gz
Algorithm Hash digest
SHA256 22663a946a9da7b164eb6e0432a9f7a135d75e2b4144a8d94ee98f56b5af3e52
MD5 ed7f2ccfc2fff679502d76dc2c8efc74
BLAKE2b-256 a6344441d726e8ca83a3ff1bd967f1fce0719726c9c3a0f533e2415058d27ba3

See more details on using hashes here.

Provenance

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

Publisher: release.yml on luocfprime/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.3-py3-none-any.whl.

File metadata

  • Download URL: envidia-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.6 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 15d1009f6d702861078372c432c815cd82bcc53da7313d34b6528a63ce978907
MD5 a162736d2f89fa8177e541f3a3d14705
BLAKE2b-256 981b07fb3912408c696b48e601a42690d55e6e1fea0b5af969bd6e534bb6f1c4

See more details on using hashes here.

Provenance

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

Publisher: release.yml on luocfprime/envidia

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

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

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