wexample-wex-addon-dev-python 0.1.1__py3-none-any.whl → 7.0.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.
@@ -0,0 +1,2 @@
1
+ filestate:
2
+ python_init: false
@@ -0,0 +1,11 @@
1
+ FROM python:3.12-slim
2
+
3
+ RUN pip install --no-cache-dir pytest pytest-benchmark
4
+
5
+ # The container runs as the host user (arbitrary UID/GID via docker run --user).
6
+ # Set HOME to /tmp so pip and other tools have a writable directory.
7
+ ENV HOME=/tmp
8
+
9
+ WORKDIR /app
10
+
11
+ CMD ["tail", "-f", "/dev/null"]
@@ -0,0 +1,93 @@
1
+ from __future__ import annotations
2
+
3
+ from wexample_wex_addon_app.workdir.mixin.abstract_profiling_workdir_mixin import (
4
+ AbstractProfilingWorkdirMixin,
5
+ )
6
+
7
+
8
+ class WithProfilingPythonWorkdirMixin(AbstractProfilingWorkdirMixin):
9
+ """Mixin that adds pytest-benchmark profiling capability to a Python workdir.
10
+
11
+ Runs benchmarks in the workdir's local venv so that local (unpublished)
12
+ dependencies are available — no Docker required.
13
+
14
+ Requires the workdir to have benchmark tests written with pytest-benchmark:
15
+ def test_my_function(benchmark):
16
+ benchmark(my_function, ...)
17
+ """
18
+
19
+ _BENCH_OUTPUT_FILENAME = ".wex_bench.json"
20
+
21
+ def run_profiling(self) -> dict:
22
+ import json
23
+ import subprocess
24
+
25
+ bench_output_path = self.get_path() / self._BENCH_OUTPUT_FILENAME
26
+ python = self._get_profiling_python()
27
+
28
+ bench_result = subprocess.run(
29
+ [
30
+ str(python),
31
+ "-m",
32
+ "pytest",
33
+ self.get_benchmark_dir(),
34
+ "--benchmark-only",
35
+ f"--benchmark-json={bench_output_path}",
36
+ "-q",
37
+ ],
38
+ capture_output=True,
39
+ text=True,
40
+ cwd=str(self.get_path()),
41
+ )
42
+
43
+ if not bench_output_path.exists():
44
+ return {
45
+ "error": (
46
+ "No benchmark output produced.\n"
47
+ f"pytest stdout:\n{bench_result.stdout}\n"
48
+ f"pytest stderr:\n{bench_result.stderr}"
49
+ )
50
+ }
51
+
52
+ try:
53
+ content = bench_output_path.read_text().strip()
54
+ if not content:
55
+ return {
56
+ "error": (
57
+ "No benchmark tests found. Add tests using pytest-benchmark:\n"
58
+ " def test_my_function(benchmark):\n"
59
+ " benchmark(my_function, ...)"
60
+ )
61
+ }
62
+ raw = json.loads(content)
63
+ finally:
64
+ bench_output_path.unlink(missing_ok=True)
65
+
66
+ return self._parse_profiling_output(raw)
67
+
68
+ def _get_profiling_python(self) -> Path:
69
+ import sys
70
+ from pathlib import Path
71
+
72
+ return Path(sys.executable)
73
+
74
+ def _parse_profiling_output(self, raw: dict) -> dict:
75
+ entries = []
76
+ for bench in raw.get("benchmarks", []):
77
+ stats = bench.get("stats", {})
78
+ entries.append(
79
+ {
80
+ "name": bench.get("name"),
81
+ "min_ms": round(stats.get("min", 0) * 1000, 3),
82
+ "mean_ms": round(stats.get("mean", 0) * 1000, 3),
83
+ "median_ms": round(stats.get("median", 0) * 1000, 3),
84
+ "max_ms": round(stats.get("max", 0) * 1000, 3),
85
+ "rounds": stats.get("rounds", 0),
86
+ }
87
+ )
88
+
89
+ return {
90
+ "language": "python",
91
+ "tool": "pytest-benchmark",
92
+ "entries": entries,
93
+ }
@@ -25,6 +25,40 @@ if TYPE_CHECKING:
25
25
  class PythonPackageWorkdir(PythonWorkdir):
26
26
  _project_info_cache = None
27
27
 
