28
28
from setuptools .command .develop import develop
29
29
from setuptools .command .sdist import sdist
30
30
31
-
32
- def execfile (fname ):
33
- with open (fname ) as f :
34
- return f .readline ().rstrip ()
35
-
36
-
37
31
repo_root = os .path .dirname (os .path .abspath (__file__ ))
38
- version_file_path = os .path .join (repo_root , "../VERSION" )
39
- version = execfile (version_file_path )
40
32
41
33
42
34
class BuildBuiltin (Command ):
@@ -146,9 +138,58 @@ def parsed_dev_reqs():
146
138
return fp .read ().splitlines ()
147
139
148
140
141
+ def parse_version (root , ** kwargs ):
142
+ """
143
+ Parse function for setuptools_scm that first tries to read '../VERSION' file
144
+ to get a version number.
145
+ """
146
+ from setuptools_scm .git import parse
147
+ from setuptools_scm .version import meta
148
+
149
+ version_file = os .path .join (repo_root , ".." , "VERSION" )
150
+ if os .path .isfile (version_file ):
151
+ with open (version_file , "r" , encoding = "utf-8" ) as fp :
152
+ return meta (fp .read ().strip ())
153
+ return parse (root , ** kwargs )
154
+
155
+
156
+ version_template = """#!/usr/bin/env python3
157
+ # -*- coding: utf-8 -*-
158
+ #
159
+ # Copyright 2020 Alibaba Group Holding Limited. All Rights Reserved.
160
+ #
161
+ # Licensed under the Apache License, Version 2.0 (the "License");
162
+ # you may not use this file except in compliance with the License.
163
+ # You may obtain a copy of the License at
164
+ #
165
+ # http://www.apache.org/licenses/LICENSE-2.0
166
+ #
167
+ # Unless required by applicable law or agreed to in writing, software
168
+ # distributed under the License is distributed on an "AS IS" BASIS,
169
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
170
+ # See the License for the specific language governing permissions and
171
+ # limitations under the License.
172
+
173
+ import os
174
+
175
+ version_file_path = os.path.join(
176
+ os.path.dirname(os.path.abspath(__file__)), "..", "..", "VERSION"
177
+ )
178
+
179
+ if os.path.isfile(version_file_path):
180
+ with open(version_file_path, "r", encoding="utf-8") as fp:
181
+ __version__ = fp.read().strip()
182
+ __version_tuple__ = (int(v) for v in __version__.split("."))
183
+ else:
184
+ __version__ = "{version}"
185
+ __version_tuple__ = {version_tuple}
186
+
187
+ del version_file_path
188
+ """
189
+
190
+
149
191
setup (
150
192
name = "gscoordinator" ,
151
- version = version ,
152
193
description = "" ,
153
194
long_description = long_description ,
154
195
long_description_content_type = "text/markdown" ,
@@ -172,6 +213,13 @@ def parsed_dev_reqs():
172
213
"Programming Language :: Python :: 3.9" ,
173
214
],
174
215
keywords = "GRAPE, Graph Computations" ,
216
+ use_scm_version = {
217
+ "root" : repo_root ,
218
+ "parse" : parse_version ,
219
+ "write_to" : os .path .join (repo_root , "gscoordinator/version.py" ),
220
+ "write_to_template" : version_template ,
221
+ },
222
+ setup_requires = ["setuptools_scm" , "grpcio" , "grpcio-tools" ],
175
223
package_dir = {"." : "." },
176
224
packages = find_packages ("." ),
177
225
package_data = {
0 commit comments