Skip to content

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

Merged
merged 8 commits into from
Jan 31, 2025
Merged

Use dynamic versioning #15

merged 8 commits into from
Jan 31, 2025

Conversation

giograno
Copy link
Member

uv now omits dynamics versions from the lock file (see astral-sh/uv#10622).
This allows us to switch to setuptools_scm to manage versioning with the usage of tags (similarly to what we do in LocalStack core).

This PR introduces the needed changes to the pyproject.toml files.

    the version was added in some comments/logs info; this does not play
    well when we re-generate the code from a branch with dynamic
    versioning
@@ -1,15 +1,12 @@
#!/bin/bash

version=$(cat VERSION)
Copy link
Member Author

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.

Copy link
Member

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 from setuptools_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...

@giograno giograno requested a review from alexrashed January 28, 2025 10:31
@giograno giograno marked this pull request as ready for review January 28, 2025 10:31
Copy link
Member

@alexrashed alexrashed left a comment

Choose a reason for hiding this comment

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

Really nice to see that uv overcame the issues we have.
I am still a bit confused with the drop of the version argument in the generation script, as I think this would drastically limit the access to data indicating the usage of the different SDK versions...
Maybe we can fix this, or at least make the impact of this change explicit / make a conscious decision?

@@ -1,15 +1,12 @@
#!/bin/bash

version=$(cat VERSION)
Copy link
Member

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 from setuptools_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...

@giograno
Copy link
Member Author

@alexrashed yes, this was kind of a chicken-egg problem.
The issue was only with the generated code. Using a version in the generation script results in a hard-coded value in the code. This would be the same issue as having the version in the uv.lock file.

I agree with you, it would be nice to know which SDK version is communicating with LocalStack.
I addressed the issue as follows:

  • I set up a version_file for setuptool_scm to dump the version number computed by setuptools_scm. This file is not tracked by git.
  • When we create the client (in the handcrafted module, not the generated one), we use such a version number to overwrite the user agent and have the correct version.

@giograno giograno requested a review from alexrashed January 29, 2025 15:18
Copy link
Member

@alexrashed alexrashed left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for addressing the comments! I think the new solution is lookin' good! 🚀

build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
version_file = "localstack-sdk-python/localstack/sdk/version.py"
Copy link
Member

Choose a reason for hiding this comment

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

praise: ‏Nice! Using the native feature of setuptools_scm for version-single-sourcing is a great idea! 💯

@@ -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"
Copy link
Member

Choose a reason for hiding this comment

The 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?‏

@giograno giograno merged commit df18a4f into main Jan 31, 2025
1 check passed
@giograno giograno deleted the dynamic-versioning branch January 31, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants