Skip to content

Commit eeeec9e

Browse files
author
aman
committed
Merge branch 'copilot/create-boilerplate-code'
2 parents e6ce78f + d72f9d6 commit eeeec9e

11 files changed

Lines changed: 372 additions & 1 deletion

File tree

.devcontainer/devcontainer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "bodyloop-sdk",
3+
"image": "mcr.microsoft.com/devcontainers/python:3.12",
4+
"features": {
5+
"ghcr.io/astral-sh/uv/devcontainer-feature/uv:latest": {}
6+
},
7+
"postCreateCommand": "uv sync",
8+
"customizations": {
9+
"vscode": {
10+
"extensions": [
11+
"ms-python.python",
12+
"ms-python.vscode-pylance",
13+
"GitHub.copilot",
14+
"GitHub.copilot-chat"
15+
],
16+
"settings": {
17+
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
18+
"editor.formatOnSave": true,
19+
"[python]": {
20+
"editor.defaultFormatter": "ms-python.python"
21+
}
22+
}
23+
}
24+
}
25+
}

.github/copilot-instructions.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# GitHub Copilot Instructions
2+
3+
## Project Overview
4+
5+
`bodyloop-sdk-*` is the pattern for the repositories of the SDKs
6+
for the BodyLoop API for certain languages.
7+
8+
This repository, `bodyloop-sdk-python` implements the one for Python.
9+
10+
## Spec-Driven Development Workflow
11+
12+
REVIEW: Defect, major: Does not apply SDD in a correct way. Does not describe the workflow we intend.
13+
14+
1. **Spec** – Write a detailed docstring describing the function/class contract
15+
(inputs, outputs, raised exceptions, edge cases) before any implementation.
16+
2. **Implement** – Ask Copilot to generate the implementation that satisfies the spec.
17+
3. **Test** – Ask Copilot to generate `pytest` tests covering the spec.
18+
4. **Review** – Verify Copilot output matches the spec; adjust as needed.
19+
20+
## Code Style
21+
22+
- Python ≥ 3.11; use type hints on all public APIs.
23+
- Keep the `src/bodyloop_sdk/` layout; add new modules inside that package.
24+
- Use `snake_case` for functions/variables, `PascalCase` for classes.
25+
- Keep public APIs small and composable; prefer pure functions.
26+
27+
## Testing
28+
29+
- All tests live in `tests/`; mirror the source module structure.
30+
- Every public function must have at least one happy-path test and one
31+
error/edge-case test.
32+
- Run tests with: `uv run pytest`
33+
34+
## Dependency Management
35+
36+
- Manage dependencies with `uv`; edit `pyproject.toml` directly.
37+
- Add runtime deps: `uv add <package>`
38+
- Add dev deps: `uv add --dev <package>`
39+
40+
## Release Process
41+
42+
- Bump `__version__` in `src/bodyloop_sdk/__init__.py`.
43+
- Create a GitHub release tagged `vX.Y.Z`.
44+
- The `release.yml` workflow will build and publish to PyPI automatically.

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
name: Test (Python ${{ matrix.python-version }})
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: ["3.11", "3.12", "3.13"]
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Set up uv
25+
uses: astral-sh/setup-uv@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- name: Install dependencies
30+
run: uv sync
31+
32+
- name: Run tests
33+
run: uv run pytest

.github/workflows/release.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
id-token: write # required for PyPI trusted publishing
9+
10+
jobs:
11+
build:
12+
name: Build distribution
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Set up uv
19+
uses: astral-sh/setup-uv@v5
20+
21+
- name: Build package
22+
run: uv build
23+
24+
- name: Upload distribution artifacts
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: dist
28+
path: dist/
29+
30+
publish:
31+
name: Publish to PyPI
32+
runs-on: ubuntu-latest
33+
needs: build
34+
environment:
35+
name: pypi
36+
url: https://pypi.org/project/bodyloop-sdk/
37+
38+
steps:
39+
- name: Download distribution artifacts
40+
uses: actions/download-artifact@v4
41+
with:
42+
name: dist
43+
path: dist/
44+
45+
- name: Publish to PyPI
46+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*.pyo
5+
*.pyd
6+
.Python
7+
*.egg
8+
*.egg-info/
9+
dist/
10+
build/
11+
eggs/
12+
parts/
13+
var/
14+
sdist/
15+
develop-eggs/
16+
.installed.cfg
17+
lib/
18+
lib64/
19+
20+
# Virtual environments
21+
.venv/
22+
venv/
23+
ENV/
24+
25+
# uv
26+
.uv/
27+
28+
# pytest
29+
.pytest_cache/
30+
.coverage
31+
htmlcov/
32+
33+
# Editors
34+
.vscode/settings.json
35+
.idea/
36+
*.swp
37+
*.swo
38+
39+
# OS
40+
.DS_Store
41+
Thumbs.db

