From 36964c2b5a63c563354e6528f88bbe6a4a30c4ee Mon Sep 17 00:00:00 2001 From: Jiajie Zhong Date: Fri, 25 Feb 2022 11:06:26 +0800 Subject: [PATCH] [deploy] Make Python API as independent directory in release's dist (#8470) This patch add python api package as independent directory in final dist directory when user run command `mvn -U install package -Prelease`. There have `tar.gz` and `whl` in the python dist directory ``` python |--- python-independent-pkg.tar.gz |--- python-independent-pkg.whl ``` close: #8343 * Give dedicated control to docker build/push goals Co-authored-by: kezhenxu94 --- dolphinscheduler-dist/pom.xml | 16 +++++ .../assembly/dolphinscheduler-python-api.xml | 34 ++++++++++ .../main/assembly/dolphinscheduler-src.xml | 7 +++ dolphinscheduler-python/pom.xml | 62 +++++++++++++++++++ .../pydolphinscheduler/setup.py | 56 +++++++++++++++-- pom.xml | 14 +++++ 6 files changed, 185 insertions(+), 4 deletions(-) create mode 100644 dolphinscheduler-dist/src/main/assembly/dolphinscheduler-python-api.xml diff --git a/dolphinscheduler-dist/pom.xml b/dolphinscheduler-dist/pom.xml index 61362a32fc..9bd65c6884 100644 --- a/dolphinscheduler-dist/pom.xml +++ b/dolphinscheduler-dist/pom.xml @@ -104,6 +104,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 3ccc60ef0a..05d54871c7 100644 --- a/dolphinscheduler-dist/src/main/assembly/dolphinscheduler-src.xml +++ b/dolphinscheduler-dist/src/main/assembly/dolphinscheduler-src.xml @@ -57,6 +57,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 433c880a1e..72d18525ec 100644 --- a/dolphinscheduler-python/pom.xml +++ b/dolphinscheduler-python/pom.xml @@ -104,5 +104,67 @@ + + 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 117ffee76f..8be8d2a516 100644 --- a/dolphinscheduler-python/pydolphinscheduler/setup.py +++ b/dolphinscheduler-python/pydolphinscheduler/setup.py @@ -16,18 +16,23 @@ # 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 = [ @@ -35,6 +40,12 @@ prod = [ "py4j~=0.10", ] +build = [ + "build", + "setuptools>=42", + "wheel", +] + doc = [ "sphinx>=4.3", "sphinx_rtd_theme>=1.0", @@ -54,7 +65,7 @@ style = [ "isort>=5.10", ] -dev = style + test + doc +dev = style + test + doc + build all_dep = prod + dev # End package required @@ -67,6 +78,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, @@ -126,6 +170,10 @@ setup( "style": style, "test": test, "doc": doc, + "build": build, + }, + cmdclass={ + "pre_clean": CleanCommand, }, entry_points={ "console_scripts": [ diff --git a/pom.xml b/pom.xml index bd5852c61d..ae8e96b7ed 100644 --- a/pom.xml +++ b/pom.xml @@ -133,6 +133,8 @@ apache ${project.name} ${project.version} + true + true @@ -1002,6 +1004,7 @@ exec + ${docker.build.skip} 1 @@ -1026,6 +1029,7 @@ exec + ${docker.push.skip} 1 @@ -1233,6 +1237,16 @@ + + + docker + + false + false + + + +