Skip to content

Commit 1b7c835

Browse files
authored
Add version API to keras_nlp (keras-team#1324)
* Add `keras_nlp.version() API` * Correct version path * Export to keras_nlp * Format * Remove __init__ version check
1 parent 1d3b520 commit 1b7c835

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

keras_nlp/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,4 @@
2626
from keras_nlp import samplers
2727
from keras_nlp import tokenizers
2828
from keras_nlp import utils
29-
30-
# This is the global source of truth for the version number.
31-
__version__ = "0.7.0"
29+
from keras_nlp.version import __version__

keras_nlp/version.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2023 The KerasNLP Authors
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+
# https://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+
from keras_nlp.api_export import keras_nlp_export
16+
17+
# Unique source of truth for the version number.
18+
__version__ = "0.7.0"
19+
20+
21+
@keras_nlp_export("keras_nlp.version")
22+
def version():
23+
return __version__

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def get_version(rel_path):
3737

3838
HERE = pathlib.Path(__file__).parent
3939
README = (HERE / "README.md").read_text()
40+
VERSION = get_version("keras_nlp/version.py")
4041

4142
setup(
4243
name="keras-nlp",
@@ -45,7 +46,7 @@ def get_version(rel_path):
4546
),
4647
long_description=README,
4748
long_description_content_type="text/markdown",
48-
version=get_version("keras_nlp/__init__.py"),
49+
version=VERSION,
4950
url="https://github.com/keras-team/keras-nlp",
5051
author="Keras team",
5152
author_email="[email protected]",

0 commit comments

Comments
 (0)