Skip to main content

Detect environment type and work within.

Project description

release lic coverage


Detect environment type and work within.


  • 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()
# >> development

# >> False

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

# {'UNBUFFERED': '1', 'IOENCODING': 'UTF-8', 'PATH': ...}

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)

# multiline with dangling quotes
MULTI_1 = "

# multiline classic
MULTI_2 = "line1

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

Read the docs for more examples.


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

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

Note: envbox CLI requires click package available.

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

envbox-1.3.0.tar.gz (19.9 kB view hashes)

Uploaded source

Built Distribution

envbox-1.3.0-py3-none-any.whl (11.4 kB view hashes)

Uploaded 3 8

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page