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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file envo-0.9.15.tar.gz
.
File metadata
- Download URL: envo-0.9.15.tar.gz
- Upload date:
- Size: 27.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.7 CPython/3.8.10 Linux/5.8.0-1036-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26745d7aaacaee4f5f654d8af02f91a1aba703721562b01b96ba92be5c72d829 |
|
MD5 | e7751581743bb1d6ad55f5b90c6f7e00 |
|
BLAKE2b-256 | bab4a5946c23faea73f546dfa4184a125509e7a308b99c9f188935887cb9d286 |
File details
Details for the file envo-0.9.15-py3-none-any.whl
.
File metadata
- Download URL: envo-0.9.15-py3-none-any.whl
- Upload date:
- Size: 31.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.7 CPython/3.8.10 Linux/5.8.0-1036-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a74ae6653ca8aec77a0663a95e18b52ab79d931cb1705f189b856b28d257d7e6 |
|
MD5 | 9b0f1d9d7972fcf90b1754ea382d379f |
|
BLAKE2b-256 | 6492958bd0f05040a7d6c28e97434f9e4103b6736e632851f2230ef7a8b91339 |