Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install milieu

How to install milieu

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install milieu
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
Windows (64-bit)
Mac OS X (10.5+)
Linux (32-bit)
0.1.1
0.1.3Never BuiltWhy not?
0.1.1 Available View build log
Linux (64-bit)
0.1.3 Available View build log
0.1.1 Available View build log
 
Imports
Lastest release
version 0.1.3 on Jan 9th, 2014

A helping hand to manage your settings among different environments

## Intro

Managing application configuration that runs on multiple environments can be tough. So, milieu comes to help you pretend you have only one settings file that magically works whenever you deploy.

Here at Yipit, we use Chef to coordinate the deploy process and to maintain the configuration, using attributes or data bags.

After that, we use [envdir](http://cr.yp.to/daemontools/envdir.html) to run our applications with variables set in Chef. Then, we use milieu to read those variables and feed the application configuration system.

## Production

The system environment is the first place milieu will try to find things. So, when the application runs inside of an environment with the right variables set, it will just work.

So, if you know you have the environment variable DATABASE_URI like this:

`bash $ export DATABASE_URI=mysql://root@localhost:3306/mydb `

The application settings glue code will look like this:

`python # steadymark:ignore >>> from milieu import Environment >>> env = Environment() >>> dburi = env.get_uri('DATABASE_URI') >>> dburi.host u'localhost' >>> dburi.port 3306 `

## Local

If you just want to load things from a file locally, the Environment.from_file() constructor will help you out.

`python # steadymark:ignore >>> from milieu import Environment >>> env = Environment.from_file('/etc/app.cfg') >>> env.get_bool('BOOL_FLAG') True >>> env.get_float('FLOAT_VAL') 3.14 `

The file app.cfg will look like this:

```yaml BOOL_FLAG: True

System Message: WARNING/2 (<string>, line 59); backlink

Inline literal start-string without end-string.

System Message: WARNING/2 (<string>, line 59); backlink

Inline interpreted text or phrase reference start-string without end-string.

FLOAT_VAL: 3.14 ```

System Message: WARNING/2 (<string>, line 62); backlink

Inline literal start-string without end-string.

System Message: WARNING/2 (<string>, line 62); backlink

Inline interpreted text or phrase reference start-string without end-string.

## From a folder

You can also load variables from a folder, where each file will be an environment variable and the file's content will be the value. Just like [envdir](http://cr.yp.to/daemontools/envdir.html).

Now, say that you have the folder /etc/envdir/app and this folder contains the file MYSQL_CONN_URI with a database URL inside of it. Just like this one here: mysql://root:secret@localhost:3306/mydb.

To read that directory and load the variable properly, you just have to do the following:

`python # steadymark:ignore >>> from milieu import Environment >>> env = Environment.from_folder('/etc/envdir/app') >>> uri = env.get_uri('MYSQL_CONN_URI') >>> uri.host 'localhost' >>> uri.port 3306 >>> uri.user 'root' >>> uri.password 'secret' `

# Hacking on it

## Install dev dependencies

`console pip install -r requirements-dev.txt `

## Run tests

`console make test `

## Change it

Make sure you write tests for your new features and keep the test coverage in 100%

## Release it

After you already made your commits, run:

`console make release `

follow the instructions and do the [harlem shake](http://www.youtube.com/watch?v=8vJiSSAMNWw)

Subscribe to package updates

Last updated Jan 9th, 2014

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.