restore original version strategy with no git hash.

This commit is contained in:
Rob 2023-10-01 18:43:03 -07:00
parent a1a557bd43
commit fd2795d0bc
No known key found for this signature in database
3 changed files with 49 additions and 34 deletions

View file

@ -2,7 +2,6 @@
, stdenv
, fetchFromGitHub
, cmake
, git
, ninja
, openssl
, openjdk11
@ -21,14 +20,17 @@ stdenv.mkDerivation rec {
src = fetchFromGitHub {
owner = pname;
repo = pname;
leaveDotGit = true;
rev = "v${version}";
hash = "sha256-NFkeeTpsxazQOstKUUu0b27hXbnq3U5g/+24BIMqtJY=";
hash = "sha256-EKvDH7RwOC4Gu/lturrfnGpzXnJ9azIwAFeuVoa6L/Y=";
};
patches = [ ./version.patch ];
nativeBuildInputs = [ cmake git ninja ];
postPatch = ''
substituteInPlace CMakeLists.txt --subst-var-by DUCKDB_VERSION "v${version}"
'';
nativeBuildInputs = [ cmake ninja ];
buildInputs = [ openssl ]
++ lib.optionals withJdbc [ openjdk11 ]
++ lib.optionals withOdbc [ unixODBC ];
@ -36,7 +38,6 @@ stdenv.mkDerivation rec {
cmakeFlags = [
# use similar flags to what is defined in ${src}/.github/workflow/{LinuxRelease,OSX}.yml
"-DDUCKDB_EXTENSION_CONFIGS=${src}/.github/config/bundled_extensions.cmake"
"-DGIT_LAST_TAG=${src.rev}"
"-DBUILD_ODBC_DRIVER=${enableFeature withOdbc}"
"-DJDBC_DRIVER=${enableFeature withJdbc}"
] ++ lib.optionals doInstallCheck [

View file

@ -1,18 +1,21 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2b49e11288..0a3eaa7f4e 100644
index 2b49e11288..0a4a69b9a0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -248,22 +248,13 @@ find_package(Git)
if(Git_FOUND)
if (NOT DEFINED GIT_COMMIT_HASH)
execute_process(
@@ -244,52 +244,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
set(SUN TRUE)
endif()
-find_package(Git)
-if(Git_FOUND)
- if (NOT DEFINED GIT_COMMIT_HASH)
- execute_process(
- COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
+ COMMAND ${GIT_EXECUTABLE} log -1 --format=%H
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_RESULT
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- RESULT_VARIABLE GIT_RESULT
- OUTPUT_VARIABLE GIT_COMMIT_HASH
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- endif()
- execute_process(
- COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@ -23,22 +26,35 @@ index 2b49e11288..0a3eaa7f4e 100644
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- OUTPUT_VARIABLE GIT_ITERATION
- OUTPUT_STRIP_TRAILING_WHITESPACE)
+ set(GIT_ITERATION "${GIT_LAST_TAG}-0-g${GIT_COMMIT_HASH}")
else()
message("Git NOT FOUND")
endif()
diff --git a/scripts/package_build.py b/scripts/package_build.py
index f0d7535ed0..350d74f877 100644
--- a/scripts/package_build.py
+++ b/scripts/package_build.py
@@ -130,7 +130,7 @@ def git_commit_hash():
if 'SETUPTOOLS_SCM_PRETEND_HASH' in os.environ:
return os.environ['SETUPTOOLS_SCM_PRETEND_HASH']
try:
- return subprocess.check_output(['git', 'log', '-1', '--format=%h']).strip().decode('utf8')
+ return subprocess.check_output(['git', 'log', '-1', '--format=%H']).strip().decode('utf8')
except:
return "deadbeeff"
-else()
- message("Git NOT FOUND")
-endif()
-
-if(GIT_RESULT EQUAL "0")
- string(REGEX REPLACE "v([0-9]+).[0-9]+.[0-9]+" "\\1" DUCKDB_MAJOR_VERSION "${GIT_LAST_TAG}")
- string(REGEX REPLACE "v[0-9]+.([0-9]+).[0-9]+" "\\1" DUCKDB_MINOR_VERSION "${GIT_LAST_TAG}")
- string(REGEX REPLACE "v[0-9]+.[0-9]+.([0-9]+)" "\\1" DUCKDB_PATCH_VERSION "${GIT_LAST_TAG}")
- string(REGEX REPLACE ".*-([0-9]+)-.*" "\\1" DUCKDB_DEV_ITERATION "${GIT_ITERATION}")
-
- if(DUCKDB_DEV_ITERATION EQUAL 0)
- # on a tag; directly use the version
- set(DUCKDB_VERSION "${GIT_LAST_TAG}")
- else()
- # not on a tag, increment the patch version by one and add a -devX suffix
- math(EXPR DUCKDB_PATCH_VERSION "${DUCKDB_PATCH_VERSION}+1")
- set(DUCKDB_VERSION "v${DUCKDB_MAJOR_VERSION}.${DUCKDB_MINOR_VERSION}.${DUCKDB_PATCH_VERSION}-dev${DUCKDB_DEV_ITERATION}")
- endif()
-else()
- # fallback for when building from tarball
- set(DUCKDB_MAJOR_VERSION 0)
- set(DUCKDB_MINOR_VERSION 0)
- set(DUCKDB_PATCH_VERSION 1)
- set(DUCKDB_DEV_ITERATION 0)
- set(DUCKDB_VERSION "v${DUCKDB_MAJOR_VERSION}.${DUCKDB_MINOR_VERSION}.${DUCKDB_PATCH_VERSION}-dev${DUCKDB_DEV_ITERATION}")
-endif()
+set(DUCKDB_VERSION "@DUCKDB_VERSION@")
message(STATUS "git hash ${GIT_COMMIT_HASH}, version ${DUCKDB_VERSION}")
diff --git a/tools/pythonpkg/setup.py b/tools/pythonpkg/setup.py
index fdf2911019..c363cc518a 100644

View file

@ -2,7 +2,6 @@
, buildPythonPackage
, duckdb
, fsspec
, git
, google-cloud-storage
, numpy
, openssl
@ -34,7 +33,6 @@ buildPythonPackage rec {
SETUPTOOLS_SCM_PRETEND_VERSION = version;
nativeBuildInputs = [
git
pybind11
setuptools-scm
];