diff --git a/dolphinscheduler-dist/pom.xml b/dolphinscheduler-dist/pom.xml
index cdbaa87c1a..a288356526 100644
--- a/dolphinscheduler-dist/pom.xml
+++ b/dolphinscheduler-dist/pom.xml
@@ -95,6 +95,22 @@
+
+ python
+ package
+
+ single
+
+
+
+ python
+ false
+
+ src/main/assembly/dolphinscheduler-python-api.xml
+
+
+
+
diff --git a/dolphinscheduler-dist/src/main/assembly/dolphinscheduler-python-api.xml b/dolphinscheduler-dist/src/main/assembly/dolphinscheduler-python-api.xml
new file mode 100644
index 0000000000..cd37acee62
--- /dev/null
+++ b/dolphinscheduler-dist/src/main/assembly/dolphinscheduler-python-api.xml
@@ -0,0 +1,34 @@
+
+
+
+ python-api
+
+ dir
+
+ false
+
+
+
+ ${basedir}/../dolphinscheduler-python/pydolphinscheduler/dist
+ .
+
+
+
diff --git a/dolphinscheduler-dist/src/main/assembly/dolphinscheduler-src.xml b/dolphinscheduler-dist/src/main/assembly/dolphinscheduler-src.xml
index e675cfb2ba..e275d6e42d 100644
--- a/dolphinscheduler-dist/src/main/assembly/dolphinscheduler-src.xml
+++ b/dolphinscheduler-dist/src/main/assembly/dolphinscheduler-src.xml
@@ -58,6 +58,13 @@
**/dolphinscheduler-ui/node/**
**/dolphinscheduler-ui/node_modules/**
+
+ **/dolphinscheduler-python/pydolphinscheduler/.pytest_cache/**
+ **/dolphinscheduler-python/pydolphinscheduler/build/**
+ **/dolphinscheduler-python/pydolphinscheduler/dist/**
+ **/dolphinscheduler-python/pydolphinscheduler/dist/**
+ **/dolphinscheduler-python/pydolphinscheduler/htmlcov/**
+
**/.settings/**
**/.project
diff --git a/dolphinscheduler-python/pom.xml b/dolphinscheduler-python/pom.xml
index f669d634dd..74a0880e9c 100644
--- a/dolphinscheduler-python/pom.xml
+++ b/dolphinscheduler-python/pom.xml
@@ -16,7 +16,8 @@
~ limitations under the License.
-->
-
+
4.0.0
org.apache.dolphinscheduler
@@ -56,4 +57,69 @@
+
+
+
+ release
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+
+
+ python-api-prepare
+ prepare-package
+
+ exec
+
+
+ python3
+ ${project.basedir}/pydolphinscheduler
+
+ -m
+ pip
+ install
+ --upgrade
+ pip
+ .[build]
+
+
+
+
+ python-api-clean
+ prepare-package
+
+ exec
+
+
+ python3
+ ${project.basedir}/pydolphinscheduler
+
+ setup.py
+ pre_clean
+
+
+
+
+ python-api-build
+ prepare-package
+
+ exec
+
+
+ python3
+ ${project.basedir}/pydolphinscheduler
+
+ -m
+ build
+
+
+
+
+
+
+
+
+
diff --git a/dolphinscheduler-python/pydolphinscheduler/setup.py b/dolphinscheduler-python/pydolphinscheduler/setup.py
index cd6eb3eb77..dacb91b536 100644
--- a/dolphinscheduler-python/pydolphinscheduler/setup.py
+++ b/dolphinscheduler-python/pydolphinscheduler/setup.py
@@ -16,24 +16,35 @@
# under the License.
"""The script for setting up pydolphinscheduler."""
-
+import logging
+import os
import sys
+from distutils.dir_util import remove_tree
from os.path import dirname, join
+from typing import List
-from setuptools import find_packages, setup
+from setuptools import Command, find_packages, setup
if sys.version_info[0] < 3:
raise Exception(
"pydolphinscheduler does not support Python 2. Please upgrade to Python 3."
)
-version = "0.1.0"
+logger = logging.getLogger(__name__)
+
+version = "2.0.4"
# Start package required
prod = [
"py4j~=0.10",
]
+build = [
+ "build",
+ "setuptools>=42",
+ "wheel",
+]
+
doc = [
"sphinx>=4.3",
"sphinx_rtd_theme>=1.0",
@@ -52,7 +63,7 @@ style = [
"isort>=5.10",
]
-dev = style + test + doc
+dev = style + test + doc + build
all_dep = prod + dev
# End package required
@@ -65,6 +76,39 @@ def read(*names, **kwargs):
).read()
+class CleanCommand(Command):
+ """Command to clean up python api before setup by running `python setup.py pre_clean`."""
+
+ description = "Clean up project root"
+ user_options: List[str] = []
+ clean_list = [
+ "build",
+ "htmlcov",
+ "dist",
+ ".pytest_cache",
+ ".coverage",
+ ]
+
+ def initialize_options(self) -> None:
+ """Set default values for options."""
+ pass
+
+ def finalize_options(self) -> None:
+ """Set final values for options."""
+ pass
+
+ def run(self) -> None:
+ """Run and remove temporary files."""
+ for cl in self.clean_list:
+ if not os.path.exists(cl):
+ logger.info("Path %s do not exists.", cl)
+ elif os.path.isdir(cl):
+ remove_tree(cl)
+ else:
+ os.remove(cl)
+ logger.info("Finish pre_clean process.")
+
+
setup(
name="apache-dolphinscheduler",
version=version,
@@ -124,5 +168,9 @@ setup(
"style": style,
"test": test,
"doc": doc,
+ "build": build,
+ },
+ cmdclass={
+ "pre_clean": CleanCommand,
},
)