Skip to main content

envbox

https://github.com/idlesign/envbox

PyPI - Version License Coverage Docs

Description

Detect environment type and work within.

Features

  • Environment type detection (extendable system);
  • Support for .env files;
  • Convenient os.environ proxying (with optional values casting into Python natives);
  • Automatic submodule-for-environment import tool;
  • Cosy per-thread settings container with environment var support;
  • CLI for environment probing.

Code sample

from envbox import get_environment

# Detect current environment type
# and get its object.
#
# Default detection sources:
# 1. ``PYTHON_ENV`` env variable
# 2. ``environment`` file contents
#
# By default this function will also try to read env variables from .env files.
env = get_environment()

env.name
# >> development

env.is_production
# >> False

env.get('HOME')  # The same as env['HOME'] and env.HOME
# >> /home/idle/

env.getmany('PYTHON')
# {'UNBUFFERED': '1', 'IOENCODING': 'UTF-8', 'PATH': ...}

.env files

Now you may want to put your environment vars into .env files (e.g.: .env, .env.development .env.production) to be read by envbox:

MY_VAR_1=value1
HOME=/home/other/

# comments are ignored, just as lines without definitions

# mathing quotes (" and ') are stripped
MY_QUOTED="some quoted "

# ${VARNAME} will be replaced by value from env (if available)
MY_VAR_2="${MY_QUOTED}"

# multiline with dangling quotes
MULTI_1="
line1
line2
"

# multiline classic
MULTI_2="line1
line2
line3"

# multiline as one line
MULTI_3="one\ntwo"

Read the docs for more examples.

CLI

$ envbox probe
# >> Detected environment type: development (Development)

$ envbox show
# >> [...]
# >> SHELL = /bin/bash
# >> [...]

!!! note envbox CLI requires click package available.

Documentation

https://envbox.readthedocs.io/

Download files

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

Source Distribution

envbox-2.0.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

envbox-2.0.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file envbox-2.0.0.tar.gz.

File metadata

  • Download URL: envbox-2.0.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for envbox-2.0.0.tar.gz
Algorithm Hash digest
SHA256 cc00b41740987938766604029e74b2e786616de56d9df32e1304005db2c57e7a
MD5 0788910fa0fec6d1ba9e3a25c56c506d
BLAKE2b-256 ba3bfb05f514fcc4c5c91d9c17197977a45d6195476583cd11bac5c81fd328fd

See more details on using hashes here.

File details

Details for the file envbox-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: envbox-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for envbox-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f56f68ba8698ad1922ef8947e8ee6a9f2a386221687893c01fbe99307fd9a852
MD5 dc19785785b004d5a6fcb10a67fc45ec
BLAKE2b-256 c198c0b751ab9dfc55c232ece781f53706f366c213ebfac800a315c0043b9c38

See more details on using hashes here.

Release history Release notifications | RSS feed

2.0.1

1 file

This release

2.0.0 This release

2 files

1.3.0

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page