Env File is 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.
-
Using IDE built-in plugin system:
- Preferences > Plugins > Browse repositories... > Search for "Env File"
Install Plugin
-
Manually:
- Download the latest release and install it manually using Preferences > Plugins > Install plugin from disk...
Restart PyCharm.
- Add new Run/Debug configuration: + Add new configuration > Python
- Enable Read from file checkbox, select a file and the file format
# This line is ignored since it's a comment
SECRET_KEY=hip-hip-env-files
VERSION=1.0or
# This line is ignored since it's a comment
SECRET_KEY hip-hip-env-files
VERSION 1.0{
# 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
}# 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 PyCharm 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 at plugin.xml.
Env File defines 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>- Add environment variables expansion
- Add support for other JetBrains IDEs (upon requests)
- Add unit tests
Any 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 in
plugin.xml/idea-plugin/vendor@email.
If you willing to contribute to the project follow the steps bellow:
- Fork the repo (for details check out the guide)
- Create a feature/bugfix brunch from the
developbranch - 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
developbranch of this repo
Copyright (c) 2015 Borys Pierov. See the LICENSE file for license rights and limitations (MIT).