Skip to main content

A easy why to mock your production environment variables during development in your project

Project description

varenv

current :green_heart: license python

A simple way to mock your environment variables during development.

Just add'em to the varenv.conf.json and have fun =). The varenv package will not overwrite any already existente environment variables.

This library was designed to be inbuilt in pojects that, when going to production, will consume environment variable, very commonly used in application that'll run in docker containers. So, they need something to mock these variable under development but that won't get in the way in production.

Usage

Create a file called 'varenv.conf.json' at your project's root path like this:

{
  "SRPC_SERVER": "127.0.0.1",
  "SRPC_SERVER_PORT": "2727",
  "ANY_OTHER_VARIABLE_I_DESIRE": 567865
}

now use it like this in your program:

import varenv.varenv as varenv

my_server_ip = varenv.get_env("SRPC_SERVER")
my_server_port = varenv.get_env("SRPC_SERVER_PORT")

# after a while, for some reason, something chaged your enviroment variables values
# then refresh it
varenv.refresh()
new_server_port = varenv.get_env("SRPC_SERVER_PORT")

If you want to change the location of the virenv.conf.json file, you can define a environment variable called VARENV_CONF_FILE_PATH to any path you desire.

You can do that in a variaty of ways, here is two exemples:

by python:

import os
os.environ['VARENV_CONF_FILE_PATH'] = '/folder/my_path/virenv.conf.json'
import varenv

by your .bashrc file:

VARENV_CONF_FILE_PATH=/folder/my_path/virenv.conf.json

by bash when calling your python program:

VARENV_CONF_FILE_PATH=/folder/my_path/virenv.conf.json python3 my_program.py

Author's Note

create by me, davincif, this project of first though the needs of a another professional project made by me. But it sounds so potentially useful the the community that I decided to open this package here freely distributed.

I have no intention to continue enhancing this project professionally, but would love to carry its development with the community if there's anyone interest.

So let me know if you want to help, or also if you need any formal concentiment to use this software, despite the fact that it's already free and open by terms of a very permissive license as zlib.


See also
  • Dependency Manager project: A simple way of managing pip dev and prod dependencies.
  • SimplestRPC project: A simple RPC for python - study project.

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

varenv-1.0.5.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

varenv-1.0.5-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file varenv-1.0.5.tar.gz.

File metadata

  • Download URL: varenv-1.0.5.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.2

File hashes

Hashes for varenv-1.0.5.tar.gz
Algorithm Hash digest
SHA256 4e441990840e9ec07ebd61e544211ddaba51754874841c0851addf4f2d41768e
MD5 6fa70fbb2a36496dc520039d26c61646
BLAKE2b-256 7e16e6d7566ab2a26a6309c46b4e8a5eabaf3d47a3ad2e654e5b18b914b298ab

See more details on using hashes here.

File details

Details for the file varenv-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: varenv-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.2

File hashes

Hashes for varenv-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a14a44b124af3c1f7df36f16c25ff9cc2de044a1365e05f847147ece28c48427
MD5 b5a79f00e94c0f624ad677df8da2b2f4
BLAKE2b-256 659507f0ee749a0420bce0ecd6fe4ee601c97100ad744e68dff48c3b6f73a9c1

See more details on using hashes here.

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