Skip to content

Conversation

silv-io
Copy link
Member

@silv-io silv-io commented Mar 20, 2024

Motivation

To introduce namespace packages, the modern way is to remove all __init__.py files in the namespace package, our case localstack_ext. Currently this is not possible because our init file contains the version attribute used in various scripts.

Changes

  • Move the __version__ out of the __init__.py into a VERSION file residing in the top-level of the project.
  • Make pyproject.toml take the version out of the VERSION file
  • Adapt all the scripts and Makefile to do their changes based on and in the VERSION file
  • To still allow for run-time access of the version, add a setup.py which - on install/build - takes the value from the VERSION file and produces a version.py file in localstack.
  • For backwards compatibility with older images, switch all the usages of the version to the pre-existing VERSION in constants.py and take the value from VERSION out of localstack.version.__version__ (version.py might not yet exist in older images which can lead to issues in the CI right now)

Testing

  • Pipeline should be green
  • Distribution should look the same (maybe we can introduce some regression tests here in the future, so that we can more easily check if we botched the distribution by some change)

TODO

What's left to do:

Note

This PR was recreated with a new branch name to trigger the companion branch detection

@silv-io silv-io added the semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases label Mar 20, 2024
Copy link

github-actions bot commented Mar 20, 2024

S3 Image Test Results (AMD64 / ARM64)

  2 files  ±0    2 suites  ±0   3m 0s ⏱️ +3s
394 tests ±0  343 ✅ ±0   51 💤 ±0  0 ❌ ±0 
788 runs  ±0  686 ✅ ±0  102 💤 ±0  0 ❌ ±0 

Results for commit ea1a7b3. ± Comparison against base commit 0f4b52e.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Mar 20, 2024

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 30m 33s ⏱️ +33s
2 707 tests ±0  2 452 ✅ ±0  255 💤 ±0  0 ❌ ±0 
2 709 runs  ±0  2 452 ✅ ±0  257 💤 ±0  0 ❌ ±0 

Results for commit f39c3bb. ± Comparison against base commit 0f4b52e.

♻️ This comment has been updated with latest results.

@silv-io silv-io force-pushed the move-version-source branch 4 times, most recently from 2ab5661 to d28e66c Compare March 20, 2024 15:00
@silv-io silv-io marked this pull request as ready for review March 20, 2024 15:29
Copy link
Member

@thrau thrau left a comment

Choose a reason for hiding this comment

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

thanks for taking a stab at this @silv-io! could you clarify for posterity why we need a VERSION file in this iteration? wouldn't introducing the version module and localstack.version.__version__ be enough?

@silv-io
Copy link
Member Author

silv-io commented Mar 21, 2024

thanks for taking a stab at this @silv-io! could you clarify for posterity why we need a VERSION file in this iteration? wouldn't introducing the version module and localstack.version.__version__ be enough?

@thrau, there are multiple benefits to that.

As you can see in the changes, many of the scripts just get way easier to handle when having the version source separated into a simple text file. This is also mentioned as a benefit in the PyPA guide in (4.):

An advantage with this technique is that it’s not specific to Python. Any tool can read the version.

So no need to use grep, awk and sed anymore here. While extracting the version with these tools is fairly easy, any change we might make at some point might be error-prone because of the heavy usage of regex patterns. A simple cat VERSION won't lead to many errors when trying to change things :)

Another point is that in a multi distribution setup it is also much easier to send a plain version file to subpackages that they can reference in the pyproject.toml, than to write a script which would put a python version file in exactly the right spot for all the different distributions.

@silv-io silv-io force-pushed the move-version-source branch from d28e66c to f39c3bb Compare March 21, 2024 15:59
Copy link
Member

@thrau thrau left a comment

Choose a reason for hiding this comment

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

Overall looks really good! The arguments make sense to me and I can see that the version file is a good way forward!
Just one comment related to updating the version number. I think I may be missing something though since I saw that the content is overwritten somewhere in the release helper.

@silv-io silv-io force-pushed the move-version-source branch from ea1a7b3 to db97b53 Compare March 22, 2024 10:14
@silv-io silv-io merged commit 367ff6b into master Mar 22, 2024
@silv-io silv-io deleted the move-version-source branch March 22, 2024 10:15
@alexrashed alexrashed mentioned this pull request Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants