{"id":23168681,"url":"https://github.com/eganjs/synth-a-py","last_synced_at":"2025-08-18T06:33:48.850Z","repository":{"id":52689685,"uuid":"307532462","full_name":"eganjs/synth-a-py","owner":"eganjs","description":"Project configuration as code in Python","archived":false,"fork":false,"pushed_at":"2021-05-11T20:34:08.000Z","size":96,"stargazers_count":3,"open_issues_count":8,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-22T15:16:02.407Z","etag":null,"topics":["configuration-as-code","poetry","python3"],"latest_commit_sha":null,"homepage":"","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/eganjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-26T23:34:16.000Z","updated_at":"2021-10-02T10:59:50.000Z","dependencies_parsed_at":"2022-09-26T17:40:45.153Z","dependency_job_id":null,"html_url":"https://github.com/eganjs/synth-a-py","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/eganjs/synth-a-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eganjs%2Fsynth-a-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eganjs%2Fsynth-a-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eganjs%2Fsynth-a-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eganjs%2Fsynth-a-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eganjs","download_url":"https://codeload.github.com/eganjs/synth-a-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eganjs%2Fsynth-a-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270955148,"owners_count":24674845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["configuration-as-code","poetry","python3"],"created_at":"2024-12-18T03:12:55.468Z","updated_at":"2025-08-18T06:33:48.553Z","avatar_url":"https://github.com/eganjs.png","language":"Python","readme":"# synth-a-py\n\n![Build](https://github.com/eganjs/synth-a-py/workflows/ci/badge.svg)\n\nProject configuration as code\n\n## Goals\n\n- [ ] Use synth-a-py to manage project configs\n  - Add support for:\n    - [x] LICENSE\n    - [x] TOML (for pyproject.toml)\n    - [x] YAML (for GitHub Actions config)\n      - [ ] GitHub Action workflow?\n    - [x] INI (for flake8/mypy config)\n    - [ ] Makefile\n    - [x] .gitignore\n  - Add ./synth.py\n- Templates:\n  - [ ] Poetry\n  - [ ] setup.py\n  - [ ] Pipenv\n- In-repo examples:\n  - [ ] Minimal\n  - [ ] Monorepo\n\n## Example usage\n\n```python\n#!/usr/bin/env python\nfrom textwrap import dedent\n\nfrom synth_a_py import Dir, License, Project, SimpleFile, TomlFile, YamlFile\n\nauthors = [\"Joseph Egan\"]\n\nproject_name = \"sample-project\"\nproject_description = \"A sample project generated using synth-a-py\"\nproject_version = \"0.1.0\"\n\nproject_import = project_name.lower().replace(\"-\", \"_\")\n\nspec = Project()\nwith spec:\n\n    TomlFile(\n        \"pyproject.toml\",\n        {\n            \"build-system\": {\n                \"requires\": [\"poetry\u003e=0.12\"],\n                \"build-backend\": \"poetry.masonry.api\",\n            },\n            \"tool\": {\n                \"poetry\": {\n                    \"name\": project_name,\n                    \"version\": project_version,\n                    \"description\": project_description,\n                    \"authors\": authors,\n                    \"license\": \"MIT\",\n                    \"dependencies\": {\n                        \"python\": \"^3.6\",\n                    },\n                    \"dev-dependencies\": {\n                        \"pytest\": \"^6\",\n                        \"pyprojroot\": \"^0.2.0\",\n                        \"synth-a-py\": \"../synth-a-py\",\n                    },\n                },\n            },\n        },\n    )\n\n    License.MIT(\"2020\", \", \".join(authors))\n\n    GitIgnore(\n      ignore=[\n        \"*.egg\",\n        \"*.egg-info/\",\n        \"*.pyc\",\n        \".cache/\",\n        \".idea/\",\n        \".mypy_cache/\",\n        \".venv/\",\n        \"dist/\",\n      ],\n    )\n\n    SimpleFile(\n        \"Makefile\",\n        dedent(\n            \"\"\"\\\n            .PHONEY: test\n            test:\n            \\tpoetry install\n            \\tpoetry run pytest\n\n            .PHONEY: synth\n            synth:\n            \\tpoetry run ./synth.py\n            \"\"\"\n        ),\n    )\n\n    with Dir(project_import):\n        SimpleFile(\n            \"__init__.py\",\n            dedent(\n                f\"\"\"\\\n                __version__ = \"{project_version}\"\n                \"\"\"\n            ),\n        )\n\n    with Dir(\"tests\"):\n        SimpleFile(\n            \"test_version.py\",\n            dedent(\n                f\"\"\"\\\n                import toml\n                from pyprojroot import here\n\n                from {project_import} import __version__\n\n\n                def test_version() -\u003e None:\n                    pyproject = toml.load(here(\"pyproject.toml\"))\n                    pyproject_version = pyproject[\"tool\"][\"poetry\"][\"version\"]\n\n                    assert __version__ == pyproject_version\n                \"\"\"\n            ),\n        )\n\n    with Dir(\".github\"):\n        with Dir(\"workflows\"):\n            YamlFile(\n                \"ci.yml\",\n                {\n                    \"name\": \"ci\",\n                    \"on\": {\n                        \"pull_request\": {\n                            \"branches\": [\"main\"],\n                        },\n                        \"push\": {\"branches\": [\"main\"]},\n                    },\n                    \"jobs\": {\n                        \"test\": {\n                            \"runs-on\": \"ubuntu-latest\",\n                            \"steps\": [\n                                {\n                                    \"name\": \"checkout\",\n                                    \"uses\": \"actions/checkout@v2\",\n                                },\n                                {\n                                    \"name\": \"setup Python\",\n                                    \"uses\": \"actions/setup-python@v2\",\n                                    \"with\": {\n                                        \"python-version\": \"3.9\",\n                                    },\n                                },\n                                {\n                                    \"name\": \"test\",\n                                    \"run\": dedent(\n                                        \"\"\"\\\n                                        pip install poetry\n                                        make test\n                                        \"\"\"\n                                    ),\n                                },\n                            ],\n                        },\n                    },\n                },\n            )\n\nspec.synth()\n```\n\n## Updating project config\n\nTo do this make edits to the `.projenrc.js` file in the root of the project and run `npx projen` to update existing or generate new config. Please also use `npx prettier --trailing-comma all --write .projenrc.js` to format this file.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feganjs%2Fsynth-a-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feganjs%2Fsynth-a-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feganjs%2Fsynth-a-py/lists"}