Skip to content

Latest commit

 

History

History
278 lines (203 loc) · 8.93 KB

dev-notes.md

File metadata and controls

278 lines (203 loc) · 8.93 KB

Install uv

This repository uses uv for Python interpreter management, dependency locking, command execution, and package building. CI and the release workflow use uv 0.13.10. Install uv with:

curl -LsSf https://astral.sh/uv/install.sh | sh

Install Python

The repository defaults to CPython 3.15, the newest stable series, in .python-version. The SDK supports CPython 3.11 and later, and CI tests CPython 3.11 through 3.15. Install the project interpreter with uv:

uv python install

If you already have an older 3.15 patch installed, upgrade it and check the project interpreter:

uv python upgrade 3.15
uv run --locked python --version

When a new stable CPython series ships, update the local default, CI test matrix, single-interpreter jobs, and these instructions together.

Synchronize dependencies

uv owns the project virtual environment (.venv/); manual activation is optional and not part of the canonical workflow. Install the locked dependencies with:

uv sync --locked

Locked synchronization installs exactly the versions recorded in uv.lock. If project metadata and the lockfile disagree, it fails instead of silently resolving new versions.

Run unit tests

uv run --locked python -m unittest discover . --pattern '*test.py'

Run unit tests with coverage report

CI runs this check on CPython 3.11 through 3.15. Add --python 3.11 after uv run --locked in both commands to exercise the oldest supported version locally.

uv run --locked coverage run -m unittest discover . --pattern '*test.py'

uv run --locked coverage report

Generate API documentation

Generate and check the API reference in a fresh directory.

docs_dir=$(mktemp -d) &&
uv run --locked pdoc --template-directory .github/pdoc --output "$docs_dir" ./ringcentral &&
test -s "$docs_dir/ringcentral.html" &&
test -s "$docs_dir/ringcentral/test/testcase.html" &&
grep -q 'id="WebSocketClient.on"' "$docs_dir/ringcentral/websocket/web_socket_client.html" &&
test ! -e "$docs_dir/agents"

Open $docs_dir/ringcentral.html to preview the result. The Pages workflow runs these checks and publishes the generated directory. Contributor instructions are maintained under docs/agents in the repository.

Build distributions

Build the source distribution, then build a wheel from that archive with uv-specific source overrides disabled:

uv build --no-sources

Recreate the environment

To recreate the environment from scratch:

rm -rf .venv
uv sync --locked

Update dependencies

Dependency updates are intentional, reviewable changes — ordinary setup and commands never modify the lockfile.

  • After a declared constraint in pyproject.toml changes, refresh the lockfile:

    uv lock
    
  • To upgrade all eligible packages to their latest allowed versions:

    uv lock --upgrade
    
  • To upgrade one named package:

    uv lock --upgrade-package <package>
    

Then synchronize and commit the updated uv.lock:

uv sync --locked

Note

Unit tests and the local WebSocket transport check require no RingCentral credentials. The transport check opens a real connection to a loopback server through the SDK. When changing the supported websockets range, run the WebSocket tests for each proposed major on the supported stable CPython series. For example, to check websockets 16.1.1 on Python 3.11:

uv run --locked --python 3.11 --with 'websockets==16.1.1' python -m unittest discover -s ringcentral/websocket -t . -p '*test.py'

Run the OAuth smoke tests

Each test gets an access token, calls GET /restapi/v2/accounts/~, and prints the HTTP status and account JSON. The test fails if the response has no account ID. Use an app configured for the grant you are testing and authorized to read account details.

Client credentials

Copy .env.sample to .env and set RINGCENTRAL_SERVER_URL, RINGCENTRAL_CLIENT_ID, and RINGCENTRAL_CLIENT_SECRET for a client credentials app with access to GET /restapi/v2/accounts/~. You can also export the variables in your shell.

uv run --locked python -m api_test.client_credentials_smoke

JWT and authorization code

These tests use the same environment variables as the JavaScript SDK smoke tests. Set RC_SERVER_URL, RC_CLIENT_ID, and RC_CLIENT_SECRET in .env or export them in your shell. For the JWT test, also set RC_JWT to the JWT for your JWT-enabled app.

uv run --locked python -m api_test.jwt_smoke

