Skip to content

Commit

Permalink
feat: add support for google.cloud.ndb.__version__
Browse files Browse the repository at this point in the history
  • Loading branch information
parthea committed Nov 24, 2023
1 parent 182fe4e commit e2a03d8
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
5 changes: 2 additions & 3 deletions google/cloud/ndb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
.. autodata:: __all__
"""

from pkg_resources import get_distribution

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

from google.cloud.ndb.client import Client
from google.cloud.ndb.context import AutoBatcher
Expand Down Expand Up @@ -129,8 +126,10 @@
from google.cloud.ndb._transaction import transactional_async
from google.cloud.ndb._transaction import transactional_tasklet
from google.cloud.ndb._transaction import non_transactional
from google.cloud.ndb.version import __version__

__all__ = [
"__version__",
"AutoBatcher",
"Client",
"Context",
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/ndb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
grpc as datastore_grpc,
)

from google.cloud.ndb import __version__
from google.cloud.ndb.version import __version__
from google.cloud.ndb import context as context_module
from google.cloud.ndb import key as key_module

Expand Down
15 changes: 15 additions & 0 deletions google/cloud/ndb/version.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion tests/unit/test__datastore_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from google.cloud.ndb import model
from google.cloud.ndb import _options
from google.cloud.ndb import tasklets
from google.cloud.ndb import __version__
from google.cloud.ndb.version import __version__

from . import utils

Expand Down

0 comments on commit e2a03d8

Please sign in to comment.