Skip to content

Commit

Permalink
Allow Customization of version and name of python packages (apache#6188)
Browse files Browse the repository at this point in the history
  • Loading branch information
aahmed-se authored Feb 3, 2020
1 parent af6b5f6 commit 39380d4
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions pulsar-client-cpp/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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},
Expand Down

0 comments on commit 39380d4

Please sign in to comment.