1313import sys
1414
1515
16- def python_is_compatible ():
17- # Scrape the version range from pyproject.toml, which should be in the current directory.
18- version_specifier = None
19- with open ("pyproject.toml" , "r" ) as file :
20- for line in file :
21- if line .startswith ("requires-python" ):
22- match = re .search (r'"([^"]*)"' , line )
23- if match :
24- version_specifier = match .group (1 )
25- break
26-
27- if not version_specifier :
28- print (
29- "WARNING: Skipping python version check: version range not found" ,
30- file = sys .stderr ,
31- )
32- return False
33-
34- # Install the packaging module if necessary.
35- try :
36- import packaging
37- except ImportError :
38- subprocess .run (
39- [sys .executable , "-m" , "pip" , "install" , "packaging" ], check = True
40- )
41- # Compare the current python version to the range in version_specifier. Exits
42- # with status 1 if the version is not compatible, or with status 0 if the
43- # version is compatible or the logic itself fails.
44- try :
45- import packaging .specifiers
46- import packaging .version
47-
48- python_version = packaging .version .parse (platform .python_version ())
49- version_range = packaging .specifiers .SpecifierSet (version_specifier )
50- if python_version not in version_range :
51- print (
52- f'ERROR: ExecuTorch does not support python version { python_version } : must satisfy "{ version_specifier } "' ,
53- file = sys .stderr ,
54- )
55- return False
56- except Exception as e :
57- print (f"WARNING: Skipping python version check: { e } " , file = sys .stderr )
58- return True
59-
60-
61- # The pip repository that hosts torch packages.
62- TORCH_URL = "https://download.pytorch.org/whl/test/cpu"
16+ from torch_pin import NIGHTLY_VERSION , TORCH_VERSION
17+
18+ # The pip repository that hosts nightly torch packages.
19+ # This will be dynamically set based on CUDA availability and CUDA backend enabled/disabled.
20+ TORCH_NIGHTLY_URL_BASE = "https://download.pytorch.org/whl/nightly"
6321
6422
6523# Since ExecuTorch often uses main-branch features of pytorch, only the nightly
@@ -71,7 +29,9 @@ def python_is_compatible():
7129#
7230# NOTE: If you're changing, make the corresponding change in .ci/docker/ci_commit_pins/pytorch.txt
7331# by picking the hash from the same date in https://hud.pytorch.org/hud/pytorch/pytorch/nightly/
74- NIGHTLY_VERSION = "dev20250906"
32+ #
33+ # NOTE: If you're changing, make the corresponding supported CUDA versions in
34+ # SUPPORTED_CUDA_VERSIONS above if needed.
7535
7636
7737def install_requirements (use_pytorch_nightly ):
@@ -89,7 +49,11 @@ def install_requirements(use_pytorch_nightly):
8949 # Setting use_pytorch_nightly to false to test the pinned PyTorch commit. Note
9050 # that we don't need to set any version number there because they have already
9151 # been installed on CI before this step, so pip won't reinstall them
92- "torch==2.9.0" if use_pytorch_nightly else "torch" ,
52+ (
53+ f"torch=={ TORCH_VERSION } .{ NIGHTLY_VERSION } "
54+ if use_pytorch_nightly
55+ else "torch"
56+ ),
9357 ]
9458
9559 # Install the requirements for core ExecuTorch package.
0 commit comments