Skip to main content

synth-a-py

Build

Project configuration as code

Example usage

#!/usr/bin/env python
from textwrap import dedent

from synth_a_py import Dir, Project, SimpleFile, TomlFile

project_name = "sample-project"
project_version = "0.1.0"
project_import = project_name.lower().replace("-", "_")

spec = Project()
with spec:
    with Dir(".github"):
        with Dir("workflows"):
            SimpleFile(
                "ci.yml",
                dedent(
                    """\
                    ...
                    """
                ),
            )
            SimpleFile(
                "publish.yml",
                dedent(
                    """\
                    ...
                    """
                ),
            )

    TomlFile(
        "pyproject.toml",
        {
            "build-system": {
                "requires": ["poetry>=0.12"],
                "build-backend": "poetry.masonry.api",
            },
            "tool": {
                "poetry": {
                    "name": project_name,
                    "version": project_version,
                    "description": "A sample project generated using synth-a-py",
                    "authors": ["Joseph Egan"],
                    "dependencies": {
                        "python": "^3.6",
                    },
                    "dev-dependencies": {
                        "pytest": "^6",
                        "pyprojroot": "^0.2.0",
                    },
                },
            },
        },
    )

    SimpleFile(
        "Makefile",
        dedent(
            """\
            .PHONEY: test
            test:
            \tpoetry install
            \tpoetry run pytest
            """
        ),
    )

    with Dir(project_import):
        SimpleFile(
            "__init__.py",
            dedent(
                f"""\
                __version__ = "{project_version}"
                """
            ),
        )

    with Dir("tests"):
        SimpleFile(
            "test_version.py",
            dedent(
                f"""\
		import toml
		from pyprojroot import here

		from {project_import} import __version__


		def test_version() -> None:
		    pyproject = toml.load(here("pyproject.toml"))
		    pyproject_version = pyproject["tool"]["poetry"]["version"]

		    assert __version__ == pyproject_version
                """
            ),
        )

spec.synth()

Goals

  • Use synth-a-py to manage project configs
    • Add support for:
      • LICENSE
      • TOML (for pyproject.toml)
      • YAML (for GitHub Actions config)
        • GitHub Action workflow?
      • INI (for flake8/mypy config)
      • Makefile
      • .gitignore
    • Add ./synth.py
  • Templates:
    • Poetry
    • setup.py
    • Pipenv
  • In-repo examples:
    • Minimal
    • Monorepo

Updating project config

To 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

synth-a-py-1.3.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

synth_a_py-1.3.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file synth-a-py-1.3.0.tar.gz.

File metadata

  • Download URL: synth-a-py-1.3.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.6 Linux/5.4.0-1031-azure

File hashes

Hashes for synth-a-py-1.3.0.tar.gz
Algorithm Hash digest
SHA256 f4118d03b84b8de30b14288f6e1110d0acc019456c1533c8c7dce9d777bf3cc2
MD5 1ba1bd11f769eb07a3f49bf088fb6284
BLAKE2b-256 eaad649c4b2a91a5a20c896328f408814700b74492ffe1ede73e06109106f43b

See more details on using hashes here.

File details

Details for the file synth_a_py-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: synth_a_py-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.6 Linux/5.4.0-1031-azure

File hashes

Hashes for synth_a_py-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 47b3d9b90936a505e857ea6162268df0b59cc9e7e119a69cdd53c5b2ea3addc0
MD5 ef9b46c8383e9a3a5e76f24fed559ca5
BLAKE2b-256 d847b58e7e4b03765c9f967e87680c7db02028e961437cda7bde0ea5814155cc

See more details on using hashes here.

Release history Release notifications | RSS feed

1.6.0

2 files

1.5.0

2 files

1.4.0

2 files

1.3.1

2 files

This release

1.3.0 This release

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page