Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for google.cloud.ndb.__version__ #929

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
feat: add support for google.cloud.ndb.__version__
  • Loading branch information
parthea committed Nov 24, 2023
commit 539e4f10bf59f1c755d15944de7dd40137cafada
5 changes: 3 additions & 2 deletions google/cloud/ndb/__init__.py
Expand Up @@ -21,9 +21,9 @@
.. autodata:: __all__
"""

from pkg_resources import get_distribution
from google.cloud.ndb import version

__version__ = get_distribution("google-cloud-ndb").version
__version__ = version.__version__

from google.cloud.ndb.client import Client
from google.cloud.ndb.context import AutoBatcher
Expand Down Expand Up @@ -131,6 +131,7 @@
from google.cloud.ndb._transaction import non_transactional

__all__ = [
"__version__",
"AutoBatcher",
"Client",
"Context",
Expand Down
15 changes: 15 additions & 0 deletions google/cloud/ndb/version.py
@@ -0,0 +1,15 @@
# Copyright 2023 Google LLC
#
# 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.
#
__version__ = "2.2.2"
12 changes: 11 additions & 1 deletion setup.py
Expand Up @@ -14,10 +14,20 @@

import io
import os
import re

import setuptools


PACKAGE_ROOT = os.path.abspath(os.path.dirname(__file__))

version = None

with open(os.path.join(PACKAGE_ROOT, "google/cloud/ndb/version.py")) as fp:
version_candidates = re.findall(r"(?<=\")\d+.\d+.\d+(?=\")", fp.read())
assert len(version_candidates) == 1
version = version_candidates[0]

def main():
package_root = os.path.abspath(os.path.dirname(__file__))
readme_filename = os.path.join(package_root, "README.md")
Expand All @@ -36,7 +46,7 @@ def main():

setuptools.setup(
name="google-cloud-ndb",
version = "2.2.2",
version = version,
description="NDB library for Google Cloud Datastore",
long_description=readme,
long_description_content_type="text/markdown",
Expand Down