Files
project-manager/project_manager/preset/default/python.toml
T
2026-08-05 11:00:45 +03:00

56 lines
1.7 KiB
TOML

[presets.python]
conditions = ["{{ 'pyproject.toml' | file }}"]
variables.python_poetry = "{{ 'pyproject.toml' | read | get('build-system.build-backend') == 'poetry.core.masonry.api' }}"
# setup
[presets.python.tasks.setup.poetry]
conditions = ["{{ python_poetry }}"]
variables.python_version = "{{ 'pyproject.toml' | read | get('project.requires-python') | search('(\\d+.\\d+)') }}"
commands = ["poetry env use {{ python_version }}", "poetry install"]
# build
[presets.python.tasks.build.poetry]
conditions = ["{{ python_poetry }}"]
commands = ["poetry build"]
# publish
[presets.python.tasks.publish.poetry]
conditions = [
"{{ python_poetry }}",
"{{ 'poetry.toml' | read | get('repositories') }}",
]
variables.python_repository = "{{ 'poetry.toml' | read | get('repositories') | key(0) }}"
commands = ["poetry publish -r {{ python_repository }}"]
# test
[presets.python.tasks.test.pytest]
conditions = ["{{ '.venv/bin/pytest' | file }}"]
commands = [".venv/bin/python -m pytest"]
# lint
[presets.python.tasks.lint.pylint]
conditions = ["{{ '.venv/bin/pylint' | file }}"]
commands = [".venv/bin/pylint ./"]
[presets.python.tasks.lint.isort]
conditions = ["{{ '.venv/bin/isort' | file }}"]
commands = [".venv/bin/isort --profile black --check-only ./"]
[presets.python.tasks.lint.black]
conditions = ["{{ '.venv/bin/black' | file }}"]
commands = [".venv/bin/black --check --diff ./"]
# format
[presets.python.tasks.format.isort]
conditions = ["{{ '.venv/bin/isort' | file }}"]
commands = [".venv/bin/isort --profile black ./"]
[presets.python.tasks.format.black]
conditions = ["{{ '.venv/bin/isort' | file }}"]
commands = [".venv/bin/black ./"]
# clean
[presets.python.tasks.clean.venv]
conditions = ["{{ '.venv' | file }}"]
commands = ["rm -rf .venv"]