This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/tsfile.git
The following commit(s) were added to refs/heads/develop by this push:
new aff40072 Auto update cpp & py project version when build with maven
(#306)
aff40072 is described below
commit aff40072e992a6c0cffd27ff858405220f221b0a
Author: Haonan <[email protected]>
AuthorDate: Fri Nov 22 10:16:58 2024 +0800
Auto update cpp & py project version when build with maven (#306)
* Auto update cpp&py project version when build with maven
* fix miss clear dylib
---
cpp/CMakeLists.txt | 5 ++---
cpp/VersionUpdater.groovy | 42 +++++++++++++++++++++++++++++++++++++
cpp/pom.xml | 50 ++++++++++++++++++++++----------------------
cpp/src/CMakeLists.txt | 4 ++--
pom.xml | 1 +
python/VersionUpdater.groovy | 41 ++++++++++++++++++++++++++++++++++++
python/pom.xml | 27 +++++++++++++++++++++++-
python/setup.py | 40 +++++++++++++++++++----------------
8 files changed, 161 insertions(+), 49 deletions(-)
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 5b96da35..1ba39325 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -20,8 +20,7 @@ cmake_minimum_required(VERSION 3.11)
project(TsFile_CPP)
cmake_policy(SET CMP0079 NEW)
-set(TsFile_CPP_VERSION_MAJOR 0)
-set(TsFile_CPP_VERSION_MINOR 1)
+set(TsFile_CPP_VERSION 1.2.0.dev)
set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -Wall -Werror")
message("cmake using: USE_CPP11=${USE_CPP11}")
@@ -68,7 +67,7 @@ endif()
message("CMAKE DEBUG: CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
-set(PROJECT_INCLUDE_DIR ${PROJECT_INCLUDE_DIR}
+set(PROJECT_INCLUDE_DIR ${PROJECT_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/third_party/lz4
${PROJECT_SOURCE_DIR}/third_party/lzokay
diff --git a/cpp/VersionUpdater.groovy b/cpp/VersionUpdater.groovy
new file mode 100644
index 00000000..49cbc650
--- /dev/null
+++ b/cpp/VersionUpdater.groovy
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Synchronize the version in CMakeLists.txt and the one used in the maven pom.
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+def cppProjectFile = new File(project.basedir, "CMakeLists.txt")
+def currentMavenVersion = project.version as String
+def currentCppVersion = currentMavenVersion
+if(currentMavenVersion.contains("-SNAPSHOT")) {
+ currentCppVersion = currentMavenVersion.split("-SNAPSHOT")[0] + ".dev"
+}
+println "Current Project Version in Maven: " + currentMavenVersion
+
+def match = cppProjectFile.text =~ /set\(TsFile_CPP_VERSION\s+(.+?)\)/
+def cppProjectFileVersion = match[0][1]
+println "Current Project Version in CMake: " + cppProjectFileVersion
+
+if (cppProjectFileVersion != currentCppVersion) {
+ cppProjectFile.text = cppProjectFile.text.replace("set(TsFile_CPP_VERSION
" + cppProjectFileVersion + ")", "set(TsFile_CPP_VERSION " + currentCppVersion
+ ")")
+ println "Version in CMakeLists.txt updated from " + cppProjectFileVersion
+ " to " + currentCppVersion
+ // TODO: When releasing, we might need to manually add this file to the
release preparation commit.
+} else {
+ println "Version in CMakeLists.txt is up to date"
+}
diff --git a/cpp/pom.xml b/cpp/pom.xml
index 65324616..c3699735 100644
--- a/cpp/pom.xml
+++ b/cpp/pom.xml
@@ -28,7 +28,6 @@
<packaging>pom</packaging>
<name>TsFile: C++</name>
<properties>
- <groovy.version>4.0.22</groovy.version>
<!-- Tell Sonar where to find the sources -->
<sonar.sources>common,examples,tsfile</sonar.sources>
<sonar.cfamily.build-wrapper-output>${project.build.directory}/build-wrapper-output</sonar.cfamily.build-wrapper-output>
@@ -120,6 +119,31 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.gmaven</groupId>
+ <artifactId>groovy-maven-plugin</artifactId>
+ <version>2.1.1</version>
+ <executions>
+ <!-- rename the cmake binary and generate a script that
adds the sonar build-wrapper -->
+ <execution>
+ <id>sync-project-version</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+
<source>${project.basedir}/VersionUpdater.groovy</source>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.groovy</groupId>
+ <artifactId>groovy</artifactId>
+ <version>${groovy.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
</plugins>
</build>
<profiles>
@@ -159,30 +183,6 @@
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.codehaus.gmaven</groupId>
- <artifactId>groovy-maven-plugin</artifactId>
- <executions>
- <!-- rename the cmake binary and generate a script
that adds the sonar build-wrapper -->
- <execution>
- <id>modify-cmake</id>
- <phase>process-test-sources</phase>
- <goals>
- <goal>execute</goal>
- </goals>
- <configuration>
-
<source>${project.basedir}/SonarcloudBuildWrapperHack.groovy</source>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.apache.groovy</groupId>
- <artifactId>groovy</artifactId>
- <version>${groovy.version}</version>
- </dependency>
- </dependencies>
- </plugin>
</plugins>
</build>
</profile>
diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt
index ce0e21ef..643e70a1 100644
--- a/cpp/src/CMakeLists.txt
+++ b/cpp/src/CMakeLists.txt
@@ -38,8 +38,8 @@ else()
target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj
read_obj write_obj)
endif()
-set(LIBTSFILE_PROJECT_VERSION 1.0)
-set(LIBTSFILE_SO_VERSION 1.0)
+set(LIBTSFILE_PROJECT_VERSION ${TsFile_CPP_VERSION})
+set(LIBTSFILE_SO_VERSION ${TsFile_CPP_VERSION})
set_target_properties(tsfile PROPERTIES VERSION ${LIBTSFILE_PROJECT_VERSION})
set_target_properties(tsfile PROPERTIES SOVERSION ${LIBTSFILE_SO_VERSION})
diff --git a/pom.xml b/pom.xml
index d58b2b09..0b668e5d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -40,6 +40,7 @@
<spotless.version>2.43.0</spotless.version>
<google.java.format.version>1.22.0</google.java.format.version>
<drill.freemarker.maven.plugin.version>1.21.1</drill.freemarker.maven.plugin.version>
+ <groovy.version>4.0.22</groovy.version>
</properties>
<build>
<pluginManagement>
diff --git a/python/VersionUpdater.groovy b/python/VersionUpdater.groovy
new file mode 100644
index 00000000..ee3eab2b
--- /dev/null
+++ b/python/VersionUpdater.groovy
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Synchronize the version in setup.py and the one used in the maven pom.
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+def pyProjectFile = new File(project.basedir, "setup.py")
+def currentMavenVersion = project.version as String
+def currentPyVersion = currentMavenVersion
+if(currentMavenVersion.contains("-SNAPSHOT")) {
+ currentPyVersion = currentMavenVersion.split("-SNAPSHOT")[0] + ".dev"
+}
+println "Current Project Version in Maven: " + currentMavenVersion
+def match = pyProjectFile.text =~ /version\s*=\s*"(.*?)"/
+def pyProjectFileVersion = match[0][1]
+println "Current Project Version in setup.py: " + pyProjectFileVersion
+
+if (pyProjectFileVersion != currentPyVersion) {
+ pyProjectFile.text = pyProjectFile.text.replace("version = \"" +
pyProjectFileVersion + "\"", "version = \"" + currentPyVersion + "\"")
+ println "Version in setup.py updated from " + pyProjectFileVersion + " to
" + currentPyVersion
+ // TODO: When releasing, we might need to manually add this file to the
release preparation commit.
+} else {
+ println "Version in setup.py is up to date"
+}
diff --git a/python/pom.xml b/python/pom.xml
index 4e576af6..f02e5021 100644
--- a/python/pom.xml
+++ b/python/pom.xml
@@ -29,7 +29,6 @@
<name>TsFile: Python</name>
<properties>
<unity.version>2.6.0</unity.version>
- <groovy.version>4.0.21</groovy.version>
<!-- Tell Sonar where to find the sources -->
<sonar.sources>tsfile</sonar.sources>
<sonar.cfamily.build-wrapper-output>${project.build.directory}/build-wrapper-output</sonar.cfamily.build-wrapper-output>
@@ -160,6 +159,7 @@
<directory>${basedir}/tsfile</directory>
<includes>
<include>*.so*</include>
+ <include>*.dylib</include>
<include>*.dll</include>
<include>*.h</include>
<include>*.cpp</include>
@@ -177,6 +177,31 @@
</filesets>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.gmaven</groupId>
+ <artifactId>groovy-maven-plugin</artifactId>
+ <version>2.1.1</version>
+ <executions>
+ <!-- rename the cmake binary and generate a script that
adds the sonar build-wrapper -->
+ <execution>
+ <id>sync-project-version</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+
<source>${project.basedir}/VersionUpdater.groovy</source>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.groovy</groupId>
+ <artifactId>groovy</artifactId>
+ <version>${groovy.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/python/setup.py b/python/setup.py
index 01120060..96b66f81 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -24,6 +24,7 @@ import platform
import shutil
import os
+version = "1.2.0.dev"
system = platform.system()
@@ -52,19 +53,6 @@ def copy_header(source, target):
shutil.copyfile(source, target)
-class BuildExt(build_ext):
- def build_extensions(self):
- numpy_include = np.get_include()
- for ext in self.extensions:
- ext.include_dirs.append(numpy_include)
- super().build_extensions()
-
- def finalize_options(self):
- if platform.system() == "Windows":
- self.compiler = 'mingw32'
- super().finalize_options()
-
-
project_dir = os.path.dirname(os.path.abspath(__file__))
libtsfile_shard_dir = os.path.join(project_dir, "..", "cpp", "target",
"build", "lib")
@@ -79,9 +67,9 @@ target_include_dir = os.path.join(project_dir, "tsfile",
"TsFile-cwrapper.h")
copy_header(source_include_dir, target_include_dir)
if system == "Darwin":
- copy_lib_files(libtsfile_shard_dir, libtsfile_dir, "1.0.dylib")
+ copy_lib_files(libtsfile_shard_dir, libtsfile_dir, version + ".dylib")
elif system == "Linux":
- copy_lib_files(libtsfile_shard_dir, libtsfile_dir, "so.1.0")
+ copy_lib_files(libtsfile_shard_dir, libtsfile_dir, "so." + version)
else:
copy_lib_files(libtsfile_shard_dir, libtsfile_dir, "dll")
@@ -92,15 +80,31 @@ ext_modules_tsfile = [
libraries=["tsfile"],
library_dirs=[libtsfile_dir],
include_dirs=[include_dir, np.get_include()],
- runtime_library_dirs=[libtsfile_dir] if platform.system() != "Windows"
else None,
- extra_compile_args=["-std=c++11"] if platform.system() != "Windows"
else ["-std=c++11", "-DMS_WIN64"],
+ runtime_library_dirs=[libtsfile_dir] if system != "Windows" else None,
+ extra_compile_args=(
+ ["-std=c++11"] if system != "Windows" else ["-std=c++11",
"-DMS_WIN64"]
+ ),
language="c++",
)
]
+
+class BuildExt(build_ext):
+ def build_extensions(self):
+ numpy_include = np.get_include()
+ for ext in self.extensions:
+ ext.include_dirs.append(numpy_include)
+ super().build_extensions()
+
+ def finalize_options(self):
+ if system == "Windows":
+ self.compiler = "mingw32"
+ super().finalize_options()
+
+
setup(
name="tsfile",
- version="1.2.0.dev0",
+ version=version,
description="Tsfile reader and writer for python",
url="https://tsfile.apache.org",
author='"Apache TsFile"',