You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2023/08/31 09:57:49 UTC
[iotdb] 01/01: Refactor python package
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch refactor_python_package
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit d5a9ef3e061d84e36a3e57d106b5772f62e98212
Author: HTHou <hh...@outlook.com>
AuthorDate: Thu Aug 31 17:57:13 2023 +0800
Refactor python package
---
.github/workflows/client-python.yml | 3 ++
.gitignore | 9 +---
iotdb-client/client-py/.gitignore | 2 +
iotdb-client/client-py/pom.xml | 62 ++++++++++++++++++++++++-
iotdb-client/client-py/release.sh | 18 ++++---
iotdb-client/client-py/{ => resources}/setup.py | 2 +-
6 files changed, 79 insertions(+), 17 deletions(-)
diff --git a/.github/workflows/client-python.yml b/.github/workflows/client-python.yml
index 2a96963edd9..5a5368e8597 100644
--- a/.github/workflows/client-python.yml
+++ b/.github/workflows/client-python.yml
@@ -48,6 +48,9 @@ jobs:
docker images
- name: Install IoTDB python client requirements
run: pip3 install -r iotdb-client/client-py/requirements_dev.txt
+ - name: Check code style
+ shell: base
+ run: black iotdb-client/client-py/ --check
- name: Integration test
shell: bash
run: |
diff --git a/.gitignore b/.gitignore
index 7eff5899cd5..812db1ac019 100644
--- a/.gitignore
+++ b/.gitignore
@@ -119,14 +119,9 @@ classes/
Makefile
**/CMakeFiles/
-### cluster test data
-node1/
-node2/
-node3/
-
# Exclude copied license
-/client-py/LICENSE
-/mlnode/LICENSE
+iotdb-client/client-py/LICENSE
+iotdb-core/mlnode/LICENSE
# ANTLR
iotdb-core/antlr/gen/
diff --git a/iotdb-client/client-py/.gitignore b/iotdb-client/client-py/.gitignore
index 0778bd56f17..c2e6bdffad3 100644
--- a/iotdb-client/client-py/.gitignore
+++ b/iotdb-client/client-py/.gitignore
@@ -3,3 +3,5 @@
/build/
/dist/
/apache_iotdb.egg-info
+/setup.py
+!/resources/setup/py
diff --git a/iotdb-client/client-py/pom.xml b/iotdb-client/client-py/pom.xml
index 74c6309fd53..fbfbc310aee 100644
--- a/iotdb-client/client-py/pom.xml
+++ b/iotdb-client/client-py/pom.xml
@@ -38,11 +38,10 @@
<skip>true</skip>
</configuration>
</plugin>
- <!-- clean thrift folder -->
+ <!-- clean thrift and old build folder -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
- <version>2.4.1</version>
<configuration>
<filesets>
<fileset>
@@ -52,6 +51,15 @@
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
+ <fileset>
+ <directory>apache_iotdb.egg-info</directory>
+ </fileset>
+ <fileset>
+ <directory>build</directory>
+ </fileset>
+ <fileset>
+ <directory>dist</directory>
+ </fileset>
<fileset>
<directory>./</directory>
<includes>
@@ -114,9 +122,59 @@
</resources>
</configuration>
</execution>
+ <execution>
+ <id>copy-setup-file-resources</id>
+ <!-- here the phase you need -->
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <encoding>utf-8</encoding>
+ <outputDirectory>${basedir}/</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${basedir}/target/classes</directory>
+ <includes>
+ <include>setup.py</include>
+ </includes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>3.4.0</version>
+ <executions>
+ <execution>
+ <id>write-python-version</id>
+ <goals>
+ <goal>regex-property</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ <configuration>
+ <name>python_version</name>
+ <regex>-SNAPSHOT</regex>
+ <value>${project.version}</value>
+ <replacement>\.dev0</replacement>
+ <failIfNoMatch>false</failIfNoMatch>
+ </configuration>
+ </execution>
</executions>
</plugin>
</plugins>
+ <resources>
+ <resource>
+ <directory>${basedir}/.resources</directory>
+ <includes>
+ <include>setup.py</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
</build>
<dependencies>
<dependency>
diff --git a/iotdb-client/client-py/release.sh b/iotdb-client/client-py/release.sh
index 2d9ca299795..df8e0adf76e 100755
--- a/iotdb-client/client-py/release.sh
+++ b/iotdb-client/client-py/release.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/bash
#
#
# Licensed to the Apache Software Foundation (ASF) under one
@@ -20,21 +20,25 @@
#
# the python version must be python3.
-python --version
+python3 --version
rm -Rf build
rm -Rf dist
rm -Rf iotdb_session.egg_info
# (Re-)build generated code
-(cd ..; mvn clean generate-sources -pl client-py -am)
+(cd ..; mvn clean package -pl client-py -am)
# Run Linting
-flake8
+black .
# Run unit tests
-pytest .
+if [ "$1" == "test" ]; then
+ pytest .
+fi
# See https://packaging.python.org/tutorials/packaging-projects/
-python setup.py sdist bdist_wheel
-twine upload --repository pypi dist/*
\ No newline at end of file
+python3 setup.py sdist bdist_wheel
+if [ "$1" == "release" ]; then
+ twine upload --repository pypi dist/*
+fi
diff --git a/iotdb-client/client-py/setup.py b/iotdb-client/client-py/resources/setup.py
similarity index 98%
rename from iotdb-client/client-py/setup.py
rename to iotdb-client/client-py/resources/setup.py
index 364f42e5ae6..3af2705af26 100644
--- a/iotdb-client/client-py/setup.py
+++ b/iotdb-client/client-py/resources/setup.py
@@ -31,7 +31,7 @@ print(long_description)
setuptools.setup(
name="apache-iotdb", # Replace with your own username
- version="1.0.0",
+ version="${python_version}",
author=" Apache Software Foundation",
author_email="dev@iotdb.apache.org",
description="Apache IoTDB client API",