Saravanan666/pypi-org huggingface dataset:
Package: enva
EnvaMaking working with environment variables in Python slightly better.Ever needed to get an environment variable as an integer or a boolean?
Ever needed to assert that an environment variable is set?
Stop looking at the standard library. It can't help you.envacan.envaprovides utility functionality for working with environment variables in Python.
There are two main features:Variable retrieval (as alternative types, e.g. int)Variable assertion (e.g. is the variable set)SponsorThis project is sponsored byDocumatic,
the search engine for your codebase.Getting startedRequirementsPython 3.10 or greaterThat's itInstall enva from pypi withpip install envaUpdatesPlease refer to thechangelogfor a full breakdown of recent updates.ExamplesConverting env varsimportosfromenva.gettersimportget_env_intos.environ["SOME_VAR"]="10"print(get_env_int("SOME_VAR"))# 10 (as an int)Verifying env var typesimportosfromenva.checkersimportrequire_variable_as_typeos.environ["SOME_VAR"]="10"os.environ["ANOTHER_VAR"]="ten"print(require_variable_as_type("SOME_VAR",float))# No throwprint(require_variable_as_type("ANOTHER_VAR",float))# Will raiseDevelopersCode qualityblack formattingisort importsmypy complianceTestingUnit testsare run with pytest.
Please ensure that new features
and bug fixes
have an appropriate test.
There is a github action
to ensure tests pass
with sufficient coverage.ContributingAll contributions are welcome!
Please see thecontributing guideto get started.LicenseGPL-3.
Please readthe licensefor full terms.
Package: env-alias
Env AliasPowerful helper utility to create shell alias commands to easily set collections of environment
variables often with secret values from a variety of data-sources and data-formats.Enables complex environment setups to be stored in source-control without secret values which makes
it particularly useful in loading secret values into containerized service environments and developer
environments alike.FeaturesData sources: local-file, http-remote, exec-stdout or directly-setSource file formats:text,ini,json,yamlSelect using jq-style selectors, xpath selectors or line-numbersReference other env values within configurationContent-Type detection for http-remote data-sources to automatically assign appropriate parserRun exec helper commands without content assignment for creating setupsDebug mode output to STDERREasy installation using PyPIpipPlenty of documentation and examples -https://env-alias.readthedocs.ioInstallationpipinstallenv-aliasUsageThis tool is typically invoked via an entry in.bash_aliaseswith an entry in the form:-eval$(env-aliasenv-project-awesome~/path-to/project-awesome-alias.yml)This simple one-liner creates a command alias in the nameenv-project-awesomethat subsequently invokes
an alias-generator that gives effect to the.ymlconfigurations(s).By naming your alias commands with a common prefix such asenv-it also becomes possible to leverage
shell tab-completion to quickly find aliases that implement the environment settings for your project,
use-case or other situation.This mechanism is enormously useful in working with large sets of environment variables from encrypted
or otherwise secured data-sources which means an environment configuration can be easily committed to
source control without the secret values.Be sure to review the examples that make the benefits of this arrangement clear.VersionCheck which version of env-alias is installedenv-alias--versionProjectGithub -github.com/ndejong/env-aliasPyPI -pypi.python.org/pypi/env-aliasReadTheDocs -env-alias.readthedocs.ioCopyright © 2021 Nicholas de Jong
Package: envappconfig
envappconfigenvappconfig is intended to provide simple configuration via environment variables, in the same spirit as argparse, which can be useful when developing and deploying12-factor apps.Features:Autogenerates usage output if an environment variable is missingDefault settings for missing environment variablesFunctions that transform the environment variable string to the value type you needEnvironment variable prefixesBasic examplefromenvappconfigimportEnvAppConfigenv=EnvAppConfig(description='Amazing app')env.add_env('port',default=1234,transform=int,help='The listen port')env.add_env('mirror',help='The URL to mirror')config=env.configure()# Returns PORT from os.environ transformed to an int,# or 1234 if PORT does not exist.config.port# Returns MIRROR from os.environ,# or displays usage at env.configure()# if MIRROR does not exist, then exits.config.mirrorAdding a prefixIf all the environment variables for the app have the same prefix, it can be specified with theprefixparameter.fromenvappconfigimportEnvAppConfigenv=EnvAppConfig(prefix='MYAPP',description='Amazing app')env.add_env('port',default=1234,transform=int,help='The listen port')env.add_env('mirror',help='The URL to mirror')config=env.configure()# Returns MYAPP_PORT from os.environ transformed to an int,# or 1234 if MYAPP_PORT does not exist.config.port# Returns MYAPP_MIRROR from os.environ,# or displays usage at env.configure()# if MYAPP_MIRROR does not exist, then exits.config.mirrorCustom transformsThetransformparameter can be used to specify normal transforms, likeintorfloat(the default isstr), but it can also take custom transform functions.  The transform function must take a single parameter, which will be filled in with the string value from the environment variable.env=EnvAppConfig(description='Amazing app')# Double the timeout specified in the TIMEOUT environment variable,# or default to 60.env.add_env('timeout',default=60,transform=lambdax:int(x)*2,help='Timeout in seconds')...Adding more config valuesAdditional config values can be added to an existing namespace, which can be helpful when there's a config value that needs to be calculated based on other config values.fromenvappconfigimportEnvAppConfigenv=EnvAppConfig(description='Amazing app')env.add_env('bind',help='IP address to bind to')env.add_env('port',default=1234,transform=int,help='The listen port')config=env.configure()config.listen=f'{config.bind}:{config.port}'# Returns the combined bind:port string.config.listenCommand LineThere are a couple options for using envappconfig at the command line (eg. when testing).PrefixIf you've only got a couple environment variables to set, just put them before the command:PORT=9999NAME=foopython3script_using_envappconfig.pydotenvIf you have more environment variables to set, consider usingdotenv.  First put your environment variables in a file named.env:PORT=9999NAME=fooThen calldotenvas follows, which will load up the variables from.envfor this command:dotenvrun--python3script_using_envappconfig.pyYou can install thedotenvcommand line tool with:python3-mpipinstall"python-dotenv[cli]"
Package: envargs
Simple means of parsing and validating environment variables. Heavily inspired by the earlier versions of webargs, which also explains the name to some extend.Installing$pipinstallenvargsUsingfromenvargsimportVar,parse_envrequired_vars={'A_INT':Var(use=int,validate=lambdax:x>=0,),'A_LIST':Var(use=lambdax:x.split(','),validate=(lambdax:len(x)==2,lambdax:x[0]=='first element',),),'A_STR':Var(use=str,load_from='SOME_OTHER_NAME',validate=bool,),}parsed=parse_env(required_vars)Say you want to configure your Flask app using this:app.config.from_mapping(parsed)Why reinvent the wheel again?To be fair there are many good packages out there to parse environment variables, quite a few of them in python too. So this package can easily be seen as redundant. However, with separation of parsing and validation into two separate functions, you gain more power to control what is actually accepted, not to mention that it makes it possible to inline a few more things, as you can most often get away with using builtin functions for most parsing and validation, and when that is not enough, lambdas or partials can do the rest.
Package: envariable
Change System Environment Variable permanentlygithub pageInstallpipinstallenvariableExamplefromenvaribleimportsetenv,unsetenv,getenv,getenvall# The variable TEST is stored permanently with the VALUE valuesetenv('TEST','VALUE')print(getenv('TEST'))>>>VALUE# The TEST variable is permanently deletedunsetenv('TEST')print(getenv('TEST'))>>>None# returned all Environment Variableall_env=getenvall()Example 2fromenvariableimportsetenv,getenvpath=getenv('PATH')setenv('PATH',f'{path}:/my/dir')
Package: envars
Helper function to read the environment variables in the development machine and on the production machine (only for heroku.com)What is the purpose of this libraryThis Library will help you read the environment variables needed to run your softwareAn example of the environment variables would be:database_login = datamasterdatabase_password =asdlf@#$kkLK!@)(“”)DATABASE_URL = postgres://dsdsfd:asdfasgsdfgjjkdty.compute-1.amazonaws.com:532/jj4566lsYou are likely to have the variable stored differently in your development and production environment:In your development/local machine:these files are stored in a local text file (usually called .env)your code will open the file, parse the text and read the variableIf your production environment is heroku.comyou can get the variables byos.environ()As you can see, the code to read the env variable is different in the development machine and the production machineEnvars a function that will read it transparently from the development or production machine using the same codeHow to use this libraryUsage:import envars.envars as envars
e_dct = envars.getenvars()The environment variables are now in e_dct. Assuming you are running on a local machine and have a .env file that looks like this:a=1
b=2You can look at the values in e_dct:>> print e_dct
defaultdict(<function <lambda> at 0x10cddbd70>, {'a': '1', 'b': '1'})

