nmk-python 1.1.0__py3-none-any.whl → 1.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
nmk_python/build.py CHANGED
@@ -9,7 +9,7 @@ from pathlib import Path
9
9
 
10
10
  from nmk.model.builder import NmkTaskBuilder
11
11
  from nmk.model.keys import NmkRootConfig
12
- from nmk.model.resolver import NmkStrConfigResolver
12
+ from nmk.model.resolver import NmkListConfigResolver, NmkStrConfigResolver
13
13
  from nmk.utils import is_windows, run_pip, run_with_logs
14
14
  from nmk_base.venvbuilder import VenvUpdateBuilder
15
15
  from tomlkit import loads
@@ -176,3 +176,15 @@ class EditableBuilder(NmkTaskBuilder):
176
176
 
177
177
  # Touch stamp file
178
178
  self.main_output.touch()
179
+
180
+
181
+ class PythonOptionalDepsResolver(NmkListConfigResolver):
182
+ """
183
+ Python optional deps resolver
184
+ """
185
+
186
+ def get_value(self, name: str, groups: dict[str, list[str]]) -> list[str]:
187
+ """
188
+ Turn dependency options deps dict into a merged list of dependencies
189
+ """
190
+ return sorted(list(set(dependency for deps in groups.values() for dependency in deps)))
nmk_python/build.yml CHANGED
@@ -21,10 +21,25 @@ config:
21
21
  pythonProjectFileFragments:
22
22
  - ${BASEDIR}/templates/build.toml.jinja
23
23
 
24
- # Python package dependencies (also contributed to venv)
24
+ # Python optional deps (named groups of python package optional dependencies)
25
+ pythonPackageOptionalRequirements: {}
26
+
27
+ # Derived list of python dependencies from the dependency groups
28
+ pythonPackageOptionalRequirementsList:
29
+ __resolver__: nmk_python.build.PythonOptionalDepsResolver
30
+ params:
31
+ groups: ${pythonPackageOptionalRequirements}
32
+ pythonProjectFileItems:
33
+ project:
34
+ optional-dependencies: ${pythonPackageOptionalRequirements}
35
+
36
+ # Python package dependencies
25
37
  pythonPackageRequirements: []
38
+
39
+ # Also install in venv all dependencies
26
40
  venvPkgDeps:
27
41
  - ${pythonPackageRequirements}
42
+ - ${pythonPackageOptionalRequirementsList}
28
43
 
29
44
  # Extra (external) resources to be bundled in built python wheel
30
45
  pythonExtraResources: {}
nmk_python/ruff.py CHANGED
@@ -7,6 +7,7 @@ from pathlib import Path
7
7
 
8
8
  from nmk.model.builder import NmkTaskBuilder
9
9
  from nmk.model.keys import NmkRootConfig
10
+ from nmk.model.resolver import NmkStrConfigResolver
10
11
  from nmk.utils import run_with_logs
11
12
 
12
13
 
@@ -35,7 +36,23 @@ class RuffBuilder(NmkTaskBuilder):
35
36
  relative_src_folders.append(p)
36
37
 
37
38
  # Delegate to ruff
38
- run_with_logs(["ruff", command] + relative_src_folders, self.logger, cwd=project_folder)
39
+ run_with_logs(["ruff"] + [arg for arg in command.split(" ") if arg] + relative_src_folders, self.logger, cwd=project_folder)
39
40
 
40
41
  # Touch output file
41
42
  self.main_output.touch()
43
+
44
+
45
+ class JoinedRulesResolver(NmkStrConfigResolver):
46
+ """
47
+ Join auto-fix rules as a comma separated string
48
+ """
49
+
50
+ def get_value(self, name: str, rules: list[str]) -> str:
51
+ """
52
+ Return coma separated rules list string
53
+
54
+ :param name: name of the config
55
+ :param rules: list of rules
56
+ :return: coma separated rules list string
57
+ """
58
+ return ",".join(rules)
nmk_python/ruff.yml CHANGED
@@ -9,8 +9,23 @@ config:
9
9
 
10
10
  # Stamp files for ruff execution
11
11
  pythonRuffFormatStamp: ${outputDir}/.ruff-format
12
+ pythonRuffFixStamp: ${outputDir}/.ruff-fix
12
13
  pythonRuffCheckStamp: ${outputDir}/.ruff-check
13
14
 
