# Copyright 2018 The Kubeflow Authors
#
# Licensed 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.

import os
import re

from setuptools import setup

NAME = 'kfp'
#VERSION = .... Change the version in kfp/__init__.py

# NOTICE, after any updates to the following, ./requirements.in should be updated
# accordingly.
REQUIRES = [
    'absl-py>=0.9,<=0.11',
    'PyYAML>=5.3,<6',
    # `Blob.from_string` was introduced in google-cloud-storage 1.20.0
    # https://github.com/googleapis/python-storage/blob/master/CHANGELOG.md#1200
    'google-cloud-storage>=1.20.0,<2',
    'kubernetes>=8.0.0,<19',
    # google-api-python-client v2 doesn't work for private dicovery by default:
    # https://github.com/googleapis/google-api-python-client/issues/1225#issuecomment-791058235
    'google-api-python-client>=1.7.8,<2',
    'google-auth>=1.6.1,<2',
    'requests-toolbelt>=0.8.0,<1',
    'cloudpickle>=1.3.0,<2',
    # Update the upper version whenever a new major version of the
    # kfp-server-api package is released.
    # Update the lower version when kfp sdk depends on new apis/fields in
    # kfp-server-api.
    # Note, please also update ./requirements.in
    'kfp-server-api>=1.1.2,<2.0.0',
    'jsonschema>=3.0.1,<4',
    'tabulate>=0.8.6,<1',
    'click>=7.1.1,<8',
    'Deprecated>=1.2.7,<2',
    'strip-hints>=0.1.8,<1',
    'docstring-parser>=0.7.3,<1',
    'kfp-pipeline-spec>=0.1.10,<0.2.0',
    'fire>=0.3.1,<1',
    'protobuf>=3.13.0,<4',
    'uritemplate>=3.0.1,<4',
    'pydantic>=1.8.2,<2',
    # Standard library backports
    'dataclasses;python_version<"3.7"',
    'typing-extensions>=3.7.4,<4;python_version<"3.9"',
]

TESTS_REQUIRE = [
    'frozendict',
]


def find_version(*file_path_parts):
    here = os.path.abspath(os.path.dirname(__file__))
    with open(os.path.join(here, *file_path_parts), 'r') as fp:
        version_file_text = fp.read()

    version_match = re.search(
        r"^__version__ = ['\"]([^'\"]*)['\"]",
        version_file_text,
        re.M,
    )
    if version_match:
        return version_match.group(1)

    raise RuntimeError('Unable to find version string.')


setup(
    name=NAME,
    version=find_version('kfp', '__init__.py'),
    description='KubeFlow Pipelines SDK',
    author='The Kubeflow Authors',
    url="https://github.com/kubeflow/pipelines",
    project_urls={
        "Documentation": "https://kubeflow-pipelines.readthedocs.io/en/stable/",
        "Bug Tracker": "https://github.com/kubeflow/pipelines/issues",
        "Source": "https://github.com/kubeflow/pipelines/tree/master/sdk",
        "Changelog": "https://github.com/kubeflow/pipelines/blob/master/sdk/RELEASE.md",
    },
    install_requires=REQUIRES,
    tests_require=TESTS_REQUIRE,
    packages=[
        'kfp',
        'kfp.auth',
        'kfp.cli',
        'kfp.cli.diagnose_me',
        'kfp.compiler',
        'kfp.components',
        'kfp.components.structures',
        'kfp.containers',
        'kfp.dsl',
        'kfp.dsl.extensions',
        'kfp.notebook',
        'kfp.v2',
        'kfp.v2.compiler',
        'kfp.v2.components',
        'kfp.v2.components.types',
        'kfp.v2.components.experimental',
        'kfp.v2.dsl',
        'kfp.v2.google.client',
        'kfp.v2.google.experimental',
    ],
    classifiers=[
        'Intended Audience :: Developers',
        'Intended Audience :: Education',
        'Intended Audience :: Science/Research',
        'License :: OSI Approved :: Apache Software License',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.6',
        'Programming Language :: Python :: 3.7',
        'Programming Language :: Python :: 3.8',
        'Programming Language :: Python :: 3.9',
        'Topic :: Scientific/Engineering',
        'Topic :: Scientific/Engineering :: Artificial Intelligence',
        'Topic :: Software Development',
        'Topic :: Software Development :: Libraries',
        'Topic :: Software Development :: Libraries :: Python Modules',
    ],
    python_requires='>=3.6.1',
    include_package_data=True,
    entry_points={
        'console_scripts': [
            'dsl-compile = kfp.compiler.main:main',
            'dsl-compile-v2 = kfp.v2.compiler.main:main',
            'kfp=kfp.__main__:main'
        ]
    })

