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

fix: move version module to django_spanner.version #844

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 1 addition & 3 deletions django_spanner/__init__.py
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.
17 changes: 10 additions & 7 deletions setup.py
Expand Up @@ -6,6 +6,7 @@

import io
import os
import re

from setuptools import find_packages, setup

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

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