stela


Namestela JSON
Version 7.1.0 PyPI version JSON
download
home_pagehttps://github.com/megalus/stela
SummaryOrganize your project settings and secrets with ease
upload_time2024-03-14 17:54:38
maintainer
docs_urlNone
authorChris Maillefaud
requires_python>=3.10,<4
licenseMIT
keywords settings configuration parser dotenv environment
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
   <img src="docs/images/stela.png" alt="Stela" />
</p>
<p align="center">
<em>Easily manage your application settings and secrets</em>
</p>
<p align="center">
<a href="https://pypi.org/project/stela/" target="_blank">
<img alt="PyPI" src="https://img.shields.io/pypi/v/stela"/></a>
<a href="https://github.com/megalus/stela/actions" target="_blank">
<img alt="Build" src="https://github.com/megalus/stela/workflows/tests/badge.svg"/></a>
<a href="https://www.python.org" target="_blank">
<img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/stela"/></a>
</p>

## Welcome to Stela

[Stela](https://en.wikipedia.org/wiki/Stele) were the "information
files" of ancient times. This library aims to simplify your project
configurations, proposing an opinionated way to manage your project
using dotenv files, or using any source you need.

### Install

```shell
$ pip install stela
```

---

### Documentation

* Docs: https://megalus.github.io/stela/

---

### Key features:

1. _**Learn once, use everywhere**_. Stela aims to be easily used in any Python project or Framework.
2. _**Separate settings from secrets from environments**_. Instead of using a single dotenv file to store all your settings,
   we use multiple dotenv files, one for each environment. This way, you can split secrets from settings, and you can
   have different values for the same setting in different environments.
3. _**Easy to implement**_. Use the command `stela init` to initialize your project and configure `.env` and `.gitignore`
   files.
4. _**Easy to use**_. To access you configuration just include `from stela import env` in your code. Simple as that.
5. _**One Interface, Any Source**_. You're not limited to dotenv files. Create your custom logic to import data from any
source you need.


### Quick Start

Run Stela initialization command. This command will create `.env`, `.env.local`, `.stela` and `.gitignore` files.

```bash
$ stela init --default
```

Create the dotenv files and add your settings and secrets.

```dotenv
# Add project settings and fake project secrets to .env
# This file will be commited to your repository
API_URL="http://localhost:8000"
DB_URL="db://fake_user:fake_password@local_db:0000/name"
```

```python
# my_script.py
from stela import env

API_URL = env.API_URL  # http://localhost:8000
DATABASE_URL_CONNECTION = env.DB_URL  # db://fake_user:fake_password@local_db:0000/name
```

```dotenv
# Add real secrets to .env.local
# This file will be ignored by git
DB_URL="db://real_user:real_password@real_db:0000/name"
```

A single, simple API to access your settings and secrets:

```python
# my_script.py
from stela import env

API_URL = env.API_URL  # http://localhost:8000
DATABASE_URL_CONNECTION = env.DB_URL  # db://real_user:real_password@real_db:0000/name
```

### Custom Sources

Use a custom, optional, final loader function to load your settings from any source you need.

```ini
# .stela
[stela]
final_loader = "path.to.my.final_loader"  # Add your final loader to Stela
```

```python
# Use SSM Parameter Store to load your settings

import boto3
from stela.config import StelaOptions

def final_loader(options: StelaOptions, env_data: dict[str, any]) -> dict[str, any]:
    """Load settings from AWS Parameter Store (SSM) to current Stela data.

    Data returned must be a Python Dictionary.
    Dict keys will be converted to env properties.
    Ex. {'Foo': 'Bar'} will be available as env.Foo

    :param env_data: Data parsed from dotenv file (the first loader)
    :param options: Stela Options obj
    :return dict[str, any]
    """
    ssm = boto3.client('ssm')
    environment = options.current_environment  # The value from STELA_ENV variable. Ex. production

    # Get from SSM
    response = ssm.get_parameters_by_path(
        Path=f'/my-project/settings/{environment}',
        WithDecryption=True
    )
    api_url = response['Parameters']['ApiUrl']  # https://real-api-url.com
    env_data.update({'API_URL': api_url})
    return env_data
```

Got your settings and secrets from both dotenv files and SSM Parameter Store:

```python
# my_script.py
from stela import env

API_URL = env.API_URL  # https://real-api-url.com
DATABASE_URL_CONNECTION = env.DB_URL  # db://real_user:real_password@real_db:0000/name
```


That's it! Check our [Documentation](https://megalus.github.io/stela/) for tons of customization and advice.

### Not working?

Don't panic. Get a towel and, please, open an
[issue](https://github.com/megalus/stela/issues).


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/megalus/stela",
    "name": "stela",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4",
    "maintainer_email": "",
    "keywords": "settings,configuration,parser,dotenv,environment",
    "author": "Chris Maillefaud",
    "author_email": "chrismaille@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/ba/12/a1747b775f80b90aa1bd06a7a3ff822b822b70486b5089a7a94dc3ea1643/stela-7.1.0.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n   <img src=\"docs/images/stela.png\" alt=\"Stela\" />\n</p>\n<p align=\"center\">\n<em>Easily manage your application settings and secrets</em>\n</p>\n<p align=\"center\">\n<a href=\"https://pypi.org/project/stela/\" target=\"_blank\">\n<img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/stela\"/></a>\n<a href=\"https://github.com/megalus/stela/actions\" target=\"_blank\">\n<img alt=\"Build\" src=\"https://github.com/megalus/stela/workflows/tests/badge.svg\"/></a>\n<a href=\"https://www.python.org\" target=\"_blank\">\n<img alt=\"PyPI - Python Version\" src=\"https://img.shields.io/pypi/pyversions/stela\"/></a>\n</p>\n\n## Welcome to Stela\n\n[Stela](https://en.wikipedia.org/wiki/Stele) were the \"information\nfiles\" of ancient times. This library aims to simplify your project\nconfigurations, proposing an opinionated way to manage your project\nusing dotenv files, or using any source you need.\n\n### Install\n\n```shell\n$ pip install stela\n```\n\n---\n\n### Documentation\n\n* Docs: https://megalus.github.io/stela/\n\n---\n\n### Key features:\n\n1. _**Learn once, use everywhere**_. Stela aims to be easily used in any Python project or Framework.\n2. _**Separate settings from secrets from environments**_. Instead of using a single dotenv file to store all your settings,\n   we use multiple dotenv files, one for each environment. This way, you can split secrets from settings, and you can\n   have different values for the same setting in different environments.\n3. _**Easy to implement**_. Use the command `stela init` to initialize your project and configure `.env` and `.gitignore`\n   files.\n4. _**Easy to use**_. To access you configuration just include `from stela import env` in your code. Simple as that.\n5. _**One Interface, Any Source**_. You're not limited to dotenv files. Create your custom logic to import data from any\nsource you need.\n\n\n### Quick Start\n\nRun Stela initialization command. This command will create `.env`, `.env.local`, `.stela` and `.gitignore` files.\n\n```bash\n$ stela init --default\n```\n\nCreate the dotenv files and add your settings and secrets.\n\n```dotenv\n# Add project settings and fake project secrets to .env\n# This file will be commited to your repository\nAPI_URL=\"http://localhost:8000\"\nDB_URL=\"db://fake_user:fake_password@local_db:0000/name\"\n```\n\n```python\n# my_script.py\nfrom stela import env\n\nAPI_URL = env.API_URL  # http://localhost:8000\nDATABASE_URL_CONNECTION = env.DB_URL  # db://fake_user:fake_password@local_db:0000/name\n```\n\n```dotenv\n# Add real secrets to .env.local\n# This file will be ignored by git\nDB_URL=\"db://real_user:real_password@real_db:0000/name\"\n```\n\nA single, simple API to access your settings and secrets:\n\n```python\n# my_script.py\nfrom stela import env\n\nAPI_URL = env.API_URL  # http://localhost:8000\nDATABASE_URL_CONNECTION = env.DB_URL  # db://real_user:real_password@real_db:0000/name\n```\n\n### Custom Sources\n\nUse a custom, optional, final loader function to load your settings from any source you need.\n\n```ini\n# .stela\n[stela]\nfinal_loader = \"path.to.my.final_loader\"  # Add your final loader to Stela\n```\n\n```python\n# Use SSM Parameter Store to load your settings\n\nimport boto3\nfrom stela.config import StelaOptions\n\ndef final_loader(options: StelaOptions, env_data: dict[str, any]) -> dict[str, any]:\n    \"\"\"Load settings from AWS Parameter Store (SSM) to current Stela data.\n\n    Data returned must be a Python Dictionary.\n    Dict keys will be converted to env properties.\n    Ex. {'Foo': 'Bar'} will be available as env.Foo\n\n    :param env_data: Data parsed from dotenv file (the first loader)\n    :param options: Stela Options obj\n    :return dict[str, any]\n    \"\"\"\n    ssm = boto3.client('ssm')\n    environment = options.current_environment  # The value from STELA_ENV variable. Ex. production\n\n    # Get from SSM\n    response = ssm.get_parameters_by_path(\n        Path=f'/my-project/settings/{environment}',\n        WithDecryption=True\n    )\n    api_url = response['Parameters']['ApiUrl']  # https://real-api-url.com\n    env_data.update({'API_URL': api_url})\n    return env_data\n```\n\nGot your settings and secrets from both dotenv files and SSM Parameter Store:\n\n```python\n# my_script.py\nfrom stela import env\n\nAPI_URL = env.API_URL  # https://real-api-url.com\nDATABASE_URL_CONNECTION = env.DB_URL  # db://real_user:real_password@real_db:0000/name\n```\n\n\nThat's it! Check our [Documentation](https://megalus.github.io/stela/) for tons of customization and advice.\n\n### Not working?\n\nDon't panic. Get a towel and, please, open an\n[issue](https://github.com/megalus/stela/issues).\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Organize your project settings and secrets with ease",
    "version": "7.1.0",
    "project_urls": {
        "Homepage": "https://github.com/megalus/stela",
        "Repository": "https://github.com/megalus/stela"
    },
    "split_keywords": [
        "settings",
        "configuration",
        "parser",
        "dotenv",
        "environment"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "252424a84218d0b568aa2a6b57ad14d5d9ce3ab478d4ac034339f562c593d102",
                "md5": "6fe1d556a3824e69b707437c79c727b3",
                "sha256": "5a6fe41e54c086478cd3bdb3c162a9222bf5463d539cc949b980bbadf482d1ac"
            },
            "downloads": -1,
            "filename": "stela-7.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6fe1d556a3824e69b707437c79c727b3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4",
            "size": 18981,
            "upload_time": "2024-03-14T17:54:35",
            "upload_time_iso_8601": "2024-03-14T17:54:35.713961Z",
            "url": "https://files.pythonhosted.org/packages/25/24/24a84218d0b568aa2a6b57ad14d5d9ce3ab478d4ac034339f562c593d102/stela-7.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ba12a1747b775f80b90aa1bd06a7a3ff822b822b70486b5089a7a94dc3ea1643",
                "md5": "c2b3e4bdeb5ab8cc14091fbfff8d9871",
                "sha256": "b418e46f2b39d5e97a0e934e6dd67a8acf4f8f2a72b7b1281dcab1091d88d97c"
            },
            "downloads": -1,
            "filename": "stela-7.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c2b3e4bdeb5ab8cc14091fbfff8d9871",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4",
            "size": 15894,
            "upload_time": "2024-03-14T17:54:38",
            "upload_time_iso_8601": "2024-03-14T17:54:38.678070Z",
            "url": "https://files.pythonhosted.org/packages/ba/12/a1747b775f80b90aa1bd06a7a3ff822b822b70486b5089a7a94dc3ea1643/stela-7.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-14 17:54:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "megalus",
    "github_project": "stela",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "stela"
}
        
Elapsed time: 0.23111s