README.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,44 @@
1-
# bodyloop-pypi
1+
# BodyLoop SDK for Python
2+
23
Python SDK for the BodyLoop API for seamless ecosystem integration
4+
5+
The URL of the source repository <https://github.com/bodyloop/bodyloop-sdk-python> has suffix `python` to enable adding SDKs for other lanuages such as JavaScript/TypeScript, C/C++, Rust, etc.
6+
7+
The distribution name (install) of the Python Package name is `bodyloop-sdk` and is available in the global Package Index PyPi at <https://pypi.org/project/bodyloop-sdk>. It omits the suffix since PyPi already tells us that we are in the Python ecosystem.
8+
9+
Examples how to get the package are:
10+
11+
```bash
12+
pip install bodyloop-sdk
13+
14+
poetry add bodyloop-sdk
15+
16+
uv add bodyloop-sdk
17+
18+
pipx install bodyloop-sdk
19+
20+
uv tool install bodyloop-sdk
21+
```
22+
23+
The top-level import of the package is the Python module `bodyloop`.
24+
25+
Usage:
26+
27+
```python
28+
import bodyloop
29+
from bodyloop import Viatar, Proband
30+
from bodyloop import System as BodyLoopSystem
31+
```
32+
33+
## Contribute
34+
35+
Local workflow
36+
37+
```bash
38+
git clone git@github.com:BodyLoop/bodyloop-sdk-python.git
39+
cd bodyloop-sdk-python
40+
41+
uv sync
42+
uv run pytest
43+
uv build
44+
```

pyproject.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[project]
2+
name = "bodyloop-sdk"
3+
version = "2026.03.05.1"
4+
description = "Python SDK for the BodyLoop API for seamless ecosystem integration"
5+
readme = "README.md"
6+
license = { file = "LICENSE" }
7+
requires-python = ">=3.11"
8+
dependencies = []
9+
10+
[project.urls]
11+
Homepage = "https://github.com/BodyLoop/bodyloop-pypi"
12+
Repository = "https://github.com/BodyLoop/bodyloop-pypi"
13+
Issues = "https://github.com/BodyLoop/bodyloop-pypi/issues"
14+
15+
[build-system]
16+
requires = ["hatchling"]
17+
build-backend = "hatchling.build"
18+
19+
[tool.hatch.build.targets.wheel]
20+
packages = ["src/bodyloop_sdk"]
21+
22+
[tool.pytest.ini_options]
23+
testpaths = ["tests"]
24+
25+
[dependency-groups]
26+
dev = [
27+
"pytest>=8.0.0",
28+
]

src/bodyloop_sdk/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""BodyLoop SDK – Python client for the BodyLoop API."""
2+
3+
from __future__ import annotations
4+
5+
try:
6+
# Python 3.8+
7+
from importlib.metadata import version as _pkg_version
8+
except ImportError: # pragma: no cover (for very old Pythons)
9+
from importlib_metadata import version as _pkg_version # type: ignore
10+
11+
12+
def _read_version() -> str:
13+
# This must match the distribution name in pyproject.toml ([project].name)
14+
return _pkg_version("bodyloop-sdk")
15+
16+
17+
__version__ = _read_version()

tests/__init__.py

Whitespace-only changes.

tests/test_bodyloop_sdk.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""Tests for the bodyloop_sdk package."""
2+
3+
import bodyloop_sdk
4+
5+
6+
def test_version_exists():
7+
"""The package exposes a __version__ string."""
8+
assert hasattr(bodyloop_sdk, "__version__")
9+
assert isinstance(bodyloop_sdk.__version__, str)
10+
11+
12+
def test_version_format():
13+
"""__version__ follows semver major.minor.patch format."""
14+
parts = bodyloop_sdk.__version__.split(".")
15+
assert len(parts) == 4
16+
assert all(part.isdigit() for part in parts)

0 commit comments

Comments
 (0)