>> print e_dct['a']
'1'If you are on the production machine at heroku.com, make sure you have the following variable in the heroku environment:ENV_NOW=productionEnvars uses this as a sign that you are on the production environment and will read it correctly. Now, on the production environment, you code will do the following:>> print e_dct
defaultdict(<function <lambda> at 0x10cddbd70>, {"ENV_NOW":"production", 'a': '1', 'b': '1'})

>> print e_dct['a']
'1'

>> print e_dct['ENV_NOW']
'production'Limitations of this libraryDesigned only for Heroku.com as production environment
Package: envass
ENVironmental data quality ASSuranceENVironmental data quality ASSurance for generating high quality data products.Installationpip install envassUsageimportnumpyasnpfromenvassimportqualityassurancevariable=np.array([1,"g",16,12.0,False,0,22.12,5.77])time=np.array(range(len(variable)))checks={"numeric":{},"IQR":{"factor":4},"IQR_window":{}}qa=qualityassurance(variable,time,**checks)
Package: envassert
Test your servers environments by using fabric.Requirementspython 2.6 or laterfabricHow to Useinstall% pip install envassertwrite fabfile.py.from fabric.api import env, task
from envassert import file, process, package, user, group, port, cron, detect

env.use_ssh_config = True

@task
def check():
    env.platform_family = detect.detect()

    assert file.exists("/etc/hosts")
    assert file.is_file("/etc/hosts")
    assert file.is_dir("/tmp/")
    assert file.dir_exists("/tmp/")
    assert file.has_line("/etc/passwd", "sshd")
    assert file.owner_is("/bin/sh", "root")
    assert file.group_is("/bin/sh", "root")
    assert file.mode_is("/bin/sh", "777")

    if env.platform_family == "freebsd":
        assert file.is_link("/compat")
    else:
        assert file.is_link("/usr/tmp")

    assert package.installed("wget.x86_64")

    assert user.exists("sshd")
    assert user.is_belonging_group("shirou", "users")
    assert group.exists("wheel")

    assert port.is_listening(22)
    assert port.is_listening(80, "tcp")

    assert process.is_up("http") is False
    assert service.is_enabled("httpd")

    assert cron.has_entry('shirou', 'python')

    assert filesystem.is_type('ext4', '/')run fab% fab -H somehost check
