Support reading .env from FIFOs (Unix) #586
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for .env files provided via Unix FIFOs (named pipes).
Rationale
1Password recently launched local .env file support, which allows developers to securely access secrets stored in 1Password Environments via a local .env file that is actually a UNIX named pipe (FIFO). This lets secrets be streamed directly into processes without ever writing plaintext credentials to disk.
Currently, Python’s python-dotenv library cannot read such mounted .env files because it only recognizes regular files. This PR adds native FIFO (named pipe) support so that Python developers can seamlessly use python-dotenv with 1Password’s new .env destinations.
We’d love for python-dotenv to achieve feature parity with other language ecosystems already supported, see the compatibility table here, and make Python’s developer experience consistent with tools like Node.js dotenv, Go’s godotenv, and others.
Changes
_get_streamandfind_dotenv, consider a path readable if it is a regular file or a FIFO usingstat.S_ISFIFO(os.stat(path).st_mode).Tests
tests/test_fifo_dotenv.py(skipped on Windows) that creates a FIFO, writes a value, and verifiesload_dotenvloads it.Notes
Disclosure
I work at 1Password and am contributing this change to improve compatibility between 1Password Environments and python-dotenv.