Skip to content

Commit f0025c3

Browse files
committed
Fix?
1 parent c63a17a commit f0025c3

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

setup.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,13 @@ def copy_extensions_to_source(self):
172172
fake_extension = Extension(name="FAKE_NAME", sources=[])
173173

174174

175-
def get_and_write_version():
176-
if os.getenv("BUILD_VERSION"):
177-
# BUILD_VERSION is set by the `test-infra` build jobs. It typically is
178-
# the content of `version.txt` plus some suffix like "+cpu" or "+cu112".
179-
# See
180-
# https://github.com/pytorch/test-infra/blob/61e6da7a6557152eb9879e461a26ad667c15f0fd/tools/pkg-helpers/pytorch_pkg_helpers/version.py#L113
181-
version = os.getenv("BUILD_VERSION")
182-
else:
175+
def get_version():
176+
# BUILD_VERSION is set by the `test-infra` build jobs. It typically is
177+
# the content of `version.txt` plus some suffix like "+cpu" or "+cu112".
178+
# See
179+
# https://github.com/pytorch/test-infra/blob/61e6da7a6557152eb9879e461a26ad667c15f0fd/tools/pkg-helpers/pytorch_pkg_helpers/version.py#L113
180+
version = os.getenv("BUILD_VERSION")
181+
if not version:
183182
with open(_ROOT_DIR / "version.txt") as f:
184183
version = f.readline().strip()
185184

@@ -195,14 +194,19 @@ def get_and_write_version():
195194
except Exception:
196195
print("INFO: Didn't find sha. Is this a git repo?")
197196

197+
return version
198+
199+
200+
def write_version_file(version):
198201
with open(_ROOT_DIR / "src/torchcodec/version.py", "w") as f:
199202
f.write(f"__version__ = '{version}'\n")
200203

201-
return version
202204

205+
version = get_version()
206+
write_version_file(version)
203207

204208
setup(
205-
version=get_and_write_version(),
209+
version=version,
206210
ext_modules=[fake_extension],
207211
cmdclass={"build_ext": CMakeBuild},
208212
)

0 commit comments

Comments
 (0)