Skip to main content

A CLI tool to export environment variables from Python settings files.

Project description

tests lint

sync-settings-dotenv

A Python CLI to sync configs between dotenv files and Python settings module.

It allows to define your application settings in a Python module and use it as a source of truth, instead of maintaining both the settings module and multiple dotenv files manually.

Currently only supports BaseSettings model from pydantic-settings.

Prerequisites

  • uv installed

Installation

The tool can be installed using uv tool:

uv tool install sync-settings-dotenv

After installation, it will be available as sync-settings-dotenv command in your terminal.

Usage

For details on usage, run:

sync-settings-dotenv --help

Generate a .env.example from Python settings file

To generate a .env.example file from a Python settings file, run:

sync-settings-dotenv path.to.settings.Module path/to/.env.example --exact

This command will create a .env.example file with all environment variables defined in the specified settings module, using their default values.

A backup of the previous version will be created as .env.example.backup.timestamp if the file already exists.

Sync from Python settings file to .env file

sync-settings-dotenv path.to.settings.Module /path/to/.env

This command will generate or update the existing .env file with default values from the specified settings module. If the .env file already exists, it will only add missing variables without overwriting existing ones.

To overwrite existing values in the .env file, use the --overwrite-values flag:

sync-settings-dotenv path.to.settings.Module /path/to/.env --overwrite-values

Sync from .env.example file to .env file

It is also possible to sync from an existing .env.example file to a .env file:

sync-settings-dotenv /path/to/.env.example /path/to/.env

It works the same way as syncing from a Python settings file.

Update and Uninstallation

To upgrade to the latest version, run:

uv tool upgrade sync-settings-dotenv

To uninstall the tool (noooo), run:

uv tool uninstall sync-settings-dotenv

Development

To set up the development environment, run:

make dev-setup

To verify all development checks:

make check-all

To install the tool in editable mode:

make local-install

Take a look at the Makefile for more commands to help with development and testing.

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

sync_settings_dotenv-0.2.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sync_settings_dotenv-0.2.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file sync_settings_dotenv-0.2.0.tar.gz.

File metadata

  • Download URL: sync_settings_dotenv-0.2.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sync_settings_dotenv-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5aff5216d0e52b0866ebffd326860ee54900a5c7f8e1a32a76147195d6475471
MD5 f5cba08d596ea485b2885716846f5970
BLAKE2b-256 339a8e2e08394d4153058c0a21be4a062c31c9364ee55dd6c92fae8e336c28f2

See more details on using hashes here.

File details

Details for the file sync_settings_dotenv-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: sync_settings_dotenv-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sync_settings_dotenv-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7abeb74bfaa69dc0a01ae1ec7989659fb29e9f57e0db5e3b70b6fe9f9a427b81
MD5 f79e652b0769439ab51cfc4a3bb5ed8e
BLAKE2b-256 d7d0b05962794e0079ceee02a088c7adfe889260ba781299fe929c74a7930e04

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page