Project configuration as code
Project description
synth-a-py
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
- Add support for:
- 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.
Project details
Release history Release notifications | RSS feed
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.1.tar.gz
(10.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file synth-a-py-1.3.1.tar.gz.
File metadata
- Download URL: synth-a-py-1.3.1.tar.gz
- Upload date:
- Size: 10.3 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24c32bb72664f288bc6373d6c94cf0e91901a37e2dd69c98873ef2c7e3d0ecfa
|
|
| MD5 |
8587fed43cd80aa1cd159ded584576b6
|
|
| BLAKE2b-256 |
06b974fa60b3611796a98640998afda977d9174a6271bd593214cfd0baef6f24
|
File details
Details for the file synth_a_py-1.3.1-py3-none-any.whl.
File metadata
- Download URL: synth_a_py-1.3.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
572bda93868f0224ccb2c7102c2fc735d4bde7851d1ab9abedc16c1a5eeacb70
|
|
| MD5 |
3978f7d7261d779062d25be6fb19c3e3
|
|
| BLAKE2b-256 |
a4727727d2aa7ebfde4ba61fb063dca18db7d51a6ff6e75fc05a80fb88d53612
|