-
Notifications
You must be signed in to change notification settings - Fork 0
Use dynamic versioning #15
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
58a20fb
b2579f6
5584d43
35f8973
9f39226
b404162
f34b9a3
5efbc32
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 |
---|---|---|
@@ -1,15 +1,12 @@ | ||
#!/bin/bash | ||
|
||
version=$(cat VERSION) | ||
|
||
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v7.10.0 generate \ | ||
-i https://raw.githubusercontent.com/localstack/openapi/refs/heads/main/openapi/emulators/localstack-spec-latest.yml \ | ||
--skip-validate-spec \ | ||
-g python \ | ||
-o /local//packages/localstack-sdk-generated \ | ||
--global-property models,apis,supportingFiles \ | ||
-p packageName=localstack.sdk \ | ||
-p packageVersion=$version \ | ||
--template-dir /local/packages/localstack-sdk-generated/templates \ | ||
--global-property apiTests=false,modelTests=false \ | ||
--global-property apiDocs=false,modelDocs=False |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from localstack.sdk import version | ||
from localstack.sdk.api_client import ApiClient | ||
from localstack.sdk.configuration import Configuration | ||
|
||
|
@@ -30,3 +31,5 @@ def __init__(self, host: str | None = None, auth_token: str | None = None, **kwa | |
self.auth_token = auth_token | ||
self.configuration = Configuration(host=self.host) | ||
self._api_client = ApiClient(configuration=self.configuration) | ||
# The generated code comes with 1.0.0 hard-coded. We set here the correct version | ||
self._api_client.user_agent = f"LocalStack SDK/{version.version}/python" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick (non-blocking): Maybe something for the next iteration, but this is a bit risky / could break if teh internals of the generated API client breaks. It might make sense to explicitly test this in the future? |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ description = "Python SDK for LocalStack" | |
authors = [ | ||
{ name = "LocalStack Team", email = "info@localstack.cloud"} | ||
] | ||
version = "0.0.4" | ||
dynamic = ["version"] | ||
dependencies = [ | ||
"localstack-sdk-generated" | ||
] | ||
|
@@ -17,9 +17,13 @@ Repository = "https://github.com/localstack/localstack-sdk-python.git" | |
Issues = "https://github.com/localstack/localstack-sdk-python/issues" | ||
|
||
[build-system] | ||
requires = ["setuptools>=64"] | ||
requires = ["setuptools>=64", "setuptools_scm>=8"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.setuptools_scm] | ||
version_file = "localstack-sdk-python/localstack/sdk/version.py" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. praise: Nice! Using the native feature of |
||
local_scheme = "no-local-version" | ||
|
||
[tool.setuptools.dynamic] | ||
readme = { file = ["README.md"], content-type = "text/markdown"} | ||
|
||
|
@@ -30,6 +34,8 @@ dev-dependencies=[ | |
"boto3>=1.35.40", | ||
] | ||
|
||
cache-keys = [{ file = "pyproject.toml" }, { git = { commit = true , tags = true }}] | ||
|
||
[tool.uv.sources] | ||
localstack-sdk-generated = { workspace = true } | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import localstack.sdk.aws | ||
from localstack.sdk import version | ||
|
||
|
||
def test_client_version(): | ||
client = localstack.sdk.aws.AWSClient() | ||
assert version.version in client._api_client.user_agent |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
I wanted to do
version=$(uvx --from setuptools-scm python -m setuptools_scm)
but the version is hardcoded in the source when we generate the code (nothing major, only logs). One option was to change the mustache template, but I think it's too much hassle for this.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.
question: Could you elaborate on this one? Is this basically a "chicken egg problem"?
setuptools_scm
needs a tag, a tag needs a comment, a commit needs the code, the code needs the version fromsetuptools_scm
?If so, what's the takeaway? This could be a strong counter-argument not to use
setuptools_scm
in the first place, or could be neglected because it's not important?If this is not going to be set, then it would at least make sense to use a partial workaround (by using the
httpUserAgent
setting).But it would be very interesting to see which versions of the SDK are actually being used to communicate with the LocalStack runtime, so a proper versioning in the http user agent could be quite beneficial...