# Tasks The **`nmk-python`** plugin defines the tasks described below. ## Setup tasks All tasks in this chapter are dependencies of the base [**`setup`**](https://nmk-base.readthedocs.io/en/stable/tasks.html#setup-task) task. (py.version)= ### **`py.version`** -- Python version stamping This task creates/updates the **{ref}`${pythonVersionStamp}`** stamp file, only when [${gitVersion}](https://nmk-base.readthedocs.io/en/stable/config.html#gitversion-git-version) has changed. This allows incremental build depending on python version change (i.e. trigger rebuild if only version changed). | Property | Value/description | |- |- | builder | {py:class}`nmk_python.version.PythonVersionRefresh` | input | [${gitVersionStamp}](https://nmk-base.readthedocs.io/en/stable/config.html#gitversionstamp-git-version-resolution-stamp-file) file | output | {ref}`${pythonVersionStamp}` file | if | {ref}`${pythonSrcFiles}` are found The builder is called with the following parameters mapping: | Name | Value | |- |- | version | **{ref}`${pythonVersion}`** (py.project)= ### **`py.project`** -- Python project file generation This task generates the **{ref}`${pythonProjectFile}`** project file. | Property | Value/description | |- |- | builder | [nmk_base.common.TomlFileBuilder](https://nmk-base.readthedocs.io/en/stable/autoapi/nmk_base/common/index.html#nmk_base.common.TomlFileBuilder) | input | {ref}`${pythonProjectFileFragments}` files | output | {ref}`${pythonProjectFile}` file | if | {ref}`${pythonSrcFiles}` are found The builder is called with the following parameters mapping: | Name | Value | |- |- | fragment_files | **{ref}`${pythonProjectFileFragments}`** | items | **{ref}`${pythonProjectFileItems}`** | plugin_name | "nmk-python" ## Build tasks All tasks in this chapter are dependencies of the base [**`build`**](https://nmk-base.readthedocs.io/en/stable/tasks.html#build-task) task. (py.format)= ### **`py.format`** -- Python code format This task calls **`ruff format`** command to format python code of this project. | Property | Value/description | |- |- | builder | {py:class}`nmk_python.ruff.RuffBuilder` | input | {ref}`${pythonSrcFiles}` + {ref}`${pythonProjectFile}` files | output | {ref}`${pythonRuffFormatStamp}` file | if | {ref}`${pythonSrcFiles}` are found The builder is called with the following parameters mapping: | Name | Value | |- |- | src_folders | **{ref}`${pythonSrcFolders}`** | command | format (py.analysis)= ### **`py.analysis`** -- Python code analysis This task calls **`ruff check`** command to analyze python code of this project. | Property | Value/description | |- |- | builder | {py:class}`nmk_python.ruff.RuffBuilder` | input | {ref}`${pythonSrcFiles}` + {ref}`${pythonProjectFile}` files | output | {ref}`${pythonRuffCheckStamp}` file | if | {ref}`${pythonSrcFiles}` are found The builder is called with the following parameters mapping: | Name | Value | |- |- | src_folders | **{ref}`${pythonSrcFolders}`** | command | check (py.build)= ### **`py.build`** -- Build Python wheel This task use the python **`build`** module to handle the wheel build. | Property | Value/description | |- |- | builder | {py:class}`nmk_python.build.PackageBuilder` | input | {ref}`${pythonSrcFiles}` + {ref}`${pythonProjectFile}` files | output | {ref}`${pythonWheel}` file | if | {ref}`${pythonSrcFiles}` are found The builder is called with the following parameters mapping: | Name | Value | |- |- | project_file | **{ref}`${pythonProjectFile}`** | version_file | **{ref}`${pythonVersionStamp}`** | source_dirs | **{ref}`${pythonSrcFolders}`** | artifacts_dir | **{ref}`${pythonArtifacts}`** | build_dir | **{ref}`${pythonBuildDir}`** | extra_resources | **{ref}`${pythonExtraResources}`** (py.install)= ### **`py.install`** -- Install Python wheel This task installs the built python wheel in the project venv. | Property | Value/description | |- |- | builder | {py:class}`nmk_python.build.Installer` | input | {ref}`${pythonWheel}` file | output | [${venvState}](https://nmk-base.readthedocs.io/en/stable/config.html#venvstate-output-requirements-file-name) | if | {ref}`${pythonSrcFiles}` are found The builder is called with the following parameters mapping: | Name | Value | |- |- | name | **{ref}`${pythonPackage}`** | pip_args | "--force-reinstall --no-deps ${venvPipArgs}" ## Tests tasks All tasks in this chapter are dependencies of the base [**`tests`**](https://nmk-base.readthedocs.io/en/stable/tasks.html#tests-task) task. (py.tests)= ### **`py.tests`** -- Run Python tests This task calls **`pytest`** command to execute python tests. | Property | Value/description | |- |- | builder | {py:class}`nmk_python.tests.PytestBuilder` | if | {ref}`${pythonTestSrcFiles}` are found The builder is called with the following parameters mapping: | Name | Value | |- |- | pytest_args | **{ref}`${pytestExtraArgs}`** ## Clean tasks All tasks in this chapter are dependencies of the base [**`clean`**](https://nmk-base.readthedocs.io/en/stable/tasks.html#clean-task) task. (py.uninstall)= ### **`py.uninstall`** -- Uninstall Python wheel This task uninstalls the built python wheel from the project venv. | Property | Value/description | |- |- | builder | {py:class}`nmk_python.build.Uninstaller` | if | {ref}`${pythonSrcFiles}` are found The builder is called with the following parameters mapping: | Name | Value | |- |- | name | **{ref}`${pythonPackage}`**