File tree Expand file tree Collapse file tree 4 files changed +14
-21
lines changed
Expand file tree Collapse file tree 4 files changed +14
-21
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ GitHub = "https://github.com/pytorch/torchcodec"
1414Documentation = " 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 ]
2020requires = [" setuptools>=61.0" ]
Original file line number Diff line number Diff line change @@ -173,15 +173,16 @@ def copy_extensions_to_source(self):
173173
174174
175175def 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
205203version = get_version ()
206- write_version_file (version )
207204
208205setup (
209206 version = version ,
Original file line number Diff line number Diff line change 99from ._frame import Frame , FrameBatch # usort:skip # noqa
1010from . 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__
Original file line number Diff line number Diff line change 22
33
44def test_version ():
5- assert torchcodec .__version__ != "0.0.0"
5+ assert "+cpu" not in torchcodec .__version__
6+ assert "+cu" not in torchcodec .__version__
You can’t perform that action at this time.
0 commit comments