Skip to content

Commit 61d2185

Browse files
committed
Single-sourcing the package version
1 parent d42082a commit 61d2185

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

scaleapi/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "1.0.2"

setup.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22
import warnings
3+
import os.path
34

45
try:
56
from setuptools import setup
@@ -25,10 +26,23 @@
2526
install_requires.append('idna')
2627
install_requires.append('requests[security]')
2728

29+
def read(rel_path):
30+
here = os.path.abspath(os.path.dirname(__file__))
31+
with open(os.path.join(here, rel_path), 'r') as fp:
32+
return fp.read()
33+
34+
def get_version(rel_path):
35+
for line in read(rel_path).splitlines():
36+
if line.startswith('__version__'):
37+
delim = '"' if '"' in line else "'"
38+
return line.split(delim)[1]
39+
else:
40+
raise RuntimeError("Unable to find a valid __version__ string in %s." % rel_path)
41+
2842
setup(
2943
name='scaleapi',
3044
packages=['scaleapi'],
31-
version='1.0.2',
45+
version=get_version("scaleapi/_version.py"),
3246
description='The official Python client library for Scale AI, the Data Platform for AI',
3347
author='Scale AI',
3448
author_email='support@scale.com',

0 commit comments

Comments
 (0)