[somehost] Executing task 'check'

Done.
Disconnecting from root@192.168.22.98... done.You can use any other fabric arguments like hosts or parallel.Detecting OSThedetect.detect()function can detect target OS and
distribution. Setting this variable toenv.platform_family,
functions can dispatch according to that value.This function is a minimal port of ohai.Currently, these platform can be detected. (but not tested yet)rhel (redhat, centos, oracle, scientific, enterpriseenterprise, amazon)debian (debian, ubuntu, linuxmint, raspbian)fedorasusegentooarchfreebsdnetbsdopenbsddarwinHowever, every functions are not implemented for these all
platform. Pull Requests are welcome.The giants on whose shoulders this works standsserverspec :http://serverspec.org/cuisine :https://github.com/sebastien/cuisineohai (for detecting platforms) :http://docs.opscode.com/chef/ohai.htmlLicenseMIT LicenseFYIcuisine: BSDserverspec: MITohai: Apache 2
Package: envassume
Assume an AWS IAM role and execute a command with the assumed credentials. AWS API credentials to assume the role must be set as environment variables, and the command and arguments are executed in the same manner asenvdir.envassumetakes the effort out of assuming an AWS role from the command-line and copying/pasting the returned credentials to run a command. If you often need to do this:-$ aws sts assume-role --role-arn arn:aws:iam::123456789012:role/s3_access --role-session-name s3_access_session
{
    "AssumedRoleUser": {
        "AssumedRoleId": "xxxxxxxxxxxxxxxxxxxxx:s3_access_session",
        "Arn": "arn:aws:sts::123456789012:assumed-role/s3_access/s3_access_session"
    },
    "Credentials": {
        "SecretAccessKey": "mmm",
        "SessionToken": "nnn",
        "Expiration": "2019-02-26T00:00:00Z",
        "AccessKeyId": "ooo"
    }
}
$ AWS_ACCESS_KEY_ID='ooo' AWS_SECRET_ACCESS_KEY='mmm' AWS_SESSION_TOKEN='nnn' aws s3 lsIt can be shortened to:-$ envassume arn:aws:iam::123456789012:role/s3_access aws s3 lsUseful if you often need to test roles, or run scripts with assumed roles on AWS instances using credentials from the instance profile.Installpip install envassumeUsageusage: envassume [-h] [-i EXTERNAL_ID] [ARN] command [argument [argument ...]]

