项目配置为代码
synth-a-p的Python项目详细描述
合成-a-py
项目配置为代码
目标
- []使用synth-a-py管理项目配置
- 添加支持:
- [x] 许可证
- [x] 汤姆(为了pyproject.toml项目)在
- [x] YAML(用于GitHub操作配置)
- []GitHub操作工作流?在
- [x] INI(用于flake8/mypy配置)
- []生成文件
- [].gitignore
- 添加/合成py在
- 添加支持:
- 模板:
- []诗歌
- []设置.py在
- []Pipenv公司
- 回购示例:
- []最小
- []Monorepo公司
示例用法
#!/usr/bin/env pythonfromtextwrapimportdedentfromsynth_a_pyimportDir,License,Project,SimpleFile,TomlFile,YamlFileauthors=["Joseph Egan"]project_name="sample-project"project_description="A sample project generated using synth-a-py"project_version="0.1.0"project_import=project_name.lower().replace("-","_")spec=Project()withspec:TomlFile("pyproject.toml",{"build-system":{"requires":["poetry>=0.12"],"build-backend":"poetry.masonry.api",},"tool":{"poetry":{"name":project_name,"version":project_version,"description":project_description,"authors":authors,"license":"MIT","dependencies":{"python":"^3.6",},"dev-dependencies":{"pytest":"^6","pyprojroot":"^0.2.0","synth-a-py":"../synth-a-py",},},},},)License.MIT("2020",", ".join(authors))SimpleFile(".gitignore",dedent("""\ *.egg *.egg-info/ *.pyc .cache/ .idea/ .mypy_cache/ .venv/ dist/ """),)SimpleFile("Makefile",dedent("""\ .PHONEY: test test: \tpoetry install \tpoetry run pytest .PHONEY: synth synth: \tpoetry run ./synth.py """),)withDir(project_import):SimpleFile("__init__.py",dedent(f"""\ __version__ = "{project_version}" """),)withDir("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 """),)withDir(".github"):withDir("workflows"):YamlFile("ci.yml",{"name":"ci","on":{"pull_request":{"branches":["main"],},"push":{"branches":["main"]},},"jobs":{"test":{"runs-on":"ubuntu-latest","steps":[{"name":"checkout","uses":"actions/checkout@v2",},{"name":"setup Python","uses":"actions/setup-python@v2","with":{"python-version":"3.9",},},{"name":"test","run":dedent("""\ pip install poetry make test """),},],},},},)spec.synth()
正在更新项目配置
为此,请编辑项目根目录下的.projenrc.js
文件,并运行npx projen
来更新现有配置或生成新配置。请使用npx prettier --trailing-comma all --write .projenrc.js
格式化此文件。在
- 项目
标签: