{"id":37074540,"url":"https://github.com/rsalmaso/python-readenv","last_synced_at":"2026-01-14T08:47:14.802Z","repository":{"id":150984945,"uuid":"620681224","full_name":"rsalmaso/python-readenv","owner":"rsalmaso","description":"readenv makes easy to automatically load environment variables from .env file(s) into os.environ.","archived":false,"fork":false,"pushed_at":"2025-03-23T21:01:28.000Z","size":175,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-20T23:21:34.651Z","etag":null,"topics":["env","environment-variables","envvar"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/python-readenv/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rsalmaso.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-29T06:57:13.000Z","updated_at":"2025-03-23T21:01:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"a16d5882-f7fd-4011-9a2f-42c15f562903","html_url":"https://github.com/rsalmaso/python-readenv","commit_stats":{"total_commits":41,"total_committers":1,"mean_commits":41.0,"dds":0.0,"last_synced_commit":"e414103057b054fda3cff2448c395851d2babf26"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/rsalmaso/python-readenv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsalmaso%2Fpython-readenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsalmaso%2Fpython-readenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsalmaso%2Fpython-readenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsalmaso%2Fpython-readenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rsalmaso","download_url":"https://codeload.github.com/rsalmaso/python-readenv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsalmaso%2Fpython-readenv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28414693,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:38:59.149Z","status":"ssl_error","status_checked_at":"2026-01-14T08:38:43.588Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["env","environment-variables","envvar"],"created_at":"2026-01-14T08:47:12.841Z","updated_at":"2026-01-14T08:47:14.789Z","avatar_url":"https://github.com/rsalmaso.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python-readenv\n\n`readenv` makes it easy to automatically load environment variables from `.env` file(s) and put into `os.environ`.\n\n## Install\n\n```shell\n$ pip install python-readenv\n```\n\n## Getting started\n\nYou can automatically load at startup time with the helper import `import readenv.loads`,\nwhich try to locate and load the first env file found from your current working directory up to\nroot.\nBy default it will search for `.env` and `.env.local` files.\n\n#### Automatic load\n\nYou can automatically load at startup time with the helper import \n\n```python\nimport readenv.loads\n\n...\n```\n\nwhich try to locate and load the first env file found from your current working directory up to\nroot.\n\n#### Manual load\n\nAlternatively, you can customize which files `readenv` should search and load\n\n```python\nimport readenv\n\nreadenv.load(\"myenv\", \"myenv.local\")\n```\n\n#### mypy integration\n\nIf you need to load the environment from mypy you could add\n\n```ini\n[mypy]\nplugins = readenv.mypy\n```\n\nin your `mypy.ini` or `setup.cfg` [file](https://mypy.readthedocs.io/en/latest/config_file.html).\n\n[pyproject.toml](https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml-file) configuration is also supported:\n\n```toml\n[tool.mypy]\nplugins = [\"readenv.mypy\"]\n```\n\n## Custom environment\n\nYou can create your own environment\n\n```python\nimport readenv\n\nenv = readenv.Environ()\n```\n\nor start with the current environ copy\n\n```python\nimport copy\nimport os\nimport readenv\n\nenv = Environ(copy.deepcopy(os.environ))\n```\n\n## Examples\n\n### Django integration\n\nPut the helper import as first place\n\n#### `manage.py`\n\n```python\n#!/usr/bin/env python3\n\nimport readenv.loads  # noqa: F401 isort:skip\n\nimport sys\n\n\nif __name__ == \"__main__\":\n    readenv.setdefault(\"DJANGO_SETTINGS_MODULE\", \"myproject.settings\")\n    from django.core.management import execute_from_command_line\n\n    execute_from_command_line(sys.argv)\n```\n\n#### `wsgi.py`\n\n```python\nimport readenv.loads  # noqa: F401 isort:skip\nfrom django.core.wsgi import get_wsgi_application\n\n\nreadenv.setdefault(\"DJANGO_SETTINGS_MODULE\", \"myproject.settings\")\napplication = get_wsgi_application()\n```\n\n#### `asgi.py`\n\n```python\nimport readenv.loads  # noqa: F401 isort:skip\nfrom django.core.asgi import get_asgi_application\n\n\nreadenv.setdefault(\"DJANGO_SETTINGS_MODULE\", \"myproject.settings\")\napplication = get_asgi_application()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsalmaso%2Fpython-readenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frsalmaso%2Fpython-readenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsalmaso%2Fpython-readenv/lists"}