optional arguments:
    -h, --help              show this help message and exit
    -i, --id EXTERNAL_ID    external id
    ARN                     AWS role ARN to assume (required if not set by environment variable)

environment variables:
    environment must contain valid AWS API credentials

    AWS_ASSUME_ROLE=ARN
        no options can be present before the command if this is defined

    AWS_ASSUME_ID=EXTERNAL_IDLicenseCopyright (c) 2017 Warren MooreThis software may be redistributed under the terms of the MIT License.
See the file LICENSE for details.Contact@wamonite     - twitter
       \_______.com - web
warren____________/ - email
Package: env-attributes
EnvAttributesv1.1.1Loads environment into class attributesInstall:pipinstallenv_attributesExample:Environment:HOST=localhost
PORT=5050Usage:Variant 1:fromenv_attributesimportEnvironmentpath_to_env='example/.env'env=Environment(env_path=path_to_env)print(env.host,env.port)output:localhost 5050Variant 2:Correct if the .env file is in the root directoryfromenv_attributesimportenvprint(env.host,env.port)output:localhost 5050Additional usage:print(env.get('host'),env['port'])Register is not important:print(env.get('HoSt'),env['PORT'])You can work with the env object as with a dict:forkeyinenv:value=env.get(key)print(key,value)output:host localhost
port 5050You can output all environment variables:print(env)output:{"host":"localhost","port":"5050"}You can also get all keys or values from env:print(env.keys())print(env.values())output:['host', 'port']
['localhost', '5050']You can get length of env:print(len(env))output:2NEWAdded ability to specify type annotations for environment variablesExample:Environment:BOOL=False
INT=123456789
FLOAT=3.14159265
STRING='Hello World!'
LIST='[123, 2.22, [1, 2, 3], {"key1": "val1", "key2": "val2"}]'
TUPLE='(1, 22, 333, 4444)'
DICT='{"key1": "val1", "key2": "val2", "key3": {"key3.1": 1, "key3.2": 2}}'
CUSTOM='1, 2, 3, 4, 5, 6, 7, 8, 9'Usagefromenv_attributesimportEnvironment,EnvTypesclassEnvironmentTypes(EnvTypes):bool:boolint:intfloat:floatstring:strlist:listtuple:tupledict:dictenv=Environment(env_types=EnvironmentTypes)print(env.bool,type(env.bool))print(env.int,type(env.int))print(env.float,type(env.float))print(env.string,type(env.string))print(env.list,type(env.list))print(env.tuple,type(env.tuple))print(env.dict,type(env.dict))output:False <class 'bool'>
123456789 <class 'int'>
3.14159265 <class 'float'>
Hello World! <class 'str'>
[123, 2.22, [1, 2, 3], {'key1': 'val1', 'key2': 'val2'}] <class 'list'>
('1', ' 22', ' 333', ' 4444') <class 'tuple'>
{'key1': 'val1', 'key2': 'val2', 'key3': {'key3.1': 1, 'key3.2': 2}} <class 'dict'>
Package: envauth
Super simple authentication middleware for when you quickly need to password
protect something and don’t have the time to implement rigorous authentication.
SupportsFlask,bottle,Djangoand genericWSGIservers out of the box.$ENVAUTHenvauthlooks for aJSONobject in theENVAUTHenvironment variable.
The keys are the usernames and the value contains the password for the user.{"username":"password","anotheruser":"pass1234"}Heroku Exampleenvauthis especially useful if you happen to be running your application on a PAAS!$ heroku config:set ENVAUTH='{"username": "password", "anotheruser": "pass1234"}'
Setting config vars and restarting application... done, v2ExamplesFlaskimportenvauth@app.route('/secret-page')@envauth.flask.requires_auth(realm='You shall not pass!')defsecret_page():returnrender_template('secret_page.html')Bottleimportenvauth@app.route('/secret-page')@envauth.bottle.requires_auth(realm='You shall not pass!')defsecret_page():returntemplate('secret_page.html')DjangoMIDDLEWARE_CLASSES+=('envauth.django',)WSGIimportenvauthapplication=envauth.wsgi(application,realm='You shall not pass!')InstallationInstallenvauthwith pip:$ pip install envauth
Package: env-automatically
Extract EnvThis project was created to solve the recurring problem of adding an environment variable to the settings.py withpython-decouplewhile not adding the same variable to the .env file. It reads the settings.py file and then creates the .env file with all environment variables already set.How to installpipinstallenv-automaticallyHow to use1 - Go to the Django project folder where settings.py is.2 - Run command:env-automatically.3 - The file.envwill be created in the same folder of settings.py.
Package: envawareconfig
EnvawareconfigLoad configurations from yaml files with automatic environment variable substitution.Installationwithpip:pip install envawareconfigwithpoetry:poetry add envawareconfigQuickStartSuppose you have a configuration file like this:# test-config.yamldatabase:name:my-databaseuser:"${DB_USER:admin}"password:"${DB_PASSWORD}"and that you have set the environment variableDB_PASSWORDtomy-secret-passwordwhileDB_USERhas been left unset.then running the following code:# main.pyfromenvawareconfigimportload_configconfig=load_config("tests/test-config.yaml")would result in:config={"database":{"name":"my-database","user":"admin","password":"my-secret-password"}}Notice that${DB_PASSWORD}has been expanded and${DB_USER:admin}used the default value.
Package: envbox
https://github.com/idlesign/envboxDescriptionDetect environment type and work within.FeaturesEnvironment type detection (extendable system);Support for.envfiles;Convenientos.environproxying (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 samplefromenvboximportget_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# >> developmentenv.is_production# >> Falseenv.get('HOME')# The same as env['HOME'] and env.HOME# >> /home/idle/env.getmany('PYTHON')# {'UNBUFFERED': '1', 'IOENCODING': 'UTF-8', 'PATH': ...}Now you may want to put your environment vars into.envfiles
(e.g.:.env,.env.development.env.production)
to be read byenvbox: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$envboxprobe# >> Detected environment type: development (Development)$envboxshow# >> [...]
# >> SHELL = /bin/bash
# >> [...]Note:envboxCLI requiresclickpackage available.Documentationhttp://envbox.readthedocs.org/
Package: envbuilder
Envbuilder is a system for automatically building virtualenvs in Python.
To do this, it uses a .env config file to defineparcels, which are
individual pieces of software to be checked out and installed into
the virtualenv.It is mainly tested under Linux, but it should work under any platform that
supports unix-y commands (including cygwin).  In fact, you might even be
able to make one config file work on both Windows and *nix if you’re
careful.Envbuilder has a few goals:Transparency- You should understand what your build is doing and
how it works.Developer-friendly- Although envbuilder is perfectly fine for production
deployment, it is primarily intended to make work environments for developers.Dynamic- Envbuilder should be able to work with a variety of technologies,
languages, and frameworks.  Developers shouldn’t be limited to a narrowly defined
set of technologies.  And neither should their tools!VCS-neutral- Envbuilder will work with your shiny new DVCS out of the box.
In fact, it will work with any VCS that has a command-line interface.  Use it
with hg, git, bzr, SVN, or CVS (if you’re a masochist).For more information, see theenvbuilder documentation.InstallingFor the latest stable version, the easiest way to install envbuilder is
through easy_intall:easy_install envbuilderYou may also install the current development version using easy_install:easy_install envbuilder==devOr you maydownload it directly.SupportIf you have any issues using envbuilder, feel free to open an issue on theissue trackeror stop
by thesupport mailing list.Release Notes0.3.0Compatibility issues:Most commands have been moved to envb-site-commands.Other improvements:Command handling has been revamped to allow for more plugabilitySupport for envb-site-commandsDependency handling for commandsLots of other miscellaneous fixes.0.2.2Requiring configobj 4.7.2 as it fixes some important bugs.0.2.1Adding a fix so that clean_pyc doesn’t delete files in the python2.6
directory.0.2.0Added a couple of examples.  If you already have a working envbuilder
installation, there is no requirement to upgrade.0.2.0b2Required the correct version of ConfigObj.  This update is not necessary
if you already have a working envbuilder installation.0.2.0b1Readded the envbuilder entry point as renaming it caused some strange
issues.0.2.0bThe name option on parcels is now set automatically from the subsection
name.Added percent (command) variables.Added the CWD built-in variable.Added a dir option for parcels that defaults to the name.Removed the test command.  This can now be done with custom commands.The envbuilder entry point is now envb.