Skip to content

Commit ae04aee

Browse files
AbishekSmeta-codesync[bot]
authored andcommitted
Have versioning be in a single place for some cases (meta-pytorch#1146)
Summary: Pull Request resolved: meta-pytorch#1146 Goal here is to have one single place for version that will be manully updated. Differential Revision: D83858764
1 parent 5a35922 commit ae04aee

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

setup.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,12 @@
55
# This source code is licensed under the BSD-style license found in the
66
# LICENSE file in the root directory of this source tree.
77

8-
import os
9-
import re
108
import sys
119
from datetime import date
1210

1311
from setuptools import find_packages, setup
1412

15-
16-
def get_version():
17-
# get version string from version.py
18-
# TODO: ideally the version.py should be generated when setup is run
19-
version_file = os.path.join(os.path.dirname(__file__), "torchx/version.py")
20-
version_regex = r"__version__ = ['\"]([^'\"]*)['\"]"
21-
with open(version_file, "r") as f:
22-
version = re.search(version_regex, f.read(), re.M).group(1)
23-
return version
13+
from torchx._version import BASE_VERSION
2414

2515

2616
def get_nightly_version():
@@ -49,7 +39,7 @@ def get_nightly_version():
4939
with open("dev-requirements.txt") as f:
5040
dev_reqs = f.read()
5141

52-
version = get_nightly_version() if is_nightly else get_version()
42+
version = get_nightly_version() if is_nightly else BASE_VERSION
5343
print(f"-- {name} building version: {version}")
5444

5545
setup(

torchx/_version.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# pyre-strict
8+
BASE_VERSION = "0.8.0dev0"

torchx/version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env python3
21
# Copyright (c) Meta Platforms, Inc. and affiliates.
32
# All rights reserved.
43
#
@@ -7,6 +6,7 @@
76

87
# pyre-strict
98

9+
from torchx._version import BASE_VERSION
1010
from torchx.util.entrypoints import load
1111

1212
# Follows PEP-0440 version scheme guidelines
@@ -18,7 +18,7 @@
1818
# 0.1.0bN # Beta release
1919
# 0.1.0rcN # Release Candidate
2020
# 0.1.0 # Final release
21-
__version__ = "0.8.0dev0"
21+
__version__: str = BASE_VERSION
2222

2323

2424
# Use the github container registry images corresponding to the current package

0 commit comments

Comments
 (0)