scaldys-template 0.7.0__tar.gz

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.
Files changed (29) hide show
  1. scaldys_template-0.7.0/LICENSE +21 -0
  2. scaldys_template-0.7.0/PKG-INFO +19 -0
  3. scaldys_template-0.7.0/README.md +355 -0
  4. scaldys_template-0.7.0/pyproject.toml +82 -0
  5. scaldys_template-0.7.0/setup.cfg +4 -0
  6. scaldys_template-0.7.0/src/scaldys_template/__about__.py +19 -0
  7. scaldys_template-0.7.0/src/scaldys_template/__init__.py +4 -0
  8. scaldys_template-0.7.0/src/scaldys_template/__main__.py +249 -0
  9. scaldys_template-0.7.0/src/scaldys_template/cli/__init__.py +3 -0
  10. scaldys_template-0.7.0/src/scaldys_template/cli/cli.py +93 -0
  11. scaldys_template-0.7.0/src/scaldys_template/cli/commands/__init__.py +5 -0
  12. scaldys_template-0.7.0/src/scaldys_template/cli/commands/arg_types.py +27 -0
  13. scaldys_template-0.7.0/src/scaldys_template/cli/commands/cmd_export.py +112 -0
  14. scaldys_template-0.7.0/src/scaldys_template/cli/commands/cmd_process.py +233 -0
  15. scaldys_template-0.7.0/src/scaldys_template/cli/commands/cmd_settings.py +73 -0
  16. scaldys_template-0.7.0/src/scaldys_template/cli/settings.py +88 -0
  17. scaldys_template-0.7.0/src/scaldys_template/common/__init__.py +4 -0
  18. scaldys_template-0.7.0/src/scaldys_template/common/app_location.py +130 -0
  19. scaldys_template-0.7.0/src/scaldys_template/common/logging.py +253 -0
  20. scaldys_template-0.7.0/src/scaldys_template/core/async_processor.py +273 -0
  21. scaldys_template-0.7.0/src/scaldys_template/core/database.py +346 -0
  22. scaldys_template-0.7.0/src/scaldys_template/core/export.py +60 -0
  23. scaldys_template-0.7.0/src/scaldys_template/py.typed +0 -0
  24. scaldys_template-0.7.0/src/scaldys_template.egg-info/PKG-INFO +19 -0
  25. scaldys_template-0.7.0/src/scaldys_template.egg-info/SOURCES.txt +27 -0
  26. scaldys_template-0.7.0/src/scaldys_template.egg-info/dependency_links.txt +1 -0
  27. scaldys_template-0.7.0/src/scaldys_template.egg-info/entry_points.txt +2 -0
  28. scaldys_template-0.7.0/src/scaldys_template.egg-info/requires.txt +5 -0
  29. scaldys_template-0.7.0/src/scaldys_template.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 Scaldys
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,19 @@
1
+ Metadata-Version: 2.4
2
+ Name: scaldys-template
3
+ Version: 0.7.0
4
+ Summary: A skeleton for Python projects by Scaldys.
5
+ Author-email: scaldys-template <scaldys@scaldys.net>
6
+ Classifier: Programming Language :: Python
7
+ Classifier: Operating System :: OS Independent
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Topic :: Utilities
11
+ Requires-Python: >=3.13
12
+ Description-Content-Type: text/x-rst
13
+ License-File: LICENSE
14
+ Requires-Dist: art>=6.5
15
+ Requires-Dist: platformdirs>=4.9.6
16
+ Requires-Dist: pydantic>=2.0
17
+ Requires-Dist: rich>=13.0
18
+ Requires-Dist: typer>=0.25.0
19
+ Dynamic: license-file
@@ -0,0 +1,355 @@
1
+ # Scaldys Template
2
+
3
+ ![License](https://img.shields.io/github/license/scaldys/scaldys-template)
4
+
5
+ A modern Python project template with best practices.
6
+
7
+ This template provides a solid foundation for Python projects with integrated
8
+ testing, documentation, and quality assurance tools. While primarily created for
9
+ personal use, it's available for anyone to use or fork on GitHub:
10
+ https://github.com/scaldys/scaldys-template
11
+
12
+ ## Features
13
+
14
+ - Modern Python development with Python 3.13+
15
+ - Command-line interface (CLI) built with Typer — global flags (`--log`,
16
+ `--verbose`) resolved once before any subcommand runs
17
+ - Application lifecycle entry point (`__main__.py`) covering freeze support,
18
+ crash hooks, signal handlers, asyncio policy, and environment validation
19
+ - Reference implementations in `core/` for async processing pipelines
20
+ (`async_processor.py`) and database abstraction (`database.py`)
21
+ - Fast dependency management with `uv`
22
+ - Comprehensive testing with `pytest`, `pytest-asyncio`, `pytest-mock`, and
23
+ coverage reporting — structured with unit / integration / slow markers
24
+ - Code quality verification with `ruff` (linting & formatting) and `pyright`
25
+ (type checking)
26
+ - Documentation with reStructuredText and `sphinx` using ReadTheDocs theme
27
+ - Windows build infrastructure with `Cython`, `scaldys-project`, and — depending
28
+ on the deployment mode — `PyInstaller`, `Inno Setup`, or wheel-only packaging
29
+ - GitHub Actions workflows for CI/CD and PyPI publishing
30
+
31
+ ## Project Structure
32
+
33
+ ```
34
+ src/scaldys_template/
35
+ ├── __main__.py ← lifecycle entry point (freeze_support, crash hook,
36
+ │ signal handlers, asyncio policy, env validation)
37
+ ├── cli/
38
+ │ ├── cli.py ← Typer app; owns the single setup_logging() call
39
+ │ ├── settings.py ← AppSettings: persisted log level (INI + Pydantic)
40
+ │ └── commands/
41
+ │ ├── arg_types.py ← shared Annotated type definitions
42
+ │ ├── cmd_export.py
43
+ │ ├── cmd_process.py ← demonstrates async pipeline + DB connection
44
+ │ └── cmd_settings.py
45
+ ├── common/
46
+ │ ├── app_location.py ← OS-aware path resolution (Windows/macOS/Linux,
47
+ │ │ source vs installed vs frozen)
48
+ │ └── logging.py ← QueueHandler-based JSON logging setup
49
+ └── core/
50
+ ├── export.py
51
+ ├── async_processor.py ← async pipeline pattern + sync wrapper
52
+ └── database.py ← connection, transaction, pool scaffold
53
+
54
+ tests/
55
+ ├── conftest.py ← isolated_app_location keystone fixture
56
+ ├── unit/
57
+ │ ├── conftest.py ← reset_scaldys_template_logger autouse fixture
58
+ │ ├── common/ ← mirrors src/scaldys_template/common/
59
+ │ ├── cli/ ← mirrors src/scaldys_template/cli/
60
+ │ └── core/ ← mirrors src/scaldys_template/core/
61
+ └── integration/ ← full CLI invocations via CliRunner
62
+ ```
63
+
64
+ ## Getting Started
65
+
66
+ ### Prerequisites
67
+
68
+ - Python 3.13 or later
69
+ - Git
70
+
71
+ ### Setup
72
+
73
+ 1. **Get the template:**
74
+
75
+ ```bash
76
+ # Option 1: Download as ZIP
77
+ # Download from https://github.com/scaldys/scaldys-template/archive/refs/heads/main.zip
78
+
79
+ # Option 2: Clone with Git
80
+ git clone https://github.com/scaldys/scaldys-template.git your-project-name
81
+ cd your-project-name
82
+ rm -rf .git
83
+ git init
84
+ ```
85
+
86
+ 2. **Customize the template:**
87
+ - Replace all occurrences of `scaldys_template` / `Scaldys-Template`
88
+ (case-sensitive) with your project name
89
+ - Update file and directory names containing "scaldys_template"
90
+ - Modify package metadata in `pyproject.toml`
91
+
92
+ 3. **Set up your repository:**
93
+ - Create a new repository on GitHub/GitLab
94
+ - Follow their instructions to push your local repository
95
+ - Set up required GitHub environments for trusted publishing
96
+
97
+ ## Development Workflow
98
+
99
+ ### Installation
100
+
101
+ `uv` will automatically install development dependencies when running a command,
102
+ for instance run the tests:
103
+
104
+ ```bash
105
+ uv run pytest ./tests
106
+ ```
107
+
108
+ While the environment is synced automatically, it may also be explicitly synced
109
+ using `uv sync`:
110
+
111
+ ```bash
112
+ uv sync --group dev
113
+ ```
114
+
115
+ For comprehensive documentation on using `uv`, visit the official documentation:
116
+ https://docs.astral.sh/uv/guides/
117
+
118
+ ### Execute the Application
119
+
120
+ The CLI entry point is `scaldys_template.__main__:main`, which runs lifecycle
121
+ setup before handing off to the Typer app. Global options (`--log`, `--verbose`)
122
+ must appear **before** the subcommand name:
123
+
124
+ ```bash
125
+ # Show help
126
+ uv run scaldys-template --help
127
+
128
+ # Show available commands
129
+ uv run scaldys-template --help
130
+
131
+ # Run the export command with debug logging
132
+ uv run scaldys-template --log debug export config.yml
133
+
134
+ # Run the process command with verbose output
135
+ uv run scaldys-template --verbose process --num-tasks 20
136
+
137
+ # Run via python -m (same lifecycle path)
138
+ uv run python -m scaldys_template --log info export config.yml
139
+
140
+ # Manage the persisted log level
141
+ uv run scaldys-template settings log warning
142
+ uv run scaldys-template settings # show current level
143
+ ```
144
+
145
+ You can also run directly from the source directory:
146
+
147
+ ```bash
148
+ # using uv
149
+ uv run scaldys-template.py
150
+
151
+ # using Python directly
152
+ python src/scaldys_template.py
153
+ ```
154
+
155
+ ### Building the Application
156
+
157
+ You can build distribution packages for your application to share or deploy it.
158
+ The build process creates both source distributions (sdist) and binary wheel
159
+ distributions.
160
+
161
+ #### Basic Build
162
+
163
+ To build the application using `uv`:
164
+
165
+ ```bash
166
+ # Build source distribution and wheel
167
+ uv build
168
+ ```
169
+
170
+ This creates distribution files in the `dist/` directory:
171
+
172
+ - `scaldys_template-x.y.z.tar.gz` (source distribution)
173
+ - `scaldys_template-x.y.z-py3-none-any.whl` (wheel distribution)
174
+
175
+ #### Build Options
176
+
177
+ For more control over the build process:
178
+
179
+ ```bash
180
+ # Build only the wheel
181
+ uv build --wheel
182
+
183
+ # Build only the source distribution
184
+ uv build --sdist
185
+
186
+ # Clean previous builds first
187
+ rm -rf dist/ build/
188
+ uv build
189
+
190
+ # Include development extras in the build
191
+ uv build --config-setting="--extras=dev"
192
+ ```
193
+
194
+ #### Verify the Build
195
+
196
+ You can verify your build artifacts before distribution:
197
+
198
+ ```bash
199
+ # List contents of the wheel
200
+ python -m zipfile -l dist/scaldys_template-*.whl
201
+
202
+ # Install from the local wheel to test
203
+ pip install --force-reinstall dist/scaldys_template-*.whl
204
+
205
+ # Run a smoke test after installation
206
+ scaldys-template --version
207
+ ```
208
+
209
+ #### Build for Different Environments
210
+
211
+ For specific target environments:
212
+
213
+ ```bash
214
+ # For a specific Python version
215
+ uv build --python-tag py313
216
+
217
+ # For specific platforms (when using C extensions)
218
+ uv build --config-setting="--plat-name=manylinux2014_x86_64"
219
+ ```
220
+
221
+ #### Automated Builds
222
+
223
+ The project includes GitHub Actions workflows that automatically build packages
224
+ when you create a new release. See the workflow file at
225
+ `.github/workflows/release.yml` for details.
226
+
227
+ ### Windows Packaging (scaldys-project)
228
+
229
+ This template includes a dedicated Windows build system managed by the
230
+ `scaldys-project` CLI command installed by `uv sync`.
231
+
232
+ **Deployment modes** — controlled by `deployment_mode` in `scaldys.toml`:
233
+
234
+ | Mode | What it builds | When to use |
235
+ | ----------------------- | ----------------------------------------------------------------- | ------------------------------------- |
236
+ | `pyinstaller` (default) | PyInstaller exe + Inno Setup installer | Most applications |
237
+ | `pyruntime` | Binary wheel + Inno Setup installer with a managed Python runtime | Apps that coexist with Quarto/Jupyter |
238
+ | `wheel_only` | Binary wheel only, no installer | Apps distributed via pip/uv |
239
+
240
+ **Key features:**
241
+
242
+ - **Cython compilation:** Critical modules are compiled to `.pyd` extensions for
243
+ performance and basic obfuscation.
244
+ - **Standalone executable:** (`pyinstaller` mode) Bundles the application into a
245
+ self-contained directory via PyInstaller.
246
+ - **Managed Python runtime:** (`pyruntime` mode) Deploys a `uv`-managed virtual
247
+ environment alongside the app, supporting online and offline installer
248
+ variants.
249
+ - **Professional installer:** (`pyinstaller` / `pyruntime` modes) Creates a
250
+ Windows setup `.exe` using Inno Setup with desktop shortcuts.
251
+ - **Binary wheel:** (all modes) Built from compiled sources and placed in
252
+ `dist/` for users with their own environment.
253
+
254
+ **Build commands:**
255
+
256
+ ```bash
257
+ # Full build: documentation + Windows distribution
258
+ scaldys-project build all
259
+
260
+ # Documentation only
261
+ scaldys-project build docs
262
+
263
+ # Windows distribution only (mode-dependent)
264
+ scaldys-project build windows
265
+
266
+ # Remove build/, dist/ and artifacts/
267
+ scaldys-project build clean
268
+
269
+ # Verify project compliance
270
+ scaldys-project check
271
+ ```
272
+
273
+ **Prerequisites:**
274
+
275
+ - **Visual Studio Build Tools:** Required for Cython compilation (all modes).
276
+ - **PyInstaller:** Required for `pyinstaller` mode (`uv sync` installs it).
277
+ - **Inno Setup:** Required for `pyinstaller` and `pyruntime` modes (must be
278
+ installed separately).
279
+
280
+ ### Code Quality Verification
281
+
282
+ The project includes automated code quality checks that run when you push
283
+ changes to GitHub. These checks are defined in `.github/workflows/release.yml`
284
+ and include:
285
+
286
+ - Building the project with `uv build`
287
+ - (Optional) Smoke tests for the wheel and source distribution packages
288
+
289
+ You can also run quality checks locally before committing:
290
+
291
+ ```bash
292
+ # Sync dependencies with lock file
293
+ uv sync --group dev
294
+
295
+ # Run the full test suite
296
+ uv run pytest
297
+
298
+ # Run only fast unit tests (no filesystem or CLI I/O)
299
+ uv run pytest -m unit
300
+
301
+ # Run only integration tests
302
+ uv run pytest -m integration
303
+
304
+ # Exclude slow tests (async pipeline tests with real latency)
305
+ uv run pytest -m "not slow"
306
+
307
+ # Run tests with coverage report
308
+ uv run pytest --cov=src/scaldys_template --cov-report=term-missing
309
+
310
+ # Lint and check formatting
311
+ uv run ruff check ./src
312
+
313
+ # Format code
314
+ uv run ruff format ./src
315
+
316
+ # Check types
317
+ uv run pyright ./src
318
+
319
+ # Build documentation
320
+ uv run sphinx-build docs/user_guide/source docs/_build
321
+ ```
322
+
323
+ #### Test markers
324
+
325
+ | Marker | What it covers | Typical run time |
326
+ | ------------- | ----------------------------------------------------------------- | ------------------------- |
327
+ | `unit` | Isolated tests — no real filesystem writes, CLI mocked | < 1 s |
328
+ | `integration` | Full CLI invocations via `CliRunner`, real file I/O in `tmp_path` | ~10 s |
329
+ | `slow` | Tests that run the real async pipeline with simulated latency | included in `integration` |
330
+
331
+ ### Publishing to PyPI
332
+
333
+ This template supports trusted publishing to PyPI using GitHub Actions:
334
+
335
+ 1. Read the Packaging Python Projects guide:
336
+ https://packaging.python.org/en/latest/tutorials/packaging-projects/
337
+ 2. For trusted publishing details, see uv's trusted publishing examples:
338
+ https://github.com/astral-sh/trusted-publishing-examples
339
+ 3. For testing purposes, use TestPyPI: modify the `run` step in
340
+ `.github/workflows/release.yml` to use TestPyPI
341
+ 4. Configure trusted publishing:
342
+ - Log in to PyPI (https://pypi.org/) or TestPyPI (https://test.pypi.org/)
343
+ - Go to "Your projects" → "Publishing" → "Trusted Publisher Management"
344
+ - Click "Add a new pending publisher" and configure:
345
+ - Project name: Your package name
346
+ - Owner: Your GitHub username
347
+ - Repository: Your repository name
348
+ - Workflow name: `release.yml`
349
+ - Environment name: `release` (configure this in your GitHub repository
350
+ settings)
351
+
352
+ ## License
353
+
354
+ This project template is distributed under the MIT license. See the LICENSE file
355
+ for details.
@@ -0,0 +1,82 @@
1
+ [project]
2
+ name = "scaldys-template"
3
+ version = "0.7.0"
4
+ authors = [
5
+ { name="scaldys-template", email="scaldys@scaldys.net" },
6
+ ]
7
+ description = "A skeleton for Python projects by Scaldys."
8
+ readme = "README.rst"
9
+ requires-python = ">=3.13"
10
+ classifiers = [
11
+ "Programming Language :: Python",
12
+ "Operating System :: OS Independent",
13
+ "Development Status :: 3 - Alpha",
14
+ "Intended Audience :: Developers",
15
+ "Topic :: Utilities",
16
+ ]
17
+ license-files = ["LICEN[CS]E*"]
18
+ dependencies = [
19
+ "art>=6.5",
20
+ "platformdirs>=4.9.6",
21
+ "pydantic>=2.0",
22
+ "rich>=13.0",
23
+ "typer>=0.25.0",
24
+ ]
25
+
26
+ [project.scripts]
27
+ scaldys-template = "scaldys_template.__main__:main"
28
+
29
+ [build-system]
30
+ requires = ["setuptools"]
31
+ build-backend = "setuptools.build_meta"
32
+
33
+ [tool.setuptools.packages.find]
34
+ where = ["src"]
35
+ include = ["scaldys_template*"]
36
+
37
+ [tool.setuptools.package-data]
38
+ scaldys_template = ["py.typed"]
39
+
40
+ [dependency-groups]
41
+ dev = [
42
+ "scaldys-project[cython,windows,docs]",
43
+ "pre-commit>=4.5.0",
44
+ "pyright>=1.1.409",
45
+ "pytest>=9.0.3",
46
+ "pytest-asyncio>=0.25.0",
47
+ "pytest-cov>=7.1.0",
48
+ "pytest-mock>=3.14.0",
49
+ "ruff>=0.15.12",
50
+ "sphinx>=9.1.0",
51
+ "sphinx-rtd-theme>=3.1.0",
52
+ ]
53
+
54
+ [tool.pytest.ini_options]
55
+ testpaths = ["tests"]
56
+ asyncio_mode = "auto"
57
+ markers = [
58
+ "unit: Fast, isolated tests with no external I/O",
59
+ "integration: Tests that touch the filesystem or invoke the full CLI",
60
+ "slow: Tests that take significant time (excluded from fast CI runs)",
61
+ ]
62
+
63
+ [tool.uv.sources]
64
+ scaldys-project = { path = "../scaldys-project", editable = true }
65
+
66
+ [tool.ruff]
67
+ line-length = 100
68
+ target-version = "py313"
69
+
70
+ [tool.ruff.lint.per-file-ignores]
71
+ "__init__.py" = ["F403"]
72
+
73
+ [tool.pyright]
74
+ exclude = [".venv"]
75
+ pythonVersion = "3.13"
76
+ venvPath = "."
77
+ venv = ".venv"
78
+
79
+ #[[tool.uv.index]]
80
+ #name = "testpypi"
81
+ #url = "https://test.pypi.org/simple/"
82
+ #publish-url = "https://test.pypi.org/legacy/"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,19 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ __all__ = [
4
+ "APP_NAME",
5
+ "PACKAGE_NAME",
6
+ "ORGANIZATION_NAME",
7
+ "VERSION",
8
+ ]
9
+
10
+ from importlib.metadata import version, PackageNotFoundError
11
+
12
+ APP_NAME = "Scaldys-Template"
13
+ PACKAGE_NAME = "scaldys_template"
14
+ ORGANIZATION_NAME = "Scaldys"
15
+
16
+ try:
17
+ VERSION = version(PACKAGE_NAME)
18
+ except PackageNotFoundError:
19
+ VERSION = "0.0.0"
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from scaldys_template.cli import *
4
+ from scaldys_template.common import *