Skip to content

Commit

Permalink
Merge pull request #132 from samansmink/fix-small-ci-issue
Browse files Browse the repository at this point in the history
switch version parsing to makefile
  • Loading branch information
samansmink authored Jan 24, 2025
2 parents 70a6987 + 5ff9b56 commit 77fb318
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 44 deletions.
10 changes: 0 additions & 10 deletions makefiles/c_api_extensions/base.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,6 @@ extension_version: configure/extension_version.txt
configure/extension_version.txt:
@ $(VERSION_COMMAND)

#############################################
### Parse DuckDB Semver
#############################################

# Either autodetect or use the provided value
PARSE_SEMVER_COMMAND=$(PYTHON_VENV_BIN) extension-ci-tools/scripts/configure_helper.py -s $(TARGET_DUCKDB_VERSION)

parse_duckdb_version:
@ $(PARSE_SEMVER_COMMAND)

#############################################
### Testing
#############################################
Expand Down
15 changes: 9 additions & 6 deletions makefiles/c_api_extensions/c_cpp.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
#############################################

# Get parsed SemVer for Stable C API
FILE_MAJOR := ./configure/duckdb_version_major.txt
FILE_MINOR := ./configure/duckdb_version_minor.txt
FILE_PATCH := ./configure/duckdb_version_patch.txt
MAJOR_VERSION := $(file < $(FILE_MAJOR))
MINOR_VERSION := $(file < $(FILE_MINOR))
PATCH_VERSION := $(file < $(FILE_PATCH))
VERSION_PARTS = $(subst ., ,$(TARGET_DUCKDB_VERSION))
MAJOR_VERSION=
MINOR_VERSION=
PATCH_VERSION=
ifeq ($(word 1,$(VERSION_PARTS)), v1)
MAJOR_VERSION = 1
MINOR_VERSION = $(word 2,$(VERSION_PARTS))
PATCH_VERSION = $(word 3,$(VERSION_PARTS))
endif

# Create build params to pass name and version
CMAKE_VERSION_PARAMS = -DEXTENSION_NAME=$(EXTENSION_NAME)
Expand Down
28 changes: 0 additions & 28 deletions scripts/configure_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def main():

arg_parser.add_argument('-ev', '--extension-version', help='Write the autodetected extension version', action='store_true')
arg_parser.add_argument('-p', '--duckdb-platform', help='Write the auto-detected duckdb platform', action='store_true')
arg_parser.add_argument('-s', '--parse-duckdb-semver', type=str, help='Write the parsed DuckDB version SemVer')

args = arg_parser.parse_args()

Expand Down Expand Up @@ -41,32 +40,5 @@ def main():
print(f"Writing platform {duckdb_platform} to {platform_file}")
f.write(duckdb_platform)

# Write parsed semver
if args.parse_duckdb_semver:
from packaging.version import Version, InvalidVersion
major_file = Path(os.path.join(OUTPUT_DIR, "duckdb_version_major.txt"))
minor_file = Path(os.path.join(OUTPUT_DIR, "duckdb_version_minor.txt"))
patch_file = Path(os.path.join(OUTPUT_DIR, "duckdb_version_patch.txt"))

major_version = ""
minor_version = ""
patch_version = ""

try:
version = Version(args.parse_duckdb_semver)
major_version = f"{version.major}"
minor_version = f"{version.minor}"
patch_version = f"{version.micro}"
print(f"Written parsed DuckDB semver v{version} to {OUTPUT_DIR}/duckdb_version_<part>.txt")
except InvalidVersion:
print(f"DuckDB version is not a semver, writing empty parsed semver files to {OUTPUT_DIR}/duckdb_version_<part>.txt")

with open(major_file, 'w') as f:
f.write(major_version)
with open(minor_file, 'w') as f:
f.write(minor_version)
with open(patch_file, 'w') as f:
f.write(patch_version)

if __name__ == '__main__':
main()

0 comments on commit 77fb318

Please sign in to comment.