For the authorization-code test, use the authorization-code app's client ID and secret. Register http://localhost:5000/oauth2callback as a redirect URI for the app, or set RC_REDIRECT_URI to another registered HTTP loopback URL with an explicit port. Open the URL printed by the command and approve the request in your browser.

uv run --locked python -m api_test.auth_code_smoke

Run demos

Copy .env.sample to .env.

Edit .env to specify credentials. Live demos read credentials from this local environment file created from the existing sample.

Run a demo file like this:

uv run --locked python ringcentral/demos/demo_fax.py

The WebSocket subscription demo (demo_subscription.py) requires an application with the "WebSocket Subscriptions" permission.

Release

Verify the release candidate

After the integrated checks pass, use a clean checkout of the tested commit on master. Confirm that the README and release notes describe the changes in that commit. Use uv 0.13.10 and CPython 3.15, as in the tag workflow. Set the intended version below, run the release tests, build both artifacts into a fresh directory, and check both artifacts with strict Twine validation and metadata inspection.

release_version=1.0.0
release_commit=$(git rev-parse HEAD) &&
release_dist=$(mktemp -d) &&
uv sync --locked --python 3.15 &&
uv run --locked coverage run -m unittest discover . --pattern '*test.py' &&
uv run --locked coverage report &&
uv build --no-sources --out-dir "$release_dist" &&
uv run --locked twine check --strict "$release_dist"/* &&
uv run --locked python -E - "$release_version" "$release_dist" <<'PY'
import sys
from email.parser import BytesParser
from pathlib import Path
from tarfile import open as open_tar
from zipfile import ZipFile

from packaging.requirements import Requirement

version, directory = sys.argv[1:]
dist = Path(directory)
stem = f"ringcentral-{version}"
wheel_path, = dist.glob(f"{stem}-*.whl")
sdist_path = dist / f"{stem}.tar.gz"
required_http_dependencies = {
    Requirement("certifi>=2026.10.19"),
    Requirement("requests>=2.33.0,<3"),
    Requirement("urllib3>=2.8.0,<3"),
}

with ZipFile(wheel_path) as wheel, open_tar(sdist_path, "r:gz") as sdist:
    wheel_metadata = wheel.read(f"{stem}.dist-info/METADATA")
    with sdist.extractfile(f"{stem}/PKG-INFO") as source_metadata:
        for path, contents in ((wheel_path, wheel_metadata), (sdist_path, source_metadata.read())):
            metadata = BytesParser().parsebytes(contents)
            assert metadata["Name"] == "ringcentral", path
            assert metadata["Version"] == version, (path, metadata["Version"])
            assert metadata["Requires-Python"] == ">=3.11", path
            dependencies = set(map(Requirement, metadata.get_all("Requires-Dist", [])))
            assert required_http_dependencies <= dependencies, (path, dependencies)
            print(f"Verified {path.name} ({metadata['Version']})")
PY

Publish and verify

After the maintainer authorizes publication, create the tag on the verified commit. Before pushing it, confirm that it resolves to the commit you built. If you start a new shell, restore the intended version and the original commit SHA as release_version and release_commit. Restore release_dist to the directory containing the verified artifacts before running the package checks below.

tag_commit=$(git rev-parse --verify "refs/tags/${release_version:?}^{commit}") &&
test "$tag_commit" = "${release_commit:?}"

Pushing the verified tag triggers the GitHub Actions release workflow. It runs the tests, rebuilds both distributions with uv build --no-sources, and uploads them using Twine. Once it succeeds, confirm that the wheel and source distribution are both on the PyPI release page. Check a fresh install from PyPI outside the repository.

(
  cd "${release_dist:?}" &&
  uv run --no-project --isolated --python 3.15 --with "ringcentral==${release_version:?}" \
    python -I -c 'from importlib.metadata import version; import ringcentral; print(version("ringcentral"))'
)

For an authorized manual upload, configure Twine in ~/.pypirc:

[distutils]
index-servers = pypi

[pypi]
repository = https://upload.pypi.org/legacy/
username = __token__
password = pypi-<your-token>

Upload the verified artifacts through Twine:

uv run --locked twine upload \
  "${release_dist:?}"/ringcentral-"${release_version:?}"-*.whl \
  "$release_dist/ringcentral-$release_version.tar.gz"