Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .genignore
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
pyproject.toml
3 changes: 3 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: "Ensure README-PYPI.md is created"
run: python scripts/prepare_readme.py

# run the glean target specified in .speakeasy/workflow.yaml
- run: speakeasy test --target glean

Expand Down
4 changes: 2 additions & 2 deletions .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ python:
- input
asyncMode: both
authors:
- Speakeasy
- Glean Technologies, Inc.
baseErrorName: GleanBaseError
clientServerStatusCodesAsErrors: true
defaultErrorName: GleanError
Expand Down Expand Up @@ -69,7 +69,7 @@ python:
moduleName: glean.api_client
outputModelSuffix: output
packageManager: poetry
packageName: glean
packageName: glean-api-client

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rwjblue-glean This looks strange. Isn't the package name supposed to be glean? We publish glean-api-client but the package users import from is glean

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, no, I think this is correct?

If you notice the [tool.poetry] section in pyproject.toml is unchanged:

packages = [
    { include = "glean", from = "src" }
]

AFAICT this is the correct way to do PEP 420 namespaced packages.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tldr; the import path is governed by the file layout in the sdist/wheel (which we haven't changed with this config change).

Landing this change, then running speakeasy run doesn't change anything about the file system layout (happy to push up a branch for you to review just to be safe).

Originally (when we first created the api clients), Speakeasy didn't support PEP 420 namespaced packages but they landed that support a few months back. In this docs they have two settings:

  • moduleName -- this is the expected import path for users (what is shown in the code samples, docs, etc)
  • packageName -- this is what is actually published to pypi

We had a work around (added in #23) that ran speakeasy run then munged a bunch of stuff in order to have the PEP 420 namespacing, but then when Speakeasy added support I updated (in #43) to avoid a really gnarly workaround that we had previously (basically setting the new moduleName field).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k. As long as the imports still work then :shipit:

pytestFilterWarnings: []
pytestTimeout: 0
responseFormat: flat
Expand Down
34 changes: 21 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@

[project]
name = "glean-api-client"
version = "0.11.22"
description = "Python Client SDK Generated by Speakeasy."
authors = [{ name = "Glean Technologies, Inc." }]
license = "MIT"
# NOTE: scripts/prepare_readme.py tweaks this to point to README-PYPI.md for publication
# The published readme has relative URLs converted to absolute URLs for PyPI compatibility
readme = "README.md"
requires-python = ">=3.9"
dependencies = ["httpx >=0.28.1", "pydantic >=2.11.2"]
authors = [{ name = "Glean Technologies, Inc." },]
readme = "README-PYPI.md"
requires-python = ">=3.9.2"
dependencies = [
"httpcore >=1.0.9",
"httpx >=0.28.1",
"pydantic >=2.11.2",
]

[tool.poetry]
packages = [{ include = "glean", from = "src" }]
include = ["py.typed", "src/glean/py.typed"]
repository = "https://github.com/gleanwork/api-client-python.git"
packages = [
{ include = "glean", from = "src" }
]
include = ["py.typed", "src/glean/api_client/py.typed"]

[tool.setuptools.package-data]
"*" = ["py.typed", "src/glean/py.typed"]
"*" = ["py.typed", "src/glean/api_client/py.typed"]

[virtualenvs]
in-project = true

[tool.poetry.group.dev.dependencies]
mypy = "==1.15.0"
pylint = "==3.2.3"
pytest = "^8.3.4"
pytest-asyncio = "^0.25.3"
pytest-xdist = "^3.6.1"
pyright = "==1.1.398"
pytest = "^8.4.1"
pytest-asyncio = "==1.2.0"
pytest-xdist = "^3.8.0"

[build-system]
requires = ["poetry-core"]
Expand All @@ -51,3 +57,5 @@ ignore_missing_imports = true
[tool.pyright]
venvPath = "."
venv = ".venv"