Skip to main content

Smart Environments handling - Define command hooks, file hooks and env variables in python and activate hot reloaded shells.

Project description

Define environmental variables in python and activate hot reloaded shells for them.

Features

  • Initialisation of variables in a given directory (creates common variables file too)

user@pc:/project$ envo local --init  # creates local environment python files
  • Easy and dynamic handling in .py files (See documentation to learn more)

  • Provides addons like handling virtual environments

user@pc:/project$ envo local --init=venv  # will add .venv to PATH
  • Automatic env variables generation based on defined python variables

  • Hot reload. Activated shell will reload environmental variables when files change.

  • Activating shells for a given environment

user@pc:/project$ envo local
🐣(project)user@pc:/project$
🐣(project)user@pc:/project$ exit
user@pc:/project$ envo prod
🔥(project)user@pc:/project$
  • Saving variables to a regular .env file

user@pc:/project$ envo local --save
  • Printing variables (handy for non interactive CLIs like CI or docker)

user@pc:/project$ envo local --dry-run
  • Detects undefined variables.

  • Perfect for switching kubernetes contexts and devops tasks

Example

Initialising environment

user@pc:/project$ envo local --init

Will create env_comm.py and env_local.py

# env_comm.py
@dataclass
class ProjectEnvComm(Env):
    @dataclass
    class Python(BaseEnv):
        version: str

    class Meta:
        raw = ["kubeconfig"]  # disable namespacing

    python: Python
    number: int
    kubeconfig: Path
    # Add more variables here

    def __init__(self) -> None:
        super().__init__(root=Path(os.path.realpath(__file__)).parent)
        self.name = "proj"
        self.python = self.Python(version="3.8.2")
        self.kubeconfig = self.root / f"{self.stage}/kubeconfig.yaml"

# env_local.py
@dataclass
class ProjectEnv(ProjectEnvComm):
    def __init__(self) -> None:
        self.stage = "test"
        self.emoji = "🛠️"
        super().__init__()

        self.number = 12

Env = ProjectEnv

Example usage:

user@pc:/project$ envo  # short for "envo local"
🐣(project)user@pc:/project$ echo $PROJ_PYTHON_VERSION
3.8.2
🐣(project)user@pc:/project$echo $PROJ_NUMBER
12

TODO: Major: * Refactor start_in * Add file hooks * Add bootstrap (versioning etc) * add error line number

Minor: * Shell should highlight envo commands on green * Unnecessary prompt rendered again aftet Ctr-d (only on xonsh?) * work on public/private fields and methods * add examples * print hooks for repr * Add reload command

Bugs: * exiting while env loading yields Attribute Error

Improvements: * type checking ?

Project details


Release history Release notifications | RSS feed

This version

1.2.4

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

envo-1.2.4.tar.gz (26.8 kB view details)

Uploaded Source

Built Distribution

envo-1.2.4-py3-none-any.whl (30.4 kB view details)

Uploaded Python 3

File details

Details for the file envo-1.2.4.tar.gz.

File metadata

  • Download URL: envo-1.2.4.tar.gz
  • Upload date:
  • Size: 26.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.9.7 Linux/5.4.0-42-generic

File hashes

Hashes for envo-1.2.4.tar.gz
Algorithm Hash digest
SHA256 2425d4a463d5b12e849817c750c26ed4d20ff4a7abd70fead5092b01dbc54a00
MD5 daabfbb1010ed96e637a670abdebcc24
BLAKE2b-256 63e9c99cd81f85697162e48dc78e4bf32e0477a221025d5642df833c4a13ade8

See more details on using hashes here.

File details

Details for the file envo-1.2.4-py3-none-any.whl.

File metadata

  • Download URL: envo-1.2.4-py3-none-any.whl
  • Upload date:
  • Size: 30.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.9.7 Linux/5.4.0-42-generic

File hashes

Hashes for envo-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b497f04a23b825143bfac7b3b378ed91b00c7e40cd05a7e2f66f4b714383c096
MD5 86d9670d0dcd3a297064ac86649a82d2
BLAKE2b-256 49109c37df11d7f03f5aaf18360c1be25645bb13582048bc2c2db588b61f2734

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page