15
+ # Extra arguments for ruff command lines
16
+ pythonRuffCommonExtraArgs: ""
17
+ pythonRuffFormatExtraArgs: ""
18
+ pythonRuffFixExtraArgs: ""
19
+ pythonRuffCheckExtraArgs: ""
20
+
21
+ # Auto-fix rules
22
+ pythonAutoFixRules: ["I"] # Default: only fix imports
23
+ pythonAutoFixJoinedRules:
24
+ __resolver__: nmk_python.ruff.JoinedRulesResolver
25
+ params:
26
+ rules:
27
+ - ${pythonAutoFixRules}
28
+
14
29
  # Ignored rules
15
30
  pythonIgnoredRules:
16
31
  - E203 # space before ":"; sometimes formatting with black introduces this kind of space in slice expressions
@@ -39,14 +54,32 @@ tasks:
39
54
  builder: nmk_python.ruff.RuffBuilder
40
55
  params:
41
56
  src_folders: ${pythonSrcFolders}
42
- command: format
57
+ command: format ${pythonRuffCommonExtraArgs} ${pythonRuffFormatExtraArgs}
58
+
59
+ # Python source code fix with ruff
60
+ py.fix:
61
+ description: Fix python code
62
+ emoji: ":snake:.:wrench:"
63
+ deps:
64
+ - py.format
65
+ appendToDeps: build
66
+ if: ${pythonSrcFiles} # Only if python source files are found
67
+ output:
68
+ - ${pythonRuffFixStamp}
69
+ input:
70
+ - ${pythonProjectFile}
71
+ - ${pythonSrcFiles}
72
+ builder: nmk_python.ruff.RuffBuilder
73
+ params:
74
+ src_folders: ${pythonSrcFolders}
75
+ command: check --fix-only --select ${pythonAutoFixJoinedRules} ${pythonRuffCommonExtraArgs} ${pythonRuffFixExtraArgs}
43
76
 
44
77
  # Python source code analysis with ruff
45
78
  py.analyze:
46
79
  description: Analyze python code
47
80
  emoji: ":snake:.:eye: "
48
81
  deps:
49
- - py.format
82
+ - py.fix
50
83
  appendToDeps: build
51
84
  if: ${pythonSrcFiles} # Only if python source files are found
52
85
  output:
@@ -57,4 +90,4 @@ tasks:
57
90
  builder: nmk_python.ruff.RuffBuilder
58
91
  params:
59
92
  src_folders: ${pythonSrcFolders}
60
- command: check
93
+ command: check ${pythonRuffCommonExtraArgs} ${pythonRuffCheckExtraArgs}
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: nmk-python
3
- Version: 1.1.0
3
+ Version: 1.3.0
4
4
  Summary: Python plugin for nmk build system
5
5
  Author: The dynod project
6
6
  Maintainer: The dynod project
@@ -26,6 +26,7 @@ Requires-Dist: ruff
26
26
  Requires-Dist: pytest-xdist
27
27
  Requires-Dist: pytest-cov
28
28
  Requires-Dist: pytest-multilog
29
+ Dynamic: license-file
29
30
 
30
31
  # nmk-python
31
32
  Python plugin for nmk build system
@@ -43,7 +44,7 @@ Python plugin for nmk build system
43
44
 
44
45
  This plugin adds support for Python development in an **`nmk`** project:
45
46
  * project file generation
