ptr727-projecttemplate-library 0.0.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.
@@ -0,0 +1,20 @@
1
+ [Dd]ebug/
2
+ [Rr]elease/
3
+ [Bb]in/
4
+ [Oo]bj/
5
+
6
+ .idea
7
+ .vs
8
+ .artifacts
9
+ .DS_Store
10
+ *.user
11
+ .claude
12
+
13
+ __pycache__/
14
+ *.py[cod]
15
+ *.egg-info/
16
+ .venv/
17
+ dist/
18
+ .pytest_cache/
19
+ .ruff_cache/
20
+ .pyright/
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.4
2
+ Name: ptr727-projecttemplate-library
3
+ Version: 0.0.0
4
+ Summary: Python PyPI template library — companion to the .NET NuGetLibrary in this template repo.
5
+ Project-URL: Homepage, https://github.com/ptr727/ProjectTemplate
6
+ Project-URL: Source, https://github.com/ptr727/ProjectTemplate
7
+ Project-URL: Issues, https://github.com/ptr727/ProjectTemplate/issues
8
+ Author: Pieter Viljoen
9
+ License: MIT
10
+ Keywords: library,pypi,template
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Requires-Python: >=3.14
20
+ Description-Content-Type: text/markdown
21
+
22
+ # PyPiLibrary
23
+
24
+ Python PyPI template — companion to the .NET `NuGetLibrary` in this repo. Published to PyPI as [`ptr727-projecttemplate-library`](https://pypi.org/project/ptr727-projecttemplate-library/).
25
+
26
+ ## Stack
27
+
28
+ - **Build backend** — [`hatchling`](https://hatch.pypa.io/latest/) via `pyproject.toml`
29
+ - **Env / deps / publish** — [`uv`](https://docs.astral.sh/uv/) (Astral)
30
+ - **Lint + format** — [`ruff`](https://docs.astral.sh/ruff/)
31
+ - **Type checker** — [`pyright`](https://microsoft.github.io/pyright/)
32
+ - **Tests** — [`pytest`](https://docs.pytest.org/)
33
+ - **Publish** — [PyPI Trusted Publishing](https://docs.pypi.org/trusted-publishers/) via `pypa/gh-action-pypi-publish` (no API token in repo secrets)
34
+
35
+ ## Layout
36
+
37
+ ```text
38
+ PyPiLibrary/
39
+ pyproject.toml
40
+ README.md
41
+ src/
42
+ ptr727_projecttemplate_library/
43
+ __init__.py
44
+ _version.py
45
+ example.py
46
+ tests/
47
+ __init__.py
48
+ test_example.py
49
+ ```
50
+
51
+ ## Local Development
52
+
53
+ The repo's [devcontainer](../docs/devcontainer.md) installs `uv` automatically and runs `uv sync` for this project on first open. To work outside the devcontainer:
54
+
55
+ ```shell
56
+ # from the repo root
57
+ cd PyPiLibrary
58
+ uv sync # creates .venv, installs deps + dev group
59
+ uv run ruff check # lint
60
+ uv run ruff format --check # formatting check
61
+ uv run pyright # type check
62
+ uv run pytest # tests
63
+ uv build # wheel + sdist into ./dist
64
+ ```
65
+
66
+ ## Publishing
67
+
68
+ Releases are produced by `.github/workflows/build-pypilibrary-task.yml` (called from `build-release-task.yml` to build, lint, type-check, test, and upload the wheel + sdist as a workflow-run artifact). Publishing is a separate top-level `publish-pypi` job in `publish-release.yml` that downloads the artifact by name and runs [Trusted Publishing](https://docs.pypi.org/trusted-publishers/) — no `PYPI_API_TOKEN` secret is involved. The publish job has `id-token: write` only at that single job level, so the test-pull-request flow (which calls the same build task during PR validation) doesn't need to propagate that permission through the reusable workflow chain.
69
+
70
+ First-time setup (one-time, on PyPI):
71
+
72
+ 1. PyPI → **Account settings** → **Publishing** → **Add a new pending publisher**.
73
+ 2. Project name: `ptr727-projecttemplate-library`. Owner: `ptr727`. Repo: `ProjectTemplate`. Workflow: `publish-release.yml`. Environment: `pypi`.
74
+ 3. GitHub repo → **Settings** → **Environments** → create `pypi` environment (optionally with required reviewers).
75
+ 4. The first successful release converts the pending publisher to a real publisher.
76
+
77
+ ## Template Adoption
78
+
79
+ When deriving a new project from this template:
80
+
81
+ - Replace the package name `ptr727-projecttemplate-library` (in `pyproject.toml`, this README, and CI) with your name.
82
+ - Rename `src/ptr727_projecttemplate_library/` to your import name.
83
+ - Re-register the trusted publisher on PyPI under the new project name.
84
+ - **Wire up a versioning scheme before the first publish.** `_version.py` ships with `__version__ = "0.0.0"` as a placeholder. The publish workflow uses `skip-existing: true` so the workflow won't fail on duplicate uploads — but **no new versions will land on PyPI** until you replace `0.0.0` with something that increments. Common options:
85
+ - [`hatch-vcs`](https://github.com/ofek/hatch-vcs) — derive the version from git tags. Add it to `[build-system].requires` and switch `[tool.hatch.version]` to `source = "vcs"`. Pairs well with tag-driven releases.
86
+ - **Read from `version.json`** — the .NET side uses Nerdbank.GitVersioning which reads from `version.json`. A small custom Hatchling plugin or a CI step can pull the version into `_version.py` so .NET and Python ship with matching versions.
87
+ - **Manual bumps** — edit `_version.py` in each release PR. Simplest, but easy to forget.
88
+
89
+ If you don't want a Python project at all, delete the `PyPiLibrary/` folder, the `build-pypilibrary-task.yml` workflow, the `build-pypilibrary` job in `build-release-task.yml`, the `publish-pypi` job in `publish-release.yml`, and the `uv` block in `.github/dependabot.yml`.
@@ -0,0 +1,68 @@
1
+ # PyPiLibrary
2
+
3
+ Python PyPI template — companion to the .NET `NuGetLibrary` in this repo. Published to PyPI as [`ptr727-projecttemplate-library`](https://pypi.org/project/ptr727-projecttemplate-library/).
4
+
5
+ ## Stack
6
+
7
+ - **Build backend** — [`hatchling`](https://hatch.pypa.io/latest/) via `pyproject.toml`
8
+ - **Env / deps / publish** — [`uv`](https://docs.astral.sh/uv/) (Astral)
9
+ - **Lint + format** — [`ruff`](https://docs.astral.sh/ruff/)
10
+ - **Type checker** — [`pyright`](https://microsoft.github.io/pyright/)
11
+ - **Tests** — [`pytest`](https://docs.pytest.org/)
12
+ - **Publish** — [PyPI Trusted Publishing](https://docs.pypi.org/trusted-publishers/) via `pypa/gh-action-pypi-publish` (no API token in repo secrets)
13
+
14
+ ## Layout
15
+
16
+ ```text
17
+ PyPiLibrary/
18
+ pyproject.toml
19
+ README.md
20
+ src/
21
+ ptr727_projecttemplate_library/
22
+ __init__.py
23
+ _version.py
24
+ example.py
25
+ tests/
26
+ __init__.py
27
+ test_example.py
28
+ ```
29
+
30
+ ## Local Development
31
+
32
+ The repo's [devcontainer](../docs/devcontainer.md) installs `uv` automatically and runs `uv sync` for this project on first open. To work outside the devcontainer:
33
+
34
+ ```shell
35
+ # from the repo root
36
+ cd PyPiLibrary
37
+ uv sync # creates .venv, installs deps + dev group
38
+ uv run ruff check # lint
39
+ uv run ruff format --check # formatting check
40
+ uv run pyright # type check
41
+ uv run pytest # tests
42
+ uv build # wheel + sdist into ./dist
43
+ ```
44
+
45
+ ## Publishing
46
+
47
+ Releases are produced by `.github/workflows/build-pypilibrary-task.yml` (called from `build-release-task.yml` to build, lint, type-check, test, and upload the wheel + sdist as a workflow-run artifact). Publishing is a separate top-level `publish-pypi` job in `publish-release.yml` that downloads the artifact by name and runs [Trusted Publishing](https://docs.pypi.org/trusted-publishers/) — no `PYPI_API_TOKEN` secret is involved. The publish job has `id-token: write` only at that single job level, so the test-pull-request flow (which calls the same build task during PR validation) doesn't need to propagate that permission through the reusable workflow chain.
48
+
49
+ First-time setup (one-time, on PyPI):
50
+
51
+ 1. PyPI → **Account settings** → **Publishing** → **Add a new pending publisher**.
52
+ 2. Project name: `ptr727-projecttemplate-library`. Owner: `ptr727`. Repo: `ProjectTemplate`. Workflow: `publish-release.yml`. Environment: `pypi`.
53
+ 3. GitHub repo → **Settings** → **Environments** → create `pypi` environment (optionally with required reviewers).
54
+ 4. The first successful release converts the pending publisher to a real publisher.
55
+
56
+ ## Template Adoption
57
+
58
+ When deriving a new project from this template:
59
+
60
+ - Replace the package name `ptr727-projecttemplate-library` (in `pyproject.toml`, this README, and CI) with your name.
61
+ - Rename `src/ptr727_projecttemplate_library/` to your import name.
62
+ - Re-register the trusted publisher on PyPI under the new project name.
63
+ - **Wire up a versioning scheme before the first publish.** `_version.py` ships with `__version__ = "0.0.0"` as a placeholder. The publish workflow uses `skip-existing: true` so the workflow won't fail on duplicate uploads — but **no new versions will land on PyPI** until you replace `0.0.0` with something that increments. Common options:
64
+ - [`hatch-vcs`](https://github.com/ofek/hatch-vcs) — derive the version from git tags. Add it to `[build-system].requires` and switch `[tool.hatch.version]` to `source = "vcs"`. Pairs well with tag-driven releases.
65
+ - **Read from `version.json`** — the .NET side uses Nerdbank.GitVersioning which reads from `version.json`. A small custom Hatchling plugin or a CI step can pull the version into `_version.py` so .NET and Python ship with matching versions.
66
+ - **Manual bumps** — edit `_version.py` in each release PR. Simplest, but easy to forget.
67
+
68
+ If you don't want a Python project at all, delete the `PyPiLibrary/` folder, the `build-pypilibrary-task.yml` workflow, the `build-pypilibrary` job in `build-release-task.yml`, the `publish-pypi` job in `publish-release.yml`, and the `uv` block in `.github/dependabot.yml`.
@@ -0,0 +1,82 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "ptr727-projecttemplate-library"
7
+ description = "Python PyPI template library — companion to the .NET NuGetLibrary in this template repo."
8
+ readme = "README.md"
9
+ license = { text = "MIT" }
10
+ authors = [{ name = "Pieter Viljoen" }]
11
+ requires-python = ">=3.14"
12
+ keywords = ["template", "pypi", "library"]
13
+ classifiers = [
14
+ "Development Status :: 4 - Beta",
15
+ "Intended Audience :: Developers",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ "Programming Language :: Python",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.14",
21
+ "Topic :: Software Development :: Libraries :: Python Modules",
22
+ ]
23
+ dynamic = ["version"]
24
+ dependencies = []
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/ptr727/ProjectTemplate"
28
+ Source = "https://github.com/ptr727/ProjectTemplate"
29
+ Issues = "https://github.com/ptr727/ProjectTemplate/issues"
30
+
31
+ [dependency-groups]
32
+ dev = [
33
+ "pytest>=8.3",
34
+ "ruff>=0.9",
35
+ "pyright>=1.1.390",
36
+ ]
37
+
38
+ [tool.hatch.version]
39
+ path = "src/ptr727_projecttemplate_library/_version.py"
40
+
41
+ [tool.hatch.build.targets.wheel]
42
+ packages = ["src/ptr727_projecttemplate_library"]
43
+
44
+ [tool.hatch.build.targets.sdist]
45
+ include = ["src", "tests", "README.md", "pyproject.toml"]
46
+
47
+ [tool.ruff]
48
+ line-length = 120
49
+ target-version = "py314"
50
+
51
+ [tool.ruff.lint]
52
+ select = [
53
+ "E", # pycodestyle errors
54
+ "W", # pycodestyle warnings
55
+ "F", # pyflakes
56
+ "I", # isort
57
+ "B", # flake8-bugbear
58
+ "UP", # pyupgrade
59
+ "N", # pep8-naming
60
+ "SIM", # flake8-simplify
61
+ "RUF", # ruff-specific
62
+ ]
63
+
64
+ [tool.ruff.format]
65
+ docstring-code-format = true
66
+
67
+ [tool.pyright]
68
+ include = ["src", "tests"]
69
+ pythonVersion = "3.14"
70
+ typeCheckingMode = "standard"
71
+ # Per-path strictness: `strict` accepts directory paths and applies
72
+ # strict-mode type checking to everything under them — equivalent to
73
+ # placing `# pyright: strict` at the top of every file in those dirs.
74
+ # Public library surface (`src/`) needs tight types; tests inherit the
75
+ # standard mode set above (fixtures, mocks, and parametrize args are
76
+ # commonly looser).
77
+ strict = ["src"]
78
+
79
+ [tool.pytest.ini_options]
80
+ minversion = "8.0"
81
+ testpaths = ["tests"]
82
+ addopts = ["-ra", "--strict-markers", "--strict-config"]
@@ -0,0 +1,6 @@
1
+ """Python PyPI template library."""
2
+
3
+ from ptr727_projecttemplate_library._version import __version__
4
+ from ptr727_projecttemplate_library.example import greet
5
+
6
+ __all__ = ["__version__", "greet"]
@@ -0,0 +1,8 @@
1
+ """Single-source-of-truth for the package version.
2
+
3
+ Hatchling reads ``__version__`` from this module via ``[tool.hatch.version]``.
4
+ For tag-driven versioning, swap this for ``hatch-vcs`` and configure the build
5
+ backend to derive the version from git tags.
6
+ """
7
+
8
+ __version__ = "0.0.0"
@@ -0,0 +1,6 @@
1
+ """Trivial example module — replace with your library code."""
2
+
3
+
4
+ def greet(name: str) -> str:
5
+ """Return a friendly greeting for ``name``."""
6
+ return f"Hello, {name}!"
File without changes
@@ -0,0 +1,16 @@
1
+ """Tests for ``ptr727_projecttemplate_library.example``."""
2
+
3
+ from ptr727_projecttemplate_library import __version__, greet
4
+
5
+
6
+ def test_version_is_string() -> None:
7
+ assert isinstance(__version__, str)
8
+ assert len(__version__) > 0
9
+
10
+
11
+ def test_greet_uses_name() -> None:
12
+ assert greet("world") == "Hello, world!"
13
+
14
+
15
+ def test_greet_with_empty_name() -> None:
16
+ assert greet("") == "Hello, !"