Package: darcy-bingley-wickham
publish testing package - do not useenvkey-pythonIntegrateEnvKeywith your Python projects to keep API keys, credentials, and other configuration securely and automatically in sync for developers and servers.Compatible with Python 2 and 3.Installation$pipinstallenvkeyThen at the entry point of your application:importenvkeyForDjango, you should put the above inmanage.pyandwsgi.py. Also see thenote on casting belowif you're migrating fromdjango-environ.UsageGenerate anENVKEYin theEnvKey App. Then setENVKEY=..., either in a gitignored.envfile in the root of your project (in development) or in an environment variable (on servers).Now all your EnvKey variables will be available inos.environ.Or as a bit of syntactic sugar to avoid needing to always importosalongsideenvkey, you can callenvkey.get, which delegates toos.environ.get. For example:importenvkeymy_var=envkey.get("SOME_ENVKEY_VAR")ErrorsThe package will throw an error if anENVKEYis missing or invalid.ExampleAssume you haveSTRIPE_SECRET_KEYset for thedevelopmentenvironment in the EnvKey App. You generate a local developmentENVKEY.In your project'sgitignored.envfile:# .envENVKEY=GsL8zC74DWchdpvssa9z-nk7humd7hJmAqNoAInapp.py:stripe.api_key=os.environ['STRIPE_SECRET_KEY']Or using theenvkey.getsugar:stripe.api_key=envkey.get('STRIPE_SECRET_KEY')NowSTRIPE_SECRET_KEYwill stay automatically in sync for all the developers on your team.For a server, generate a serverENVKEYin the EnvKey App, then set theENVKEYas an environment variable instead of putting it in a.envfile.Now your servers will stay in sync as well. If you need to rotate yourSTRIPE_SECRET_KEYyou can do it in a few seconds in the EnvKey App, restart your servers, and you're good to go. All your team's developers and all your servers will have the new value.Overriding VarsThis package will not overwrite existing environment variables or additional variables set in a.envfile. This can be convenient for customizing environments that otherwise share the same configuration. You can also usesub-environmentsin the EnvKey App for this purpose.Working OfflineThis package caches your encrypted config in development so that you can still use it while offline. Your config will still be available (though possibly not up-to-date) the next time you lose your internet connection. If you do have a connection available, envkey will always load the latest config. Your cached encrypted config is stored in$HOME/.envkey/cacheFor caching purposes, it's assumed you're in development mode when a.envfile exists in the root of your project.Disabling autoloadIf you'd like to have more control over how your config is loaded, you can prevent the package from auto-loading on import by settingENVKEY_DISABLE_AUTOLOAD=1either in your.envfile or as an environment variable.You can then load your config explicitly like this:importenvkeyenvkey.load(cache_enabled=True,dot_env_enabled=True,dot_env_path=".env")For even more flexibility, you can just fetch your config as a dict (without setting it onos.environ) like this:importenvkeyimportosconfig=envkey.fetch_env(os.environ['ENVKEY'],cache_enabled=True)django-environ castingIf you happen to be migrating fromdjango-environto EnvKey, watch out for the fact that EnvKeydoes notcast variables to booleans or any other non-string types asdjango-environdoes. All variables set by EnvKey will bestringsin accordance with the cross-platform environment variable standard. See:https://twitter.com/manishsinhaha/status/1265746057377361921envkey-fetch binariesIf you look in theextdirectory of this package, you'll find a number ofenvkey-fetchbinaries for various platforms and architectures. These are output by theenvkey-fetch Go library. It contains EnvKey's core cross-platform fetching, decryption, verification, web of trust, redundancy, and caching logic. It is completely open source.x509 error / ca-certificatesOn a stripped down OS like Alpine Linux, you may get anx509: certificate signed by unknown authorityerror when this package attempts to load your config.envkey-fetchtries to handle this by including its own set of trusted CAs viagocertifi, but if you're getting this error anyway, you can fix it by ensuring that theca-certificatesdependency is installed. On Alpine you'll want to run:apk add --no-cache ca-certificatesFurther ReadingFor more on EnvKey in general:Read thedocs.Read theintegration quickstart.Read thesecurity and cryptography overview.Need help? Have questions, feedback, or ideas?Post anissueor email us:support@envkey.com.