setup.py 5.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# 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.

18
"""The script for setting up pydolphinscheduler."""
19 20
import logging
import os
21
import sys
22
from distutils.dir_util import remove_tree
23
from os.path import dirname, join
24
from typing import List
25

26
from setuptools import Command, find_packages, setup
27 28

if sys.version_info[0] < 3:
29 30 31
    raise Exception(
        "pydolphinscheduler does not support Python 2. Please upgrade to Python 3."
    )
32

33 34
logger = logging.getLogger(__name__)

J
Jiajie Zhong 已提交
35
version = "3.0.0"
36 37 38

# Start package required
prod = [
39
    "click>=8.0.0",
40
    "py4j~=0.10",
41
    "ruamel.yaml",
42 43
]

44 45 46 47 48 49
build = [
    "build",
    "setuptools>=42",
    "wheel",
]

50 51 52
doc = [
    "sphinx>=4.3",
    "sphinx_rtd_theme>=1.0",
53
    "sphinx-click>=3.0",
54
    "sphinx-inline-tabs",
55
    "sphinx-copybutton>=0.4.0",
56 57 58 59
    # Unreleased package have a feature we want(use correct version package for API ref), so we install from
    # GitHub directly, see also:
    # https://github.com/Holzhaus/sphinx-multiversion/issues/42#issuecomment-1210539786
    "sphinx-multiversion @ git+https://github.com/Holzhaus/sphinx-multiversion#egg=sphinx-multiversion",
60 61 62 63 64 65
]

test = [
    "pytest>=6.2",
    "freezegun>=1.1",
    "coverage>=6.1",
66
    "pytest-cov>=3.0",
67
    "docker>=5.0.3",
68 69 70 71 72 73 74
]

style = [
    "flake8>=4.0",
    "flake8-docstrings>=1.6",
    "flake8-black>=0.2",
    "isort>=5.10",
75
    "autoflake>=1.4",
76 77
]

78
dev = style + test + doc + build
79 80 81 82

all_dep = prod + dev
# End package required

83 84

def read(*names, **kwargs):
85
    """Read file content from given file path."""
86 87 88 89 90
    return open(
        join(dirname(__file__), *names), encoding=kwargs.get("encoding", "utf8")
    ).read()


91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
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."""

    def finalize_options(self) -> None:
        """Set final values for options."""

    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.")


122
setup(
123
    name="apache-dolphinscheduler",
124 125
    version=version,
    license="Apache License 2.0",
126
    description="Apache DolphinScheduler Python API",
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
    long_description=read("README.md"),
    # Make sure pypi is expecting markdown
    long_description_content_type="text/markdown",
    author="Apache Software Foundation",
    author_email="dev@dolphinscheduler.apache.org",
    url="https://dolphinscheduler.apache.org/",
    python_requires=">=3.6",
    keywords=[
        "dolphinscheduler",
        "workflow",
        "scheduler",
        "taskflow",
    ],
    project_urls={
        "Homepage": "https://dolphinscheduler.apache.org",
142
        "Documentation": "https://dolphinscheduler.apache.org/python/dev/index.html",
143 144 145 146
        "Source": "https://github.com/apache/dolphinscheduler/tree/dev/dolphinscheduler-python/"
        "pydolphinscheduler",
        "Issue Tracker": "https://github.com/apache/dolphinscheduler/issues?"
        "q=is%3Aissue+is%3Aopen+label%3APython",
147 148 149 150 151 152
        "Discussion": "https://github.com/apache/dolphinscheduler/discussions",
        "Twitter": "https://twitter.com/dolphinschedule",
    },
    packages=find_packages(where="src"),
    package_dir={"": "src"},
    include_package_data=True,
153
    package_data={
154
        "pydolphinscheduler": ["core/default_config.yaml"],
155 156
    },
    platforms=["any"],
157 158
    classifiers=[
        # complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
159
        "Development Status :: 3 - Alpha",
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
        "Environment :: Console",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: Apache Software License",
        "Operating System :: Unix",
        "Operating System :: POSIX",
        "Operating System :: Microsoft :: Windows",
        "Programming Language :: Python",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.6",
        "Programming Language :: Python :: 3.7",
        "Programming Language :: Python :: 3.8",
        "Programming Language :: Python :: 3.9",
        "Programming Language :: Python :: Implementation :: CPython",
        "Programming Language :: Python :: Implementation :: PyPy",
        "Topic :: Software Development :: User Interfaces",
    ],
176 177 178 179 180 181 182
    install_requires=prod,
    extras_require={
        "all": all_dep,
        "dev": dev,
        "style": style,
        "test": test,
        "doc": doc,
183 184 185 186
        "build": build,
    },
    cmdclass={
        "pre_clean": CleanCommand,
187
    },
188 189 190 191 192
    entry_points={
        "console_scripts": [
            "pydolphinscheduler = pydolphinscheduler.cli.commands:cli",
        ],
    },
193
)