sdk/python/setup.py
# Copyright 2018 The Kubeflow Authors
#
# Licensed 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.

import os
import re

from setuptools import setup

NAME = 'kfp'
#VERSION = .... Change the version in kfp/__init__.py

# NOTICE, after any updates to the following, ./requirements.in should be updated
# accordingly.
REQUIRES = [
    'absl-py>=0.9,<=0.11',
    'PyYAML>=5.3,<6',
    # `Blob.from_string` was introduced in google-cloud-storage 1.20.0
    # https://github.com/googleapis/python-storage/blob/master/CHANGELOG.md#1200
    'google-cloud-storage>=1.20.0,<2',
    'kubernetes>=8.0.0,<19',
    # google-api-python-client v2 doesn't work for private dicovery by default:
    # https://github.com/googleapis/google-api-python-client/issues/1225#issuecomment-791058235
    'google-api-python-client>=1.7.8,<2',
    'google-auth>=1.6.1,<2',
    'requests-toolbelt>=0.8.0,<1',
    'cloudpickle>=1.3.0,<2',
    # Update the upper version whenever a new major version of the
    # kfp-server-api package is released.
    # Update the lower version when kfp sdk depends on new apis/fields in
    # kfp-server-api.
    # Note, please also update ./requirements.in
    'kfp-server-api>=1.1.2,<2.0.0',
    'jsonschema>=3.0.1,<4',
    'tabulate>=0.8.6,<1',
    'click>=7.1.2,<9',
    'Deprecated>=1.2.7,<2',
    'strip-hints>=0.1.8,<1',
    'docstring-parser>=0.7.3,<1',
    'kfp-pipeline-spec>=0.1.10,<0.2.0',
    'fire>=0.3.1,<1',
    'protobuf>=3.13.0,<4',
    'uritemplate>=3.0.1,<4',
    'pydantic>=1.8.2,<2',
    # Standard library backports
    'dataclasses;python_version<"3.7"',
    'typing-extensions>=3.7.4,<4;python_version<"3.9"',
]

TESTS_REQUIRE = [
    'frozendict',
]


def find_version(*file_path_parts):
    here = os.path.abspath(os.path.dirname(__file__))
    with open(os.path.join(here, *file_path_parts), 'r') as fp:
        version_file_text = fp.read()

    version_match = re.search(
        r"^__version__ = ['\"]([^'\"]*)['\"]",
        version_file_text,
        re.M,
    )
    if version_match:
        return version_match.group(1)

    raise RuntimeError('Unable to find version string.')


setup(
    name=NAME,
    version=find_version('kfp', '__init__.py'),
    description='KubeFlow Pipelines SDK',
    author='The Kubeflow Authors',
    url="https://github.com/kubeflow/pipelines",
    project_urls={
        "Documentation": "https://kubeflow-pipelines.readthedocs.io/en/stable/",
        "Bug Tracker": "https://github.com/kubeflow/pipelines/issues",
        "Source": "https://github.com/kubeflow/pipelines/tree/master/sdk",
        "Changelog": "https://github.com/kubeflow/pipelines/blob/master/sdk/RELEASE.md",
    },
    install_requires=REQUIRES,
    tests_require=TESTS_REQUIRE,
    packages=[
        'kfp',
        'kfp.auth',
        'kfp.cli',
        'kfp.cli.diagnose_me',
        'kfp.compiler',
        'kfp.components',
        'kfp.components.structures',
        'kfp.containers',
        'kfp.dsl',
        'kfp.dsl.extensions',
        'kfp.notebook',
        'kfp.v2',
        'kfp.v2.compiler',
        'kfp.v2.components',
        'kfp.v2.components.types',
        'kfp.v2.components.experimental',
        'kfp.v2.dsl',
        'kfp.v2.google.client',
        'kfp.v2.google.experimental',
    ],
    classifiers=[
        'Intended Audience :: Developers',
        'Intended Audience :: Education',
        'Intended Audience :: Science/Research',
        'License :: OSI Approved :: Apache Software License',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.6',
        'Programming Language :: Python :: 3.7',
        'Programming Language :: Python :: 3.8',
        'Programming Language :: Python :: 3.9',
        'Topic :: Scientific/Engineering',
        'Topic :: Scientific/Engineering :: Artificial Intelligence',
        'Topic :: Software Development',
        'Topic :: Software Development :: Libraries',
        'Topic :: Software Development :: Libraries :: Python Modules',
    ],
    python_requires='>=3.6.1',
    include_package_data=True,
    entry_points={
        'console_scripts': [
            'dsl-compile = kfp.compiler.main:main',
            'dsl-compile-v2 = kfp.v2.compiler.main:main',
            'kfp=kfp.__main__:main'
        ]
    })

