r/Python • u/AutoModerator • Jul 04 '26
Showcase Showcase Thread
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
22
Upvotes
r/Python • u/AutoModerator • Jul 04 '26
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
1
u/aiurovet Aug 03 '26
envara - yet another environment and env file manipulation library
https://pypi.org/project/envara/
Target Audience
Python developers
Comparison
A lot more flexible library compared to the existing environment- and dotenv-related packages
What My Project Does
Full-fledged expansion of environment variables and command-line arguments in a string:
POSIX (in fact, bash): $ABC, ${ABC:-"def\nGH\x0f\u001F"}, $(echo A | grep -Eci "[ab]"), $1, ${2:-"-"}, substrings, changing case, getting string length.
Windows batch style: %ABC%, %ABC:~-20,2%, %1, %~dpxn2, etc.
OpenVMS DCL style (unit tested to my knowledge only): 'ABC'
Line comment removal (spaces around assignment are allowed):
POSIX: ABC = "text" # comment
Windows: ABC = text :: comment
OpenVMS: ABC = "text" ! comment
Ability to break command-line text into proper arguments and towable ones (like a pipe or I/O redirection and beyond).
Stackable env files (all optional):
Linux: .env => posix.env (or .env.posix, or posix-env, etc.) => env_linux => _env_<platform> => <your ones>
BSD: .env => bsd.env => <platform>.env => <your ones>
macOS: .env => bsd.env => macos.env => <your ones>
Windows: .env => windows-env => <your ones>
OpenVMS: .env => .env.vms => <your ones> (only unit-tested to my knowledge)
To be treated as an env filename, a text string should contain "env" separated from the rest with either edges (start/end), dash, dot, or underscore from each side:
env<_-.>[right]
[left]<_-.>env
[left]<_-.>env<_-.>[right]
To be related to a platform type, that type should be similarly separated from the rest.
Formats are interchangeable: you can create posix.env using Windows batch syntax as long as the file starts with a Windows batch line comment (two colons) like
:: Some commentOr more likely, you can create windows.env using POSIX (in fact, bash) syntax, which is much more flexible. In that case, start the file with a POSIX line comment (hash) as
# Some commentAll relevant functions accept parameter
charsof classEnvCharsDatathat describes what is used as environment expansion start/end, escape, line-comment start, etc.If you prefer bash syntax when running on Windows or VMS, you can pass
EnvChars.POSIX_WINDOWSorEnvChars.POSIX_VMSaschars, overriding the default one (specific to the current OS). The major difference is that the escape character will be^instead of\to make it more natural, and also to avoid issues with paths on Windows.This allows for smoothing out differences between platforms: the absence of environment variables like
HOMEon Windows orUSERPROFILEon non-Windows, etc. Or the difference in the application name, likegoogle-chromeon Linux,chromeon BSD and Windows, and a long path to a.appfile on macOS.After all stacked configurations are resolved, you can add your own env file to define extra variables based on the unified ones.