Skip to content

Commit

Permalink
fix: move version module to
Browse files Browse the repository at this point in the history
  • Loading branch information
parthea committed Nov 14, 2023
1 parent cd82ea1 commit 062de95
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 1 addition & 3 deletions django_spanner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# do that.
from uuid import uuid4

import pkg_resources
from google.cloud.spanner_v1 import JsonObject
from django.db.models.fields import (
NOT_PROVIDED,
Expand All @@ -24,6 +23,7 @@
from .functions import register_functions
from .lookups import register_lookups
from .utils import check_django_compatability
from .version import __version__

# Monkey-patch google.DatetimeWithNanoseconds's __eq__ compare against
# datetime.datetime.
Expand All @@ -41,8 +41,6 @@
)
from django.db.models import JSONField

__version__ = pkg_resources.get_distribution("django-google-spanner").version

USE_EMULATOR = os.getenv("SPANNER_EMULATOR_HOST") is not None

# Only active LTS django versions (2.2.*, 3.2.*) are supported by this library right now.
Expand Down
File renamed without changes.
19 changes: 12 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import io
import os
import re

from setuptools import find_packages, setup

Expand All @@ -27,16 +28,20 @@
}

BASE_DIR = os.path.dirname(__file__)
VERSION_FILENAME = os.path.join(BASE_DIR, "version.py")
PACKAGE_INFO = {}
with open(VERSION_FILENAME) as f:
exec(f.read(), PACKAGE_INFO)
version = PACKAGE_INFO["__version__"]

# Setup boilerplate below this line.

package_root = os.path.abspath(BASE_DIR)

version = None

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

# Setup boilerplate below this line.

readme_filename = os.path.join(package_root, "README.rst")
with io.open(readme_filename, encoding="utf-8") as readme_file:
readme = readme_file.read()
Expand Down

0 comments on commit 062de95

Please sign in to comment.