copier/devtasks.py
Yajo bbdbeb86c3 build: better gitpod and vscode UX
These days, Gitpod supports VSCode workspaces instead of only Theia.

Theia understands settings under `.vscode` as well as under `.theia`, but VSCode only understands settings under `.vscode`. Thus, it seems reasonable to move settings to that new location and then provide a good UX on both local VSCode and Gitpod's.

I also install new tools such as commitizen.

The goal is that just clicking on Gitpod badge, you have a full dev environment ready to hack.
2021-04-15 17:46:24 +01:00

54 lines
1.3 KiB
Python

import os
import shutil
from pathlib import Path
from subprocess import check_call
def clean():
"""
Clean build, test or other process artefacrts from the project workspace
"""
build_artefacts = (
"build/",
"dist/",
"*.egg-info",
"pip-wheel-metadata",
)
python_artefacts = (
".pytest_cache",
"htmlcov",
".coverage",
"**/__pycache__",
"**/*.pyc",
"**/*.pyo",
)
project_dir = Path(".").resolve()
for pattern in build_artefacts + python_artefacts:
for matching_path in project_dir.glob(pattern):
print(f"Deleting {matching_path}")
if matching_path.is_dir():
shutil.rmtree(matching_path)
else:
matching_path.unlink()
def dev_setup():
"""Setup a development environment."""
# Gitpod sets PIP_USER=yes, which breaks poetry
env = dict(os.environ, PIP_USER="no")
check_call(["poetry", "install", "--extras", "docs"], env=env)
check_call(
[
"poetry",
"run",
"pre-commit",
"install",
"-t",
"pre-commit",
"-t",
"commit-msg",
],
env=env,
)
check_call(["poetry", "run", "pre-commit", "install-hooks"], env=env)