Skip to content

Commit c305b8b

Browse files
committed
wtf
1 parent b20500d commit c305b8b

File tree

4 files changed

+14
-21
lines changed

4 files changed

+14
-21
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ GitHub = "https://github.com/pytorch/torchcodec"
1414
Documentation = "https://pytorch.org/torchcodec/stable/index.html"
1515

1616
[tool.setuptools.dynamic]
17-
version = {attr = "torchcodec.__version__"}
17+
version = {file = "version.txt"}
1818

1919
[build-system]
2020
requires = ["setuptools>=61.0"]

setup.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,16 @@ def copy_extensions_to_source(self):
173173

174174

175175
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:
176+
if version := 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+
with open(_ROOT_DIR / "version.txt", "w") as f:
182+
f.write(f"{version}")
183+
else:
182184
with open(_ROOT_DIR / "version.txt") as f:
183185
version = f.readline().strip()
184-
185186
try:
186187
sha = (
187188
subprocess.check_output(
@@ -194,16 +195,12 @@ def get_version():
194195
except Exception:
195196
print("INFO: Didn't find sha. Is this a git repo?")
196197

197-
return version
198-
198+
f.write(f"__version__ = '{version}\n")
199199

200-
def write_version_file(version):
201-
with open(_ROOT_DIR / "src/torchcodec/version.py", "w") as f:
202-
f.write(f"def _get_version(): return '{version}'\n")
200+
return version
203201

204202

205203
version = get_version()
206-
write_version_file(version)
207204

208205
setup(
209206
version=version,

src/torchcodec/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,4 @@
99
from ._frame import Frame, FrameBatch # usort:skip # noqa
1010
from . import decoders, samplers # noqa
1111

12-
from .version import _get_version
13-
14-
try:
15-
__version__ = _get_version()
16-
except Exception:
17-
pass
12+
from .version import __version__

test/test_version.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33

44
def test_version():
5-
assert torchcodec.__version__ != "0.0.0"
5+
assert "+cpu" not in torchcodec.__version__
6+
assert "+cu" not in torchcodec.__version__

0 commit comments

Comments
 (0)