Skip to content

Commit 5d88412

Browse files
authored
add PEP-396 version attribute (#435)
1 parent c4053ff commit 5d88412

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

setup.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,27 @@
1212
# language governing permissions and limitations under the License.
1313
from __future__ import absolute_import
1414

15-
from glob import glob
1615
import os
16+
import re
17+
from glob import glob
1718

1819
from setuptools import setup, find_packages
1920

2021

22+
def get_version():
23+
root = os.path.dirname(__file__)
24+
version_re = re.compile(r'''__version__ = ['"]([0-9.]+)['"]''')
25+
26+
init = read(os.path.join(root, 'src/sagemaker', '__init__.py'))
27+
return version_re.search(init).group(1)
28+
29+
2130
def read(fname):
2231
return open(os.path.join(os.path.dirname(__file__), fname)).read()
2332

2433

2534
setup(name="sagemaker",
26-
version="1.11.3",
35+
version=get_version(),
2736
description="Open source library for training and deploying models on Amazon SageMaker.",
2837
packages=find_packages('src'),
2938
package_dir={'': 'src'},
@@ -44,7 +53,8 @@ def read(fname):
4453
],
4554

4655
# Declare minimal set for installation
47-
install_requires=['boto3>=1.4.8', 'numpy>=1.9.0', 'protobuf>=3.1', 'scipy>=0.19.0', 'urllib3 >=1.21, <1.23',
56+
install_requires=['boto3>=1.4.8', 'numpy>=1.9.0', 'protobuf>=3.1', 'scipy>=0.19.0',
57+
'urllib3 >=1.21, <1.23',
4858
'PyYAML>=3.2', 'protobuf3-to-dict>=0.1.5', 'docker-compose>=1.21.0'],
4959

5060
extras_require={

src/sagemaker/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@
3434
from sagemaker.session import production_variant # noqa: F401
3535
from sagemaker.session import s3_input # noqa: F401
3636
from sagemaker.session import get_execution_role # noqa: F401
37+
38+
__version__ = '1.11.3'

tests/unit/test_init.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
13+
from __future__ import absolute_import
14+
15+
import sagemaker
16+
17+
18+
def test_version():
19+
assert sagemaker.__version__

0 commit comments

Comments
 (0)