diff --git a/python/setup.py.client.in b/python/setup.py.client.in index 1864c53528b587207cb98c3410e79ce039e69e65..86b3c331babccd06bdc6e206866a1c43da7b27d7 100644 --- a/python/setup.py.client.in +++ b/python/setup.py.client.in @@ -23,10 +23,19 @@ from setuptools import setup, Distribution, Extension from setuptools import find_packages from setuptools import setup from paddle_serving_client.version import serving_client_version +from pkg_resources import DistributionNotFound, get_distribution + def python_version(): return [int(v) for v in platform.python_version().split(".")] +def find_package(pkgname): + try: + get_distribution(pkgname) + return True + except DistributionNotFound: + return False + def copy_lib(): os.popen('mkdir -p paddle_serving_client/lib') for lib in ['libpython2.7.so.1.0', 'libssl.so.10', 'libcrypto.so.10']: @@ -41,9 +50,12 @@ if '${PACK}' == 'ON': REQUIRED_PACKAGES = [ - 'six >= 1.10.0', 'protobuf >= 3.1.0','paddlepaddle' + 'six >= 1.10.0', 'protobuf >= 3.1.0' ] +if not find_package("paddlepaddle") and not find_package("paddlepaddle-gpu"): + REQUIRED_PACKAGES.append("paddlepaddle") + packages=['paddle_serving_client', 'paddle_serving_client.proto', 'paddle_serving_client.io', diff --git a/python/setup.py.server.in b/python/setup.py.server.in index e852f02c3d39a1321fb964cad03116c4c39da778..b0bb7aa3703d6c4128a142191fc34578784c6789 100644 --- a/python/setup.py.server.in +++ b/python/setup.py.server.in @@ -22,6 +22,14 @@ from setuptools import setup, Distribution, Extension from setuptools import find_packages from setuptools import setup from paddle_serving_server.version import serving_server_version +from pkg_resources import DistributionNotFound, get_distribution + +def find_package(pkgname): + try: + get_distribution(pkgname) + return True + except DistributionNotFound: + return False def python_version(): return [int(v) for v in platform.python_version().split(".")] @@ -29,10 +37,13 @@ def python_version(): max_version, mid_version, min_version = python_version() REQUIRED_PACKAGES = [ - 'six >= 1.10.0', 'protobuf >= 3.1.0','paddlepaddle', - 'paddle_serving_client' + 'six >= 1.10.0', 'protobuf >= 3.1.0', + 'paddle_serving_client', 'flask' ] +if not find_package("paddlepaddle") and not find_package("paddlepaddle-gpu"): + REQUIRED_PACKAGES.append("paddlepaddle") + packages=['paddle_serving_server', 'paddle_serving_server.proto'] @@ -73,4 +84,3 @@ setup( ], license='Apache 2.0', keywords=('paddle-serving serving-server deployment industrial easy-to-use')) - diff --git a/python/setup.py.server_gpu.in b/python/setup.py.server_gpu.in index 08466e246c61c197aeb46bdbe9d43b5d28ae07a2..13ddb7329716c686eb21f118e203166e6badbd24 100644 --- a/python/setup.py.server_gpu.in +++ b/python/setup.py.server_gpu.in @@ -22,6 +22,14 @@ from setuptools import setup, Distribution, Extension from setuptools import find_packages from setuptools import setup from paddle_serving_server_gpu.version import serving_server_version +from pkg_resources import DistributionNotFound, get_distribution + +def find_package(pkgname): + try: + get_distribution(pkgname) + return True + except DistributionNotFound: + return False def python_version(): return [int(v) for v in platform.python_version().split(".")] @@ -29,10 +37,13 @@ def python_version(): max_version, mid_version, min_version = python_version() REQUIRED_PACKAGES = [ - 'six >= 1.10.0', 'protobuf >= 3.1.0','paddlepaddle', + 'six >= 1.10.0', 'protobuf >= 3.1.0', 'paddle_serving_client' ] +if not find_package("paddlepaddle") and not find_package("paddlepaddle-gpu"): + REQUIRED_PACKAGES.append("paddlepaddle") + packages=['paddle_serving_server_gpu', 'paddle_serving_server_gpu.proto']