Support reading .env from FIFOs (Unix) by sidharth-sudhir · Pull Request #586 · theskumar/python-dotenv
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
- In
_get_streamandfind_dotenv, consider a path readable if it is a regular file or a FIFO usingstat.S_ISFIFO(os.stat(path).st_mode). - No behavioural change for regular files.
Tests
- Adds
tests/test_fifo_dotenv.py(skipped on Windows) that creates a FIFO, writes a value, and verifiesload_dotenvloads it.
Notes
- Unix/macOS only (Windows named pipes not covered).
Disclosure
I work at 1Password and am contributing this change to improve compatibility between 1Password Environments and python-dotenv.