-
Notifications
You must be signed in to change notification settings - Fork 51
fix(python-sdk): Use README.md as single source of truth, fix CI compile #697
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| """ | ||
| Override Speakeasy-generated pyproject.toml to use README.md as the package readme. | ||
|
|
||
| Speakeasy emits readme = "README-PYPI.md" but does not generate that file. We use | ||
| README.md as the single source of truth for the SDK; this script patches pyproject.toml | ||
| after generation so build/test work. At publish time, prepare_readme.py creates | ||
| README-PYPI.md and publish.sh builds with it. | ||
| """ | ||
| import sys | ||
|
|
||
| PYPROJECT = "pyproject.toml" | ||
| OLD = 'readme = "README-PYPI.md"' | ||
| NEW = 'readme = "README.md"' | ||
|
Comment on lines
+11
to
+13
|
||
|
|
||
|
|
||
| def main() -> int: | ||
| try: | ||
| with open(PYPROJECT, "r", encoding="utf-8") as f: | ||
| content = f.read() | ||
| except OSError as e: | ||
| print(f"Failed to read {PYPROJECT}: {e}", file=sys.stderr) | ||
| return 1 | ||
|
|
||
| if OLD not in content: | ||
| if NEW in content: | ||
| return 0 # Already patched | ||
| print(f"Neither {OLD!r} nor {NEW!r} found in {PYPROJECT}", file=sys.stderr) | ||
| return 1 | ||
|
|
||
| content = content.replace(OLD, NEW, 1) | ||
| try: | ||
| with open(PYPROJECT, "w", encoding="utf-8") as f: | ||
| f.write(content) | ||
| except OSError as e: | ||
| print(f"Failed to write {PYPROJECT}: {e}", file=sys.stderr) | ||
| return 1 | ||
|
|
||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,10 @@ | ||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||
| # README.md is the source of truth. For PyPI we need absolute links, so we | ||||||||||||||
| # generate README-PYPI.md and point pyproject at it only for this build. | ||||||||||||||
| export POETRY_PYPI_TOKEN_PYPI=${PYPI_TOKEN} | ||||||||||||||
|
||||||||||||||
| export POETRY_PYPI_TOKEN_PYPI=${PYPI_TOKEN} | |
| : "${PYPI_TOKEN:?PYPI_TOKEN environment variable must be set}" | |
| export POETRY_PYPI_TOKEN_PYPI="${PYPI_TOKEN}" |
Copilot
AI
Feb 11, 2026
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.
The sed replacement assumes the pyproject line is exactly readme = "README.md". If the generated/edited TOML uses different whitespace/quotes or already has README-PYPI.md, this command will silently do nothing and the publish build may use the wrong README. Consider making this replacement resilient (match the readme key regardless of current value/spacing) and fail fast if no change was applied.
| sed -i.bak 's/readme = "README.md"/readme = "README-PYPI.md"/' pyproject.toml | |
| sed -i.bak -E 's/^[[:space:]]*readme[[:space:]]*=[[:space:]]*".*"/readme = "README-PYPI.md"/' pyproject.toml | |
| if cmp -s pyproject.toml pyproject.toml.bak; then | |
| echo "Error: failed to update readme in pyproject.toml" >&2 | |
| exit 1 | |
| fi |
Copilot
AI
Feb 11, 2026
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.
publish.sh edits pyproject.toml to point at README-PYPI.md but never restores it back to README.md. After a local publish (or a failed publish), the working tree will be left in a state where normal builds/tests may fail unless README-PYPI.md is present. Consider restoring pyproject.toml from the backup on exit (e.g., via a trap) and/or explicitly switching it back to README.md after poetry publish completes.
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.
.gitignorecontains a duplicate.DS_Storeentry. Removing the duplicate reduces noise and makes the ignore list easier to maintain.