28
+ def check_publish_prerequisites(self) -> None:
29
+ import os
30
+ import shutil
31
+
32
+ super().check_publish_prerequisites()
33
+ if shutil.which("pdm"):
34
+ return
35
+
36
+ self.warning("'pdm' not found in PATH — required to publish Python packages.")
37
+ suggestion = (
38
+ "/home/weeger/.local/bin"
39
+ if os.path.isfile("/home/weeger/.local/bin/pdm")
40
+ else None
41
+ )
42
+ response = self.io.input(
43
+ question="Enter the directory containing pdm (will be prepended to PATH):",
44
+ default_value=suggestion,
45
+ ).get_value()
46
+
47
+ if not response:
48
+ raise RuntimeError(
49
+ "'pdm' not configured. Install it with: pipx install pdm"
50
+ )
51
+
52
+ os.environ["PATH"] = response + ":" + os.environ.get("PATH", "")
53
+ self._persist_env_value("PATH", os.environ["PATH"])
54
+ self.info(f"Added {response!r} to PATH — saved to .wex/local/env.yml")
55
+
56
+ if not shutil.which("pdm"):
57
+ raise RuntimeError(
58
+ f"'pdm' still not found after adding {response!r} to PATH. "
59
+ "Check that pdm is installed in that directory."
60
+ )
61
+
28
62
  def prepare_value(self, raw_value: DictConfig | None = None) -> DictConfig:
29
63
  from wexample_helpers.helpers.array import array_dict_get_by
30
64
  from wexample_helpers.helpers.file import file_read
@@ -25,6 +25,9 @@ from wexample_wex_addon_dev_python.const.python import (
25
25
  PYTHON_PYTEST_COV_REPORT_DIR,
26
26
  )
27
27
  from wexample_wex_addon_dev_python.file.python_app_iml_file import PythonAppImlFile
28
+ from wexample_wex_addon_dev_python.workdir.mixin.with_profiling_python_workdir_mixin import (
29
+ WithProfilingPythonWorkdirMixin,
30
+ )
28
31
 
29
32
  if TYPE_CHECKING:
30
33
  from wexample_config.const.types import DictConfig
@@ -44,7 +47,7 @@ if TYPE_CHECKING:
44
47
  )
45
48
 
46
49
 
47
- class PythonWorkdir(CodeBaseWorkdir):
50
+ class PythonWorkdir(WithProfilingPythonWorkdirMixin, CodeBaseWorkdir):
48
51
  def app_install(self, env: str | None = None, force: bool = False) -> Path:
