Tasks

The nmk-python plugin defines the tasks described below.


Setup tasks

All tasks in this chapter are dependencies of the base setup task.


py.version – Python version stamping

This task creates/updates the ${pythonVersionStamp} stamp file, only when ${gitVersion} has changed. This allows incremental build depending on python version change (i.e. trigger rebuild if only version changed).

Property

Value/description

builder

nmk_python.version.PythonVersionRefresh

input

${gitVersionStamp} file

output

${pythonVersionStamp} file

The builder is called with the following parameters mapping:

Name

Value

version

${pythonVersion}

Note

Behavior changed in version 1.7.0
In former versions, this task was only triggered if ${pythonSrcFiles} were found.


py.project – Python project file generation

This task generates the ${pythonProjectFile} project file.

Property

Value/description

builder

nmk_base.common.TomlFileBuilder

input

${pythonProjectFileFragments} files

output

${pythonProjectFile} file

The builder is called with the following parameters mapping:

Name

Value

fragment_files

${pythonProjectFileFragments}

items

${pythonProjectFileItems}

plugin_name

“nmk-python”

Note

Behavior changed in version 1.7.0
In former versions, this task was only triggered if ${pythonSrcFiles} were found.


Build tasks


Preprocessing tasks

All tasks in this chapter are dependencies of the base build.preprocess task.

Changed in version 1.10.2 – previous dependency was on main build task.


py.format – Python code format

This task calls ruff format command to format python code of this project.

Property

Value/description

builder

nmk_python.ruff.RuffBuilder

input

${pythonSrcFiles} + ${pythonProjectFile} files

output

${pythonRuffFormatStamp} file

if

${pythonSrcFiles} are found

The builder is called with the following parameters mapping:

Name

Value

src_folders

${pythonSrcFolders}

command

format ${pythonRuffCommonExtraArgs} ${pythonRuffFormatExtraArgs}

Changed in version 1.2 – Previous value was "format"


py.fix – Python code fix

This task calls ruff check --fix-only command to fix python code of this project.

See ${pythonAutoFixRules} config item to define rules categories to auto-fix.

Property

Value/description

builder

nmk_python.ruff.RuffBuilder

input

${pythonSrcFiles} + ${pythonProjectFile} files

output

${pythonRuffFixStamp} file

if

${pythonSrcFiles} are found

The builder is called with the following parameters mapping:

Added in version 1.2


py.analyze – Python code analysis

This task calls ruff check command to analyze python code of this project.

Property

Value/description

builder

nmk_python.ruff.RuffBuilder

input

${pythonSrcFiles} + ${pythonProjectFile} files

output

${pythonRuffCheckStamp} file

if

${pythonSrcFiles} are found

The builder is called with the following parameters mapping:

Name

Value

src_folders

${pythonSrcFolders}

command

check ${pythonRuffCommonExtraArgs} ${pythonRuffCheckExtraArgs}

Changed in version 1.2 – Previous value was "check"


Compilation tasks

All tasks in this chapter are dependencies of the base build.compile task.

Changed in version 1.10.2 – previous dependency was on main build task.


py.editable – Python project install in editable mode

This task installs the project in editable mode in the venv.

Property

Value/description

builder

nmk_python.build.EditableBuilder

input

${pythonProjectFile} file

output

${pythonEditableStamp} file

if

${pythonSrcFiles} are found


py.deps – Generate Python dependencies metadata

This task generates the ${pythonDepsMetadata} metadata json file, containing all current project dependencies versions (indexed by name).

Dependencies are splitted between internal and external ones:

  • internal dependencies are all ones matching with any pattern defined in ${pythonLocalDepsPatterns} (if any)

  • external dependencies are all the other ones

Property

Value/description

builder

nmk_python.build.DepsMetadataBuilder

input

${pythonProjectFile} file

output

${pythonDepsMetadata} file

if

${pythonSrcFiles} are found

The builder is called with the following parameters mapping:

Name

Value

root_name

${pythonPackage}

local_deps

${pythonLocalDepsPatterns}

constraints

${pythonMergedConstraints}
Added in version 1.12.0

fail_on_error

${pythonConstraintsStrictCheck}
Added in version 1.12.0

Added in version 1.8.0

Since Version 1.12.0, this task also checks found external dependencies vs constraints (listed in ${pythonMergedConstraints}), i.e. raise a warning if:

  • any dependency is not found at all in the input constraints

  • any dependency version does not match the specified version constraint

Moreover, if ${pythonConstraintsStrictCheck} item is set to True, the task will fail if at least one of these warnings is raised.


Tests tasks

All tasks in this chapter are dependencies of the base tests task.


py.tests – Run Python tests

This task calls pytest command to execute python tests.

Property

Value/description

builder

nmk_python.tests.PytestBuilder

if

${pythonTestSrcFiles} are found

The builder is called with the following parameters mapping:

Name

Value

pytest_args

${pytestExtraArgs}


Package tasks

All tasks in this chapter are dependencies of the base package task.


py.build – Build Python wheel

This task use the python build module to handle the wheel build.

Property

Value/description

builder

nmk_python.build.PackageBuilder

input

${pythonSrcFiles} + ${pythonProjectFile} files

output

${pythonWheel} file

if

${pythonSrcFiles} are found

The builder is called with the following parameters mapping:

Name

Value

project_file

${pythonProjectFile}

version_file

${pythonVersionStamp}

source_dirs

${pythonSrcFolders}

artifacts_dir

${pythonArtifacts}

build_dir

${pythonBuildDir}

extra_resources

${pythonExtraResources}


Install tasks

All tasks in this chapter are dependencies of the base install task.


py.install – Install Python wheel

This task installs the built python wheel in the project venv.

Property

Value/description

builder

nmk_python.build.Installer

input

${pythonWheel} file

output

${venvState}

if

${pythonSrcFiles} are found

The builder is called with the following parameters mapping:

Name

Value

name

${pythonPackage}

wheel

${pythonWheel}

Changed in version 1.7.0

to_remove

${pythonEditableStamp}

The builder also removes the ${pythonEditableStamp} stamp file, to force installing the project in editable mode again on the next build.


Clean tasks

All tasks in this chapter are dependencies of the base clean task.


py.uninstall – Uninstall Python wheel and local dependencies

This task uninstalls the built python wheel and its local dependencies from the project venv.

Property

Value/description

builder

nmk_python.build.Uninstaller

if

${pythonSrcFiles} are found

The builder is called with the following parameters mapping:

Name

Value

name

${pythonPackage}

local_deps

${pythonLocalDepsPatterns}

Added in version 1.8.0