# pydantic-config-builder
A tool to build YAML configurations by merging multiple files.
## Features
- Merge multiple YAML files into a single configuration file
- Support for base configuration files with overlay files
- Recursive merging of dictionaries and arrays
- Use built configurations as base for other configurations
- Configuration file based build management
- Command line interface tool
- Support for relative and absolute paths
- Home directory expansion with ~
## Installation
```bash
pip install pydantic-config-builder
```
## Usage
Create a configuration file named `pydantic_config_builder.yml` in your project directory:
```yaml
# New format (recommended)
development:
input:
- base/*.yaml # All YAML files in base directory
- path/to/base.yaml # Specific file
output:
- default.yaml # Local output
- ~/.config/app.yaml # Global config
- build/dev.yaml # Build output
production:
input:
- default.yaml # Use output of another configuration
- configs/**/*.yaml # All YAML files in configs and subdirectories
- /path/to/overlay-*.yaml # All overlay files in specific directory
output:
- prod.yaml
- /etc/app/config.yaml
# Legacy format (still supported)
default.yaml:
- base/*.yaml
- path/to/base.yaml
```
Then run the builder:
```bash
# Use default configuration file (pydantic_config_builder.yml)
pydantic_config_builder
# Or specify a configuration file
pydantic_config_builder -c path/to/config.yml
# Enable verbose output
pydantic_config_builder -v
```
### Path Resolution
- Absolute paths (starting with /) are used as is
- Paths starting with ~ are expanded to the user's home directory
- Relative paths are resolved relative to the configuration file's directory
- Glob patterns (*, ?, []) are supported for source files
- `*.yaml` matches all YAML files in the current directory
- `**/*.yaml` matches all YAML files recursively in subdirectories
- If a pattern matches no files, a warning is printed and the pattern is skipped
### Merging Behavior
- Dictionaries are merged recursively, with later files overwriting earlier ones
- Arrays are replaced entirely (not appended or merged by index)
## Example
Given these files:
`base.yaml`:
```yaml
database:
host: localhost
port: 5432
credentials:
username: admin
logging:
level: info
```
`overlay.yaml`:
```yaml
database:
port: 5433
credentials:
password: secret
logging:
format: json
```
And this configuration:
```yaml
# pydantic_config_builder.yml
config.yaml:
- base.yaml
- overlay.yaml
```
The resulting `config.yaml` will be:
```yaml
database:
host: localhost
port: 5433
credentials:
username: admin
password: secret
logging:
level: info
format: json
```
## Documentation
For more detailed documentation, please see the [GitHub repository](https://github.com/kiarina/pydantic-config-builder).
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/kiarina/pydantic-config-builder",
"name": "pydantic-config-builder",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "pydantic, yaml, configuration, builder",
"author": "kiarina",
"author_email": "kiarinadawa@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/9c/a5/06d984c1dbbc92db31ec6ac6a94f010f1b4e9c018712e457e15f9086ebd8/pydantic_config_builder-0.5.0.tar.gz",
"platform": null,
"description": "# pydantic-config-builder\n\nA tool to build YAML configurations by merging multiple files.\n\n## Features\n\n- Merge multiple YAML files into a single configuration file\n- Support for base configuration files with overlay files\n- Recursive merging of dictionaries and arrays\n- Use built configurations as base for other configurations\n- Configuration file based build management\n- Command line interface tool\n- Support for relative and absolute paths\n- Home directory expansion with ~\n\n## Installation\n\n```bash\npip install pydantic-config-builder\n```\n\n## Usage\n\nCreate a configuration file named `pydantic_config_builder.yml` in your project directory:\n\n```yaml\n# New format (recommended)\ndevelopment:\n input:\n - base/*.yaml # All YAML files in base directory\n - path/to/base.yaml # Specific file\n output:\n - default.yaml # Local output\n - ~/.config/app.yaml # Global config\n - build/dev.yaml # Build output\n\nproduction:\n input:\n - default.yaml # Use output of another configuration\n - configs/**/*.yaml # All YAML files in configs and subdirectories\n - /path/to/overlay-*.yaml # All overlay files in specific directory\n output:\n - prod.yaml\n - /etc/app/config.yaml\n\n# Legacy format (still supported)\ndefault.yaml:\n - base/*.yaml\n - path/to/base.yaml\n```\n\nThen run the builder:\n\n```bash\n# Use default configuration file (pydantic_config_builder.yml)\npydantic_config_builder\n\n# Or specify a configuration file\npydantic_config_builder -c path/to/config.yml\n\n# Enable verbose output\npydantic_config_builder -v\n```\n\n### Path Resolution\n\n- Absolute paths (starting with /) are used as is\n- Paths starting with ~ are expanded to the user's home directory\n- Relative paths are resolved relative to the configuration file's directory\n- Glob patterns (*, ?, []) are supported for source files\n - `*.yaml` matches all YAML files in the current directory\n - `**/*.yaml` matches all YAML files recursively in subdirectories\n - If a pattern matches no files, a warning is printed and the pattern is skipped\n\n### Merging Behavior\n\n- Dictionaries are merged recursively, with later files overwriting earlier ones\n- Arrays are replaced entirely (not appended or merged by index)\n\n## Example\n\nGiven these files:\n\n`base.yaml`:\n```yaml\ndatabase:\n host: localhost\n port: 5432\n credentials:\n username: admin\nlogging:\n level: info\n```\n\n`overlay.yaml`:\n```yaml\ndatabase:\n port: 5433\n credentials:\n password: secret\nlogging:\n format: json\n```\n\nAnd this configuration:\n\n```yaml\n# pydantic_config_builder.yml\nconfig.yaml:\n - base.yaml\n - overlay.yaml\n```\n\nThe resulting `config.yaml` will be:\n\n```yaml\ndatabase:\n host: localhost\n port: 5433\n credentials:\n username: admin\n password: secret\nlogging:\n level: info\n format: json\n```\n\n## Documentation\n\nFor more detailed documentation, please see the [GitHub repository](https://github.com/kiarina/pydantic-config-builder).\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A tool to build YAML configurations by merging multiple files",
"version": "0.5.0",
"project_urls": {
"Documentation": "https://github.com/kiarina/pydantic-config-builder",
"Homepage": "https://github.com/kiarina/pydantic-config-builder",
"Repository": "https://github.com/kiarina/pydantic-config-builder"
},
"split_keywords": [
"pydantic",
" yaml",
" configuration",
" builder"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c5e5e1d9fad532fb483a502fb934ab799a933286646840589c30fae2b186fdbf",
"md5": "537de1968ca2b3e417567977184077e5",
"sha256": "cd8bb15f6489cd84c718f131986e29d39b1d8c9cfc98402aa0c5d90a450ea4ae"
},
"downloads": -1,
"filename": "pydantic_config_builder-0.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "537de1968ca2b3e417567977184077e5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 7915,
"upload_time": "2025-02-09T21:04:16",
"upload_time_iso_8601": "2025-02-09T21:04:16.955584Z",
"url": "https://files.pythonhosted.org/packages/c5/e5/e1d9fad532fb483a502fb934ab799a933286646840589c30fae2b186fdbf/pydantic_config_builder-0.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9ca506d984c1dbbc92db31ec6ac6a94f010f1b4e9c018712e457e15f9086ebd8",
"md5": "f2917dfa3fe8f3fd016e9d903b8f0837",
"sha256": "221a85be4d679a5cf0cb5a33f5e12fe1dfca45d241fe0dc65f210202e83f636f"
},
"downloads": -1,
"filename": "pydantic_config_builder-0.5.0.tar.gz",
"has_sig": false,
"md5_digest": "f2917dfa3fe8f3fd016e9d903b8f0837",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 6468,
"upload_time": "2025-02-09T21:04:18",
"upload_time_iso_8601": "2025-02-09T21:04:18.130917Z",
"url": "https://files.pythonhosted.org/packages/9c/a5/06d984c1dbbc92db31ec6ac6a94f010f1b4e9c018712e457e15f9086ebd8/pydantic_config_builder-0.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-09 21:04:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kiarina",
"github_project": "pydantic-config-builder",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pydantic-config-builder"
}