46
- * code format and analysis with [ruff](https://astral.sh/ruff)
47
+ * code format, fix and analysis with [ruff](https://astral.sh/ruff)
47
48
  * python wheel build
48
49
  * test with [pytest](https://pytest.org)
49
50
  * VSCode settings generation (if [**`nmk-vscode`**](https://github.com/dynod/nmk-vscode) plugin is also used)
@@ -1,14 +1,14 @@
1
1
  nmk_python/__init__.py,sha256=EouCWXbAeObby1vOCx0Vx_WaGC2fEEFDMCen3JZt4TU,446
2
2
  nmk_python/badges.yml,sha256=LzElZecCXKxdF-oPkvIwfnbQlOcAM_zUj6MelClmAug,749
3
- nmk_python/build.py,sha256=rN7CvAUPU-gGsg17cBojdqGBSbW-GAEFItz234rqM1E,6307
4
- nmk_python/build.yml,sha256=Yn4zVuNNo1fnAsvlI_ul_kmEpLp_5WHK4pA0T9kkQ3I,4297
3
+ nmk_python/build.py,sha256=K8BowkROfrGwOPk7wKwOo9fsWJrrk8bDqJqliC876WI,6716
4
+ nmk_python/build.yml,sha256=WLSVQN1y4zqGHyMZxa4GlMuOZNyvV_NJvjOLJCVvdDs,4860
5
5
  nmk_python/doc.yml,sha256=12amAlYylH7JAHaqBIOoEZ_LrXY_bPNKuHrrwUkIj8w,932
6
6
  nmk_python/files.py,sha256=gtPf6ldR5F4oGsAdzFnEIbI9MqqvF3z5JQnyONZmLmk,1863
7
7
  nmk_python/files.yml,sha256=-vGjogdulwsfdKVEUa5RARYDKxF3m9RmHKFnIhaT3_k,780
8
8
  nmk_python/plugin.yml,sha256=hi7osXyIwpHgJAsww5mhOA6emxhzgitDF8cOsvyY29Y,1068
9
9
  nmk_python/project.yml,sha256=sRIMvKkasrYlIvOo3DsVyNM_sgID_sHVgZg_bSIqtfw,975
10
- nmk_python/ruff.py,sha256=tfqC66NEB3P1FID1qzP-Ba3hafF02A1I9GIeruGUW2U,1058
11
- nmk_python/ruff.yml,sha256=09ackKHfT9oXKqIniYUehFkyW2DUxlHl5Ak5x2tlvQQ,1808
10
+ nmk_python/ruff.py,sha256=TBmn5nFflcFRvjj36JtJGJ-GYHOK6XfhK9Jp-2dO5_E,1557
11
+ nmk_python/ruff.yml,sha256=FNmYjbv2l5vlqFXinY87LfgzpZ3PSiduB_xUiYw8aMw,3019
12
12
  nmk_python/tests.py,sha256=8kRKP3dT2Thi5W5sCQSQOPXkV1D9C7tde3QYySo6G2c,1212
13
13
  nmk_python/tests.yml,sha256=wQusYK1bxSl87zWFQy5lJcrkcAz4pMEZT9Vt6o2K5Vs,1538
14
14
  nmk_python/version.py,sha256=fLpOWdujYwlJB7XhWaOGCTeg3gQaClk2YHoRkkW64dE,3109
@@ -19,8 +19,8 @@ nmk_python/templates/pytest.toml.jinja,sha256=zQ3SRWnF23Omxm7zInE54j0l3OyjXSOn5p
19
19
  nmk_python/templates/python-settings.json.jinja,sha256=-6J1tybWEzChxlDqu4tp9BMWxbYD8HpztGs9G8LkC_w,877
20
20
  nmk_python/templates/python-test-debug-launch.json.jinja,sha256=J_xju2EpHNXvgvqBxlf99p7g-ZMh3xE-_2r7o_57gpU,364
21
21
  nmk_python/templates/ruff.toml.jinja,sha256=DTHe1ixK1SBY8d2xBCfkGz89HzjAoMO7Ogs12AY1i4Y,346
22
- nmk_python-1.1.0.dist-info/LICENSE,sha256=PROo9EW7wP6jmSr_90OluItAsIB411b_CAqEBioMKpI,1074
23
- nmk_python-1.1.0.dist-info/METADATA,sha256=xdcI0iJEVV_3VQQHdj2m0oEo5ith5CAhcSMQSXM2CWo,3118
24
- nmk_python-1.1.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
25
- nmk_python-1.1.0.dist-info/top_level.txt,sha256=MCb5w_hoOZ0kk3Dajxrd9Pz6lZ3pyuS6TQCRA3vddTo,11
26
- nmk_python-1.1.0.dist-info/RECORD,,
22
+ nmk_python-1.3.0.dist-info/licenses/LICENSE,sha256=PROo9EW7wP6jmSr_90OluItAsIB411b_CAqEBioMKpI,1074
23
+ nmk_python-1.3.0.dist-info/METADATA,sha256=C_R9ask9HqHqC8qFlgU6PrHRXe9leUBOQCu8a3KC798,3145
24
+ nmk_python-1.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
+ nmk_python-1.3.0.dist-info/top_level.txt,sha256=MCb5w_hoOZ0kk3Dajxrd9Pz6lZ3pyuS6TQCRA3vddTo,11
26
+ nmk_python-1.3.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5