-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Allow overriding of git describe also in scripts (via OVERRIDE_GIT_DESCRIBE environment variable) #11179
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
Allow overriding of git describe also in scripts (via OVERRIDE_GIT_DESCRIBE environment variable) #11179
Conversation
…ride via OVERRIDE_GIT_DESCRIBE
Now coverting both empty, version only, version+dev only or complete OVERRIDE_GIT_DESCRIBE
@@ -128,11 +128,39 @@ def get_relative_path(source_dir, target_file): | |||
return target_file | |||
|
|||
|
|||
def get_git_describe(): |
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.
Some useful generated simplification that I think would be nicer to work with:
from typing import NamedTuple
class VersionInfo(NamedTuple):
major: str
minor: str
patch: str
dev_version: str
def get_git_describe():
# Assume package_build.get_git_describe() returns a string like "v1.2.3-dev1-abcdef"
long_version = package_build.get_git_describe()
# Split the version and dev_version parts
version_parts, dev_version = long_version.split('-')[:-1], long_version.split('-')[-1]
major, minor, patch = version_parts[0].lstrip('v').split('.')
return VersionInfo(major, minor, patch, dev_version)
# Example usage:
version_info = get_git_describe()
print(version_info.major) # Print major version
print(version_info.minor) # Print minor version
print(version_info.patch) # Print patch version
print(version_info.dev_version) # Print development version
Not to be used verbatim obviously, but making a NamedTuple for this sounds like a good idea
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.
This is cool, but I don't feel very comfortable adding infrastructure around this.
Also connected: #11187, that is currently just a copy.
This seems to work properly, see for example the results of this run: https://github.com/duckdb/duckdb-test-staging/actions/runs/8298231890/job/22711776901 |
Thanks! |
Merge pull request duckdb/duckdb#11179 from carlopi/override_git_describe_in_scripts
Changes the scripts used by python build OR by amalgamation to use (if available) the environment variable OVERRIDE_GIT_DESCRIBE.
Idea is:
Code is a simple but a bit intricate (try / except and all), would love a proper review (ping to @Mause, @Mytherin or @Tishj).
I noticed that a similar role is covered by SETUPTOOLS_SCM_PRETEND_VERSION / SETUPTOOLS_SCM_PRETEND_HASH. Those variables keep having precedence as they had before, but also that might need a review.