From 39380d43dc61b71fe31dbb8670e6af66ba3acfe2 Mon Sep 17 00:00:00 2001 From: Ali Ahmed Date: Mon, 3 Feb 2020 10:17:35 -0800 Subject: [PATCH] Allow Customization of version and name of python packages (#6188) --- pulsar-client-cpp/python/setup.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/pulsar-client-cpp/python/setup.py b/pulsar-client-cpp/python/setup.py index c16b9cf7473dd..52617a2cde881 100644 --- a/pulsar-client-cpp/python/setup.py +++ b/pulsar-client-cpp/python/setup.py @@ -19,6 +19,8 @@ from setuptools import setup from distutils.core import Extension +from distutils.util import strtobool +from os import environ import subprocess import sys @@ -28,18 +30,32 @@ from os.path import dirname, realpath, join def get_version(): + use_full_pom_name = strtobool(environ.get('USE_FULL_POM_NAME', 'False')) + # Get the pulsar version from pom.xml TOP_LEVEL_PATH = dirname(dirname(dirname(realpath(__file__)))) POM_PATH = join(TOP_LEVEL_PATH, 'pom.xml') root = ET.XML(open(POM_PATH).read()) version = root.find('{http://maven.apache.org/POM/4.0.0}version').text.strip() - # Strip the '-incubating' suffix, since it prevents the packages - # from being uploaded into PyPI - return version.split('-')[0] + if use_full_pom_name: + return version + else: + # Strip the '-incubating' suffix, since it prevents the packages + # from being uploaded into PyPI + return version.split('-')[0] + +def get_name(): + postfix = environ.get('NAME_POSTFIX', '') + base = 'pulsar-client' + return base + postfix VERSION = get_version() +NAME = get_name() + +print(VERSION) +print(NAME) if sys.version_info[0] == 2: PY2 = True @@ -79,7 +95,7 @@ def build_extension(self, ext): dependencies += ['enum34'] setup( - name="pulsar-client", + name=NAME, version=VERSION, packages=['pulsar', 'pulsar.schema', 'pulsar.functions'], cmdclass={'build_ext': my_build_ext},