def register( manager: TaskManager, project: str, cwd: Path, substitutions: Dict[str, str], ) -> bool: """Register documentation tasks to the manager.""" manager.register(PydepsTask("python-deps", cwd, project), []) del substitutions return True
def register( manager: TaskManager, project: str, cwd: Path, substitutions: Dict[str, str], ) -> bool: """Register unit testing tasks to the manager.""" manager.register(PythonTester("python-test", cwd, project), []) manager.register(PythonTester("python-test-{pattern}", cwd, project), []) del substitutions return True
def register( manager: TaskManager, project: str, cwd: Path, substitutions: Dict[str, str], ) -> bool: """Register YAML linting tasks to the manager.""" manager.register(Yamllint("yaml-lint-{location}", cwd), []) del project del substitutions return True
def register( manager: TaskManager, project: str, cwd: Path, substitutions: Dict[str, str], ) -> bool: """Register datazen tasks to the manager.""" manager.register(DatazenTask("dz-sync", cwd), []) del project del substitutions return True
def register( manager: TaskManager, project: str, cwd: Path, substitutions: Dict[str, str], ) -> bool: """Register package building tasks to the manager.""" # Make sure 'wheel' is also installed so we can build a wheel. reqs = ["venv", "python-install-build"] manager.register(PythonBuild("python-build", cwd, once=False), reqs) manager.register(PythonBuild("python-build-once", cwd), reqs) del project del substitutions return True
def register( manager: TaskManager, project: str, cwd: Path, substitutions: Dict[str, str], ) -> bool: """Register package tasks to the manager.""" # Set up initial data so that every task has easy access to common # definitions. init_data = { "__dirs__": { "build": cwd.joinpath("build"), "venv": venv_dir(cwd), "venv_bin": venv_bin(cwd), "proj": cwd.joinpath(project), }, "__files__": { "python": venv_bin(cwd, "python") }, } # Register a task that would always fail for testing. manager.register(FailTask("fail")) # Register the initialization task. manager.register(DictMerger("vmklib.init", init_data, substitutions)) # Load additional modules. result = True for dep in [ register_venv, register_python_lint, register_python_package, register_python_yaml, register_python_build, register_python_sa, register_python_test, register_datazen, register_python_docs, ]: if result: result = dep(manager, project, cwd, substitutions) return result
def register( manager: TaskManager, project: str, cwd: Path, substitutions: Dict[str, str], ) -> bool: """Register virtual environment tasks to the manager.""" # Ensure that a valid version is set. set_if_not(substitutions, "python_version", _python_version()) # The target that actually creates the initial environment. manager.register(Venv("venv{python_version}", cwd), []) # Add a "phony" style target to just create the virtual environment. Here # We would also add dependencies like requirement-file installs. manager.register(Phony("venv"), ["venv{python_version}"]) # Look for requirements files. requirements_files = [ cwd.joinpath("requirements.txt"), cwd.joinpath("dev_requirements.txt"), cwd.joinpath(project, "requirements.txt"), cwd.joinpath(project, "dev_requirements.txt"), ] # Register requirements' install tasks. manager.register( RequirementsInstaller( "python{python_version}-project-requirements", *list(filter(lambda x: x.is_file(), requirements_files)), ), ["vmklib.init", "venv{python_version}"], ) manager.register( Phony("python-project-requirements"), ["python{python_version}-project-requirements"], ) manager.register_to("venv", ["python-project-requirements"]) return True
def register( manager: TaskManager, project: str, cwd: Path, substitutions: Dict[str, str], ) -> bool: """Register Python package tasks to the manager.""" del project del cwd del substitutions manager.register( PythonPackage("python{python_version}-install-{package}"), [] ) manager.register( Phony("python-install-{package}"), ["python{python_version}-install-{package}"], ) manager.register(PythonPackage("python-editable", "-e", package="."), []) return True
def register( manager: TaskManager, project: str, cwd: Path, substitutions: Dict[str, str], ) -> bool: """Register Python linting tasks to the manager.""" manager.register(PythonLinter("python-lint-{linter}", cwd, project), []) line_length = ["--line-length", str(substitutions.get("line_length", 79))] isort_args = line_length + [ "--profile", substitutions.get("isort_profile", "black"), "--fss", "-m", "3", ] manager.register( PythonLinter( "python-format-check-isort", cwd, project, "--check-only", *isort_args, linter="isort", ), [], ) manager.register( PythonLinter( "python-format-isort", cwd, project, *isort_args, linter="isort", ), [], ) manager.register( PythonLinter( "python-format-check-black", cwd, project, "--check", *line_length, linter="black", ), [], ) manager.register( PythonLinter( "python-format-black", cwd, project, *line_length, linter="black", ), # Depend on 'isort' so that we don't format multiple files at the same # time. ["python-format-isort"], ) manager.register( Phony("python-format-check"), ["python-format-check-black", "python-format-check-isort"], ) manager.register( Phony("python-format"), # 'black' depends on 'isort' already. ["python-format-black"], ) manager.register( Phony("python-lint"), [ "python-lint-flake8", "python-lint-pylint", "python-format-check", ], ) return True