-
Notifications
You must be signed in to change notification settings - Fork 0
fix(packaging): Apache-2.0 metadata, a migration note, and CI that actually runs the tests #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| name: python tests | ||
|
|
||
| # Runs the pytest suite on every pull request and every push to main. | ||
| # | ||
| # WHY THIS EXISTS: before this workflow, NOTHING in CI ran pytest. The repo had | ||
| # six test files (SDK exports, parity APIs, contract coverage, README quickstart, | ||
| # x402, packaging) and 52 tests, and a pull request could delete or break every | ||
| # one of them and still show all-green — `python-lint` runs ruff only, | ||
| # `foundation-gate` runs a secret scan and a file-size gate, `smoke-install` | ||
| # builds and imports the wheel, and `release` builds a distribution. None of them | ||
| # execute a test. That gap is what let the stdlib-shadow defect reach PyPI as | ||
| # wave-sdk 2.0.0. | ||
| # | ||
| # The matrix mirrors smoke-install.yml (the floor and the two current versions in | ||
| # `requires-python = ">=3.9"`), so a version that can install the wheel is also a | ||
| # version whose behaviour is asserted. | ||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: python-tests-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| pytest: | ||
| name: pytest (py${{ matrix.python-version }}) | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python-version: ["3.9", "3.12", "3.13"] | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install the SDK with every extra it tests | ||
| # `realtime` and `x402` are optional extras with their own test modules, | ||
| # so the suite needs them present or those tests silently do less work. | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -e ".[dev,realtime,x402]" | ||
|
|
||
| - name: pytest | ||
| run: python -m pytest -q |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| # Migrating to `wave-sdk` 2.1.0 | ||
|
|
||
| Two things changed between the published `2.0.0` releases and `2.1.0`: the | ||
| **distribution you install** and the **package you import**. Both changes are | ||
| mechanical, and the second one is not optional — the old import never worked | ||
| outside the SDK's own repo. | ||
|
|
||
| | | Old (`2.0.0`, published) | New (`2.1.0`) | | ||
| | --- | --- | --- | | ||
| | Install name(s) | `wave-av-sdk`, `wave-sdk` | `wave-sdk` | | ||
| | Import name | `wave` (broken — see below) | `wave_sdk` | | ||
| | Client class | `Wave` | `Wave` (unchanged) | | ||
| | Method surface | 35 `*API` classes | 42 `*API` classes | | ||
|
|
||
| ## 1. Install `wave-sdk` | ||
|
|
||
| ```bash | ||
| pip uninstall -y wave-av-sdk wave-sdk | ||
| pip install "wave-sdk>=2.1.0" | ||
| ``` | ||
|
|
||
| `wave-av-sdk` and `wave-sdk` were both published at `2.0.0` and contain the same | ||
| code. `wave-sdk` is the one name that continues; `wave-av-sdk` is not being | ||
| republished. Uninstall **both** before installing: they each drop a top-level | ||
| `wave/` directory into `site-packages`, and leaving one behind leaves that | ||
| directory (and its stale `2.0.0` modules) on disk next to the new `wave_sdk`. | ||
|
|
||
| ## 2. Change `import wave` to `import wave_sdk` | ||
|
|
||
| ```diff | ||
| -from wave import Wave | ||
| +from wave_sdk import Wave | ||
|
|
||
| -from wave import WaveError, RateLimitError | ||
| +from wave_sdk import WaveError, RateLimitError | ||
|
|
||
| -import wave | ||
| -client = wave.Wave(api_key=..., organization_id=...) | ||
| +import wave_sdk | ||
| +client = wave_sdk.Wave(api_key=..., organization_id=...) | ||
| ``` | ||
|
|
||
| Nothing below the top-level name changed. Every class, method, argument and | ||
| return type keeps its name, so a find-and-replace of the import line is the | ||
| whole migration: | ||
|
|
||
| ```bash | ||
| # from the root of your project | ||
| grep -rl --include='*.py' -E '^\s*(from|import)\s+wave(\W|$)' . \ | ||
| | xargs sed -i.bak -E 's/^(\s*)(from|import)(\s+)wave(\W|$)/\1\2\3wave_sdk\4/' | ||
| ``` | ||
|
|
||
| ## Why the rename was required | ||
|
|
||
| CPython ships a standard-library module called `wave` (`Lib/wave.py`, the WAV | ||
| audio reader/writer) in every install, on every supported version. The | ||
| standard-library directory sits **ahead of `site-packages`** on `sys.path`. | ||
|
|
||
| So for anyone who ran `pip install wave-sdk==2.0.0`, `import wave` resolved to | ||
| the standard library, not to the SDK. The SDK's own files were on disk, in | ||
| `site-packages/wave/`, and were unreachable: | ||
|
|
||
| ```console | ||
| $ python -m venv v && ./v/bin/pip install wave-sdk==2.0.0 | ||
| $ ./v/bin/python -c "import wave; print(wave.__file__)" | ||
| /…/lib/python3.12/wave.py # the standard library, not the SDK | ||
| $ ./v/bin/python -c "from wave import Wave" | ||
| ImportError: cannot import name 'Wave' from 'wave' | ||
| ``` | ||
|
|
||
| The defect was invisible during development because the repo checkout is the | ||
| first entry on `sys.path`; inside the checkout, the local `wave/` directory won | ||
| `import wave` and the test suite passed. `wave_sdk` collides with nothing, and | ||
| `import wave` now correctly keeps meaning the standard library: | ||
|
|
||
| ```console | ||
| $ ./v/bin/python -c "import wave_sdk; print(wave_sdk.__version__)" | ||
| 2.1.0 | ||
| $ ./v/bin/python -c "import wave; print(wave.__file__)" | ||
| /…/lib/python3.12/wave.py # still the standard library — no shadowing | ||
| ``` | ||
|
|
||
| Two gates keep this from recurring: `tests/test_packaging.py` fails any pull | ||
| request that reintroduces a top-level package named after a standard-library | ||
| module, and `.github/workflows/smoke-install.yml` builds the wheel and imports | ||
| it from a fresh virtualenv with no repo on `sys.path`. | ||
|
|
||
| ## A note on the `wave.<api>` names in the README | ||
|
|
||
| The README's API tables are written as `wave.clips`, `wave.pipeline`, and so on. | ||
| Those are **attributes of a client instance**, not module paths — they describe | ||
| the shape of the `Wave` facade whatever you name your variable: | ||
|
|
||
| ```python | ||
| from wave_sdk import Wave | ||
|
|
||
| wave = Wave(api_key="…", organization_id="org_123") | ||
| wave.clips.list() # the `wave.clips` in the README table | ||
| ``` | ||
|
|
||
| There is no importable `wave` module in this SDK, and there will not be one. | ||
|
|
||
| ## License | ||
|
|
||
| `2.1.0` also corrects the distribution's license metadata. The repo has been | ||
| Apache-2.0 since commit `99d81d3`, but `pyproject.toml` still declared `MIT`, so | ||
| `2.0.0` shipped `License: MIT` in its `METADATA` alongside an Apache-2.0 | ||
| `LICENSE` file in the same archive. The license itself did not change — the | ||
| metadata now matches the `LICENSE` and `NOTICE` files it ships with. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use a portable file-selection command.
macOS BSD
grepdoes not support--include. The bulk migration command then fails before it updates imports. Usefindwith portablegrepoptions, or state that GNU grep is required.🤖 Prompt for AI Agents