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 |
|
input |
${gitVersionStamp} file |
output |
The builder is called with the following parameters mapping:
Name |
Value |
|---|---|
version |
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 |
|
input |
|
output |
${pythonProjectFile} file |
The builder is called with the following parameters mapping:
Name |
Value |
|---|---|
fragment_files |
|
items |
|
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 |
|
input |
|
output |
|
if |
${pythonSrcFiles} are found |
The builder is called with the following parameters mapping:
Name |
Value |
|---|---|
src_folders |
|
command |
format ${pythonRuffCommonExtraArgs} ${pythonRuffFormatExtraArgs} |
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 |
|
input |
|
output |
|
if |
${pythonSrcFiles} are found |
The builder is called with the following parameters mapping:
Name |
Value |
|---|---|
src_folders |
|
command |
check –fix-only –select ${pythonAutoFixJoinedRules} ${pythonRuffCommonExtraArgs} ${pythonRuffFixExtraArgs} |
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 |
|
input |
|
output |
|
if |
${pythonSrcFiles} are found |
The builder is called with the following parameters mapping:
Name |
Value |
|---|---|
src_folders |
|
command |
check ${pythonRuffCommonExtraArgs} ${pythonRuffCheckExtraArgs} |
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 |
|
input |
${pythonProjectFile} file |
output |
|
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 |
|
input |
${pythonProjectFile} file |
output |
|
if |
${pythonSrcFiles} are found |
The builder is called with the following parameters mapping:
Name |
Value |
|---|---|
root_name |
|
local_deps |
|
constraints |
${pythonMergedConstraints} |
fail_on_error |
${pythonConstraintsStrictCheck} |
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 |
|
if |
${pythonTestSrcFiles} are found |
The builder is called with the following parameters mapping:
Name |
Value |
|---|---|
pytest_args |
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 |
|
input |
|
output |
${pythonWheel} file |
if |
${pythonSrcFiles} are found |
The builder is called with the following parameters mapping:
Name |
Value |
|---|---|
project_file |
|
version_file |
|
source_dirs |
|
artifacts_dir |
|
build_dir |
|
extra_resources |
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 |
|
input |
${pythonWheel} file |
output |
|
if |
${pythonSrcFiles} are found |
The builder is called with the following parameters mapping:
Name |
Value |
|---|---|
name |
|
wheel |
${pythonWheel} |
to_remove |
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 |
|
if |
${pythonSrcFiles} are found |
The builder is called with the following parameters mapping:
Name |
Value |
|---|---|
name |
|
local_deps |
${pythonLocalDepsPatterns} |