49
52
  from wexample_wex_addon_app.helpers.python import (
50
53
  python_ensure_pip_or_fail,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wexample-wex-addon-dev-python
3
- Version: 0.1.1
3
+ Version: 7.0.0
4
4
  Summary: Python dev addon for wex
5
5
  Author-Email: weeger <contact@wexample.com>
6
6
  License: MIT
@@ -15,8 +15,8 @@ Requires-Dist: griffe>=2.0.2
15
15
  Requires-Dist: networkx
16
16
  Requires-Dist: pylint
17
17
  Requires-Dist: pyright
18
- Requires-Dist: wexample-filestate-python>=0.1.0
19
- Requires-Dist: wexample-wex-addon-app>=1.1.0
18
+ Requires-Dist: wexample-filestate-python>=6.4.0
19
+ Requires-Dist: wexample-wex-addon-app>=9.0.0
20
20
  Provides-Extra: dev
21
21
  Requires-Dist: pytest; extra == "dev"
22
22
  Requires-Dist: pytest-cov; extra == "dev"
@@ -24,7 +24,132 @@ Description-Content-Type: text/markdown
24
24
 
25
25
  # wex_addon_dev_python
26
26
 
27
- Version: 0.1.1
27
+ Version: 7.0.0
28
+
29
+ Python dev addon for wex
30
+
31
+ ## Table of Contents
32
+
33
+ - [Tests](#tests)
34
+ - [Suite Integration](#suite-integration)
35
+ - [Dependencies](#dependencies)
36
+ - [Versioning](#versioning)
37
+ - [License](#license)
38
+ - [Suite Integration](#suite-integration)
39
+ - [Suite Signature](#suite-signature)
40
+ - [Introduction](#introduction)
41
+ - [Roadmap](#roadmap)
42
+ - [Status Compatibility](#status-compatibility)
43
+ - [Useful Links](#useful-links)
44
+ - [Migration Notes](#migration-notes)
45
+
46
+ ## Tests
47
+
48
+ This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.
49
+
50
+ ### Installation
51
+
52
+ First, install the required testing dependencies:
53
+ ```bash
54
+ .venv/bin/python -m pip install pytest pytest-cov
55
+ ```
56
+
57
+ ### Basic Usage
58
+
59
+ Run all tests with coverage:
60
+ ```bash
61
+ .venv/bin/python -m pytest --cov --cov-report=html
62
+ ```
63
+
64
+ ### Common Commands
65
+ ```bash
66
+ # Run tests with coverage for a specific module
67
+ .venv/bin/python -m pytest --cov=your_module
68
+
69
+ # Show which lines are not covered
70
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing
71
+
72
+ # Generate an HTML coverage report
73
+ .venv/bin/python -m pytest --cov=your_module --cov-report=html
74
+
75
+ # Combine terminal and HTML reports
76
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html
77
+
78
+ # Run specific test file with coverage
79
+ .venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
80
+ ```
81
+
82
+ ### Viewing HTML Reports
83
+
84
+ After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.
85
+
86
+ ### Coverage Threshold
87
+
88
+ To enforce a minimum coverage percentage:
89
+ ```bash
90
+ .venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
91
+ ```
92
+
93
+ This will cause the test suite to fail if coverage drops below 80%.
94
+
95
+ ## Integration in the Suite
96
+
97
+ This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
98
+
99
+ ### Related Packages
100
+
101
+ The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
102
+
103
+ Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
104
+
105
+ ## Dependencies
106
+
107
+ - attrs: >=23.1.0
108
+ - cattrs: >=23.1.0
109
+ - griffe: >=2.0.2
110
+ - networkx:
111
+ - pylint:
112
+ - pyright:
113
+ - wexample-filestate-python: >=6.4.0
114
+ - wexample-wex-addon-app: >=9.0.0
115
+
116
+ ## Versioning & Compatibility Policy
117
+
118
+ Wexample packages follow **Semantic Versioning** (SemVer):
119
+
120
+ - **MAJOR**: Breaking changes
121
+ - **MINOR**: New features, backward compatible
122
+ - **PATCH**: Bug fixes, backward compatible
123
+
124
+ We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.
125
+
126
+ ## License
127
+
128
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
129
+
130
+ Free to use in both personal and commercial projects.
131
+
132
+ ## Integration in the Suite
133
+
134
+ This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
135
+
136
+ ### Related Packages
137
+
138
+ The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
139
+
140
+ Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
141
+
142
+ # About us
143
+
144
+ [Wexample](https://wexample.com) stands as a cornerstone of the digital ecosystem — a collective of seasoned engineers, researchers, and creators driven by a relentless pursuit of technological excellence. More than a media platform, it has grown into a vibrant community where innovation meets craftsmanship, and where every line of code reflects a commitment to clarity, durability, and shared intelligence.
145
+
146
+ This packages suite embodies this spirit. Trusted by professionals and enthusiasts alike, it delivers a consistent, high-quality foundation for modern development — open, elegant, and battle-tested. Its reputation is built on years of collaboration, refinement, and rigorous attention to detail, making it a natural choice for those who demand both robustness and beauty in their tools.
147
+
148
+ Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.
149
+
150
+ # wex_addon_dev_python
151
+
152
+ Version: 0.2.0
28
153
 
29
154
  Python dev addon for wex
30
155
 
@@ -110,7 +235,7 @@ Visit the [Wexample Suite documentation](https://docs.wexample.com) for the comp
110
235
  - pylint:
111
236
  - pyright:
112
237
  - wexample-filestate-python: >=0.1.0
113
- - wexample-wex-addon-app: >=1.1.0
238
+ - wexample-wex-addon-app: >=1.2.0
114
239
 
115
240
  ## Versioning & Compatibility Policy
116
241
 
@@ -175,3 +300,33 @@ See the [project roadmap](https://github.com/wexample/python-wex_addon_dev_pytho
175
300
  When upgrading between major versions, refer to the migration guides in the documentation.
176
301
 
177
302
  Breaking changes are clearly documented with upgrade paths and examples.
303
+
304
+ ## Known Limitations & Roadmap
305
+
306
+ Current limitations and planned features are tracked in the GitHub issues.
307
+
308
+ See the [project roadmap](https://github.com/wexample/python-wex_addon_dev_python/issues) for upcoming features and improvements.
309
+
310
+ ## Status & Compatibility
311
+
312
+ **Maturity**: Production-ready
313
+
314
+ **Python Support**: >=3.10
315
+
316
+ **OS Support**: Linux, macOS, Windows
317
+
318
+ **Status**: Actively maintained
319
+
320
+ ## Useful Links
321
+
322
+ - **Homepage**: https://github.com/wexample/python-wex-addon-dev-python
323
+ - **Documentation**: [docs.wexample.com](https://docs.wexample.com)
324
+ - **Issue Tracker**: https://github.com/wexample/python-wex-addon-dev-python/issues
325
+ - **Discussions**: https://github.com/wexample/python-wex-addon-dev-python/discussions
326
+ - **PyPI**: [pypi.org/project/wex_addon_dev_python](https://pypi.org/project/wex_addon_dev_python/)
327
+
328
+ ## Migration Notes
329
+
330
+ When upgrading between major versions, refer to the migration guides in the documentation.
331
+
332
+ Breaking changes are clearly documented with upgrade paths and examples.
@@ -1,6 +1,6 @@
1
- wexample_wex_addon_dev_python-0.1.1.dist-info/METADATA,sha256=hN6jSzby21sI5GgKk1WEPI81RMzAVGI44EAQMqJE1Ng,6259
2
- wexample_wex_addon_dev_python-0.1.1.dist-info/WHEEL,sha256=Z36eTX6lG3PITRleSd5hAZHCcz52yg3c0JQVxKBbLW0,90
3
- wexample_wex_addon_dev_python-0.1.1.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
1
+ wexample_wex_addon_dev_python-7.0.0.dist-info/METADATA,sha256=vgKhE5kJFtokoCULRFyeSDrOSPfPkX8vK26Nv8AgMI0,11753
2
+ wexample_wex_addon_dev_python-7.0.0.dist-info/WHEEL,sha256=Z36eTX6lG3PITRleSd5hAZHCcz52yg3c0JQVxKBbLW0,90
3
+ wexample_wex_addon_dev_python-7.0.0.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
4
  wexample_wex_addon_dev_python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  wexample_wex_addon_dev_python/__pycache__/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  wexample_wex_addon_dev_python/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -35,13 +35,15 @@ wexample_wex_addon_dev_python/middleware/__pycache__/__init__.py,sha256=47DEQpj8
35
35
  wexample_wex_addon_dev_python/middleware/each_python_file_middleware.py,sha256=UzNEpedCYf31aNONFl0SuSJnoXRzhJhgEiTCaPark6E,2311
36
36
  wexample_wex_addon_dev_python/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  wexample_wex_addon_dev_python/python_addon_manager.py,sha256=Mmr9F5lOS2gbb8JTB4-vTri4Qn5Cd2Jukjk7uiTr1Hs,582
38
- wexample_wex_addon_dev_python/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
+ wexample_wex_addon_dev_python/resources/.wex.yml,sha256=JdIF6nGkFcfi76yZYGlXxeWfOK4eAUSV_gAn6i3hk2w,32
39
+ wexample_wex_addon_dev_python/resources/docker/Dockerfile.python-profiling,sha256=5ujzXfWNN2nv8qQzCLel6dlOwLQ1XhIGZuqplCNB_vQ,290
39
40
  wexample_wex_addon_dev_python/resources/package_publish_gitlab.yml,sha256=WVMj-DeFedQak5s5FraEnM1Rx1-ut4KgPodvAVv25ZM,304
40
- wexample_wex_addon_dev_python/resources/readme_templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
41
  wexample_wex_addon_dev_python/resources/readme_templates/tests.md.j2,sha256=tKLcDwx7jhQkryXIxWr12AK-hKEaP6Rusu2MrluiABs,1289
42
42
  wexample_wex_addon_dev_python/workdir/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  wexample_wex_addon_dev_python/workdir/__pycache__/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
- wexample_wex_addon_dev_python/workdir/python_package_workdir.py,sha256=Fd2A7Qpsy_jstE4zj6AD4PPbMSOGkoBibhCFLDAZrXo,17637
44
+ wexample_wex_addon_dev_python/workdir/mixin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
+ wexample_wex_addon_dev_python/workdir/mixin/with_profiling_python_workdir_mixin.py,sha256=rWf_AMq4YM_vvKYZiXyhFeAz2xg0KMt_u-1FJACtvjc,3042
46
+ wexample_wex_addon_dev_python/workdir/python_package_workdir.py,sha256=cc-taJ9D11qkQM0leiAK-rg-5nCWENgueKOSwKXC758,18839
45
47
  wexample_wex_addon_dev_python/workdir/python_packages_suite_workdir.py,sha256=ICHHewLpsXiheYzGDEahphBryH98ZVezWzSAy6A5w5I,2874
46
- wexample_wex_addon_dev_python/workdir/python_workdir.py,sha256=tx6UcaBHnrq9khQ6ndG14BzFPNOlqhl-626iNoL6T1o,18078
47
- wexample_wex_addon_dev_python-0.1.1.dist-info/RECORD,,
48
+ wexample_wex_addon_dev_python/workdir/python_workdir.py,sha256=V6RB-Qm7HM5k_1qc7yL6a1y4EKjBsvy4V5VkXhcR37c,18244
49
+ wexample_wex_addon_dev_python-7.0.0.dist-info/RECORD,,