Skip to content

Commit 9564ce0

Browse files
carsongeeavishalom
authored andcommitted
Moved package information to __about__.py to avoid dependency issues (#134)
1 parent 328036c commit 9564ce0

File tree

4 files changed

+39
-18
lines changed

4 files changed

+39
-18
lines changed

firebase_admin/__about__.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2017 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""About information (version, etc) for Firebase Admin SDK."""
16+
17+
__version__ = '2.9.0'
18+
__title__ = 'firebase_admin'
19+
__author__ = 'Firebase'
20+
__license__ = 'Apache License 2.0'
21+
__url__ = 'https://firebase.google.com/docs/admin/setup/'

firebase_admin/__init__.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,9 @@
2121
import six
2222

2323
from firebase_admin import credentials
24+
from firebase_admin.__about__ import __version__
2425

2526

26-
# Declaring module version as per https://www.python.org/dev/peps/pep-0396/#specification
27-
# Update this accordingly for each release.
28-
__version__ = '2.9.0'
29-
3027
_apps = {}
3128
_apps_lock = threading.RLock()
3229
_clock = datetime.datetime.utcnow

scripts/prepare_release.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ if ! parseVersion "$VERSION"; then
5555
exit 1
5656
fi
5757

58-
CUR_VERSION=$(grep "^__version__ =" ../firebase_admin/__init__.py | awk '{print $3}' | sed "s/'//g")
58+
CUR_VERSION=$(grep "^__version__ =" ../firebase_admin/__about__.py | awk '{print $3}' | sed "s/'//g")
5959
if [ -z "$CUR_VERSION" ]; then
60-
echo "[ERROR] Failed to find the current version. Check firebase_admin/__init__.py for version declaration."
60+
echo "[ERROR] Failed to find the current version. Check firebase_admin/__about__.py for version declaration."
6161
exit 1
6262
fi
6363
if ! parseVersion "$CUR_VERSION"; then
@@ -119,12 +119,12 @@ fi
119119
##################################
120120

121121
HOST=$(uname)
122-
echo "[INFO] Updating __init__.py and CHANGELOG.md"
122+
echo "[INFO] Updating __about__.py and CHANGELOG.md"
123123
if [ $HOST == "Darwin" ]; then
124-
sed -i "" -e "s/__version__ = '$CUR_VERSION'/__version__ = '$VERSION'/" "../firebase_admin/__init__.py"
124+
sed -i "" -e "s/__version__ = '$CUR_VERSION'/__version__ = '$VERSION'/" "../firebase_admin/__about__.py"
125125
sed -i "" -e "1 s/# Unreleased//" "../CHANGELOG.md"
126126
else
127-
sed -i -e "s/__version__ = '$CUR_VERSION'/__version__ = '$VERSION'/" "../firebase_admin/__init__.py"
127+
sed -i -e "s/__version__ = '$CUR_VERSION'/__version__ = '$VERSION'/" "../firebase_admin/__about__.py"
128128
sed -i -e "1 s/# Unreleased//" "../CHANGELOG.md"
129129
fi
130130

setup.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@
2121
from setuptools import find_packages
2222
from setuptools import setup
2323

24-
import firebase_admin
25-
2624

2725
if sys.version_info < (2, 7):
2826
print('firebase_admin requires python2 version >= 2.7 or python3.', file=sys.stderr)
2927
sys.exit(1)
3028

29+
# Read in the package meta data per recommendations from:
30+
# https://packaging.python.org/guides/single-sourcing-package-version/
31+
about_path = path.join(path.dirname(path.abspath(__file__)), 'firebase_admin', '__about__.py')
32+
about = {}
33+
with open(about_path) as fp:
34+
exec(fp.read(), about) # pylint: disable=exec-used
35+
3136

3237
long_description = ('The Firebase Admin Python SDK enables server-side (backend) Python developers '
3338
'to integrate Firebase into their services and applications.')
@@ -43,16 +48,14 @@
4348
':python_version<"3.4"': ('enum34>=1.0.4',),
4449
}
4550

46-
version = firebase_admin.__version__
47-
4851
setup(
49-
name='firebase_admin',
50-
version=version,
52+
name=about['__title__'],
53+
version=about['__version__'],
5154
description='Firebase Admin Python SDK',
5255
long_description=long_description,
53-
url='https://firebase.google.com/docs/admin/setup/',
54-
author='Firebase',
55-
license='Apache License 2.0',
56+
url=about['__url__'],
57+
author=about['__author__'],
58+
license=about['__license__'],
5659
keywords='firebase cloud development',
5760
extras_require=extras_require,
5861
install_requires=install_requires,

0 commit comments

Comments
 (0)