This is an automated email from the ASF dual-hosted git repository.

xyz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-client-python.git


The following commit(s) were added to refs/heads/main by this push:
     new fe6dc94  Add a version attribute (#81)
fe6dc94 is described below

commit fe6dc9424c72077a9cb6d9aaa9f5bb66ec488914
Author: Eric Hare <[email protected]>
AuthorDate: Fri Jan 13 03:53:03 2023 -0800

    Add a version attribute (#81)
---
 pkg/mac/build-mac-wheels.sh |  2 +-
 pulsar/__about__.py         | 19 +++++++++++++++++++
 pulsar/__init__.py          |  2 ++
 setup.py                    |  9 +++++----
 version.txt                 |  1 -
 5 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/pkg/mac/build-mac-wheels.sh b/pkg/mac/build-mac-wheels.sh
index 22a3b31..917bfec 100755
--- a/pkg/mac/build-mac-wheels.sh
+++ b/pkg/mac/build-mac-wheels.sh
@@ -25,7 +25,7 @@ cd "${ROOT_DIR}"
 
 source pkg/mac/common.sh
 
-PYTHON_CLIENT_VERSION=$(cat version.txt | xargs)
+PYTHON_CLIENT_VERSION=$(grep -v '^#' pulsar/__about__.py | cut -d "=" -f2 | 
sed "s/'//g")
 
 PYTHON_VERSION=$1
 
diff --git a/pulsar/__about__.py b/pulsar/__about__.py
new file mode 100644
index 0000000..a66d247
--- /dev/null
+++ b/pulsar/__about__.py
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+__version__='3.1.0a1'
diff --git a/pulsar/__init__.py b/pulsar/__init__.py
index ec119e4..0ce2e4b 100644
--- a/pulsar/__init__.py
+++ b/pulsar/__init__.py
@@ -48,6 +48,8 @@ import _pulsar
 from _pulsar import Result, CompressionType, ConsumerType, InitialPosition, 
PartitionsRoutingMode, BatchingType, \
     LoggerLevel, BatchReceivePolicy  # noqa: F401
 
+from pulsar.__about__ import __version__
+
 from pulsar.exceptions import *
 
 from pulsar.functions.function import Function
diff --git a/setup.py b/setup.py
index 046b2bb..f2ef81b 100755
--- a/setup.py
+++ b/setup.py
@@ -27,11 +27,12 @@ from distutils.command import build_ext
 
 
 def get_version():
-    # Get the pulsar version from version.txt
     root = path.dirname(path.realpath(__file__))
-    version_file = path.join(root, 'version.txt')
-    with open(version_file) as f:
-        return f.read().strip()
+    version_file = path.join(root, 'pulsar', '__about__.py')
+    version = {}
+    with open(version_file) as fp:
+        exec(fp.read(), version)
+    return version['__version__']
 
 
 def get_name():
diff --git a/version.txt b/version.txt
deleted file mode 100644
index 9034c7b..0000000
--- a/version.txt
+++ /dev/null
@@ -1 +0,0 @@
-3.1.0a1

Reply via email to