Env Fileis a plugin for PyCharm that allows you to set environment variables from files for python-based run configurations. Works with all Python-based run configuration in PyCharm.
Supported formats:
.env YAML dictionary JSON dictionary (parsed with YAML parser since JSON is subset of YAML ) All formats assume that both keys and values are strings. InstallationUsing IDE built-in plugin system:
Preferences > Plugins > Browse repositories... > Search for "Env File" > Install PluginManually:
Download thelatest release and install it manually using Preferences > Plugins > Install plugin from disk...Restart PyCharm.
Usage Add new Run/Debug configuration : + Add new configuration > Python Enable Read from file checkbox, select a file and the file format
Examples .env # This line is ignored since it's a comment SECRET_KEY=hip-hip-env-files VERSION=1.0
or
# This line is ignored since it's a comment SECRET_KEY hip-hip-env-files VERSION 1.0 JSON { # JSON doesn't have comments but since JSON is subset of YAML # We parse it with YAML parser and therefore have comments # And even trialling commas in objects :) "SECRET_KEY": "hip-hip-env-files", "VERSION": "1.0", # All non-string literals should be enclosed in quotes; btw this is ignored too } YAML # This line is ignored since it's a comment SECRET_KEY: hip-hip-env-files VERSION: "1.0" # All non-string literals should be enclosed in quotes; btw this is ignored too Extending FunctionalityPyCharm is based on the IDEA core and has awesome extensions engine. Env File plugin utilizes it for its own purposes and designed to be highly extensible.
If you want to extend it's functionality take a look atplugin.xml.
Env Filedefines two extension points that it uses by itself and that can be used by others:
<extensionPoints> <extensionPoint name="envfileParser" beanClass="net.ashald.envfile.parsers.EnvFileParserExtension"> <with attribute="implementationClass" implements="net.ashald.envfile.parsers.EnvFileParser"/> </extensionPoint> <extensionPoint name="envfileFormat" beanClass="net.ashald.envfile.formats.EnvFileFormatExtension"/> </extensionPoints>Env File's own configuration is a good example of how it can be extended:
<extensions defaultExtensionNs="net.ashald.envfile"> <envfileParser id="env" implementationClass="net.ashald.envfile.parsers.DotEnvFileParser"/> <envfileParser id="yaml" implementationClass="net.ashald.envfile.parsers.YamlFileParser"/> <envfileFormat fileExtension="env" parserId="env"/> <envfileFormat fileExtension="json" parserId="yaml"/> <envfileFormat fileExtension="yaml" parserId="yaml"/> </extensions> Further Development Add environment variables expansion Add support for other JetBrains IDEs (upon requests) Add unit tests FeedbackAny feedback, bug reports and feature requests are highly appreciated!
Feel free to create an issue, contact me using Github or just drop me an email to the address specified inplugin.xml /idea-plugin/vendor@email .
ContributingIf you willing to contribute to the project follow the steps bellow:
Fork the repo (for details check out theguide) Create a feature/bugfix brunch from the develop branch Clone the fork to your machine Install Gradle Navigate into the local copy and execute gradle setup Open the dir with IntelliJ IDEA Configure IntelliJ IDEA Plugin SDK Set Java Compiler to 1.6 : go to Settings > Build, Execution, Deployment > Compiler > Java Compiler and set Project bytecode version to 1.6 Rebuild the project: Build > Rebuild Project Add new Run/Debug configuration : + Add new configuration > Plugin Run the project and check that Env File plugin is enabled in child PyCharm instance Do your changes Add yourself to AUTHORS.md Commit & Push Check that you up to date with the upstream Do interactive rebase and ensure that your commits history is properly organized and has reasonable commit messages Create a Pull Request into the develop branch of this repo LicenseCopyright (c) 2015 Borys Pierov. See theLICENSE file for license rights and limitations (MIT).