sdk/python/setup.py
diff --git a/sdk/RELEASE.md b/sdk/RELEASE.md
index 63d3c51960c..6c66be15bfb 100644
--- a/sdk/RELEASE.md
+++ b/sdk/RELEASE.md
@@ -17,6 +17,7 @@
 * Fix executor getting None as value when float 0 is passed in. [\#6682](https://github.com/kubeflow/pipelines/pull/6682)
 * Fix function-based components not preserving the namespace of GCPC artifact types. [\#6702](https://github.com/kubeflow/pipelines/pull/6702)
 * Depends on `typing-extensions>=3.7.4,<4; python_version<"3.9"` [\#6683](https://github.com/kubeflow/pipelines/pull/6683)
+* Depends on `click>=7.1.2,<9` [\#6691](https://github.com/kubeflow/pipelines/pull/6691)
 * Update v2 yaml format [\#6661](https://github.com/kubeflow/pipelines/pull/6661)
 
 ## Documentation Updates
diff --git a/sdk/python/requirements.in b/sdk/python/requirements.in
index ce5f25039f6..98f0a2dd84e 100644
--- a/sdk/python/requirements.in
+++ b/sdk/python/requirements.in
@@ -26,7 +26,7 @@ requests-toolbelt>=0.8.0,<1
 
 # CLI
 tabulate>=0.8.6,<1
-click>=7.1.1,<8
+click>=7.1.2,<9
 
 # kfp.v2
 absl-py>=0.9,<=0.11
diff --git a/sdk/python/requirements.txt b/sdk/python/requirements.txt
index e659295beae..9deb19cb49d 100644
--- a/sdk/python/requirements.txt
+++ b/sdk/python/requirements.txt
@@ -19,7 +19,7 @@ cffi==1.14.6
     # via google-crc32c
 charset-normalizer==2.0.6
     # via requests
-click==7.1.2
+click>=7.1.2,<9
     # via -r requirements.in
 cloudpickle==1.6.0
     # via -r requirements.in
diff --git a/sdk/python/setup.py b/sdk/python/setup.py
index cadd93e7059..b3922c81434 100644
--- a/sdk/python/setup.py
+++ b/sdk/python/setup.py
@@ -43,7 +43,7 @@
     'kfp-server-api>=1.1.2,<2.0.0',
     'jsonschema>=3.0.1,<4',
     'tabulate>=0.8.6,<1',
-    'click>=7.1.1,<8',
+    'click>=7.1.2,<9',
     'Deprecated>=1.2.7,<2',
     'strip-hints>=0.1.8,<1',
     'docstring-parser>=0.7.3,<1',

[sdk] dependency conflict with tensorflow 2.6.0 and seldon-core
### Environment

*  KFP version: 1.7
*  KFP SDK version: 1.8.3


*  All dependencies version:
```
[~]$ pip list | grep kfp
kfp                               1.8.3
kfp-pipeline-spec                 0.1.11
kfp-server-api                    1.7.0
```
kfp==1.8.3 collides with tensorflow==2.6 because it requires 

https://github.com/kubeflow/pipelines/blob/220d79df66e31bbd93c409fb361e0463bde4aeac/sdk/python/setup.py#L56

while tensorflow needs
```
Warning!!! Possibly conflicting dependencies found:
* tensorflow==2.6.0
 - typing-extensions [required: ~=3.7.4, installed: 3.10.0.2]
```

https://github.com/tensorflow/tensorflow/blob/421fba8888bb8f8724bc2e35ca2fdcde16e1bfe5/tensorflow/tools/pip_package/setup.py#L90

is `'typing-extensions>=3.7.4,<4;python_version<"3.9"'`   not enough?

The same goes for seldon-core==1.11.* and package click and absl-py

```
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
kfp 1.8.2 requires absl-py<=0.11,>=0.9, but you have absl-py 0.13.0 which is incompatible.
kfp 1.8.2 requires click<8,>=7.1.1, but you have click 8.0.1 which is incompatible.
kfp 1.8.2 requires typing-extensions<4,>=3.10.0.2, but you have typing-extensions 3.7.4.3 which is incompatible.
```
