Skip to main content

Infuses GNU make with the ability to read .env files

Project description

make.env

GitHub Workflow Status (event) PyPI GitHub PyPI - Python Version

Infuses GNU make with the ability to read .env files

Motivation

Often when working with Makefiles, you might have the need to read environment variables from a .env file, and have make treat them as if the environment variables were actually variables in the Makefile.

The most popular solution is to import the .env file into the Makefile, and then export every varaible declared so far:

include .env
export

The problem with this is that it is prone to errors. For example, if your .env file contains the following:

APP_PASSWORD='8oyy!r#vNpRy2TT'

The variable APP_PASSWORD will be exported with the value '8oyy!r. Likewise, if your .env file contains the following:

APP_PASSWORD='Qy%$%J9$rD#jqVw'

The variable APP_PASSWORD will be exported with the value 'Qy%J9D.

What's more, any attempt to use this variable will result in an error in make concerning the lack of a closing quote:

unexpected EOF while looking for matching `''

Explanaition

In both cases, APP_PASSWORD contained values which make treats specially.

The # is used to start comments, therefore as soon as make sees a #, it will ignore the rest of the line.

The $ is used to reference a variable or function, so when make sees a $, it will treat whatever comes after it as a variable or function reference.

The solution

That's where this wrapper comes in. It allows us to read a .env file and pass them to make in a way that allows make to treat them as variables and copy their values literally rather than attempting to interpret them.

Project details


Download files

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

Source Distribution

make.env-0.0.7.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

make.env-0.0.7-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

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