From 0ffcb39b2eb253e94bd5bc596880b23f9fbafc7c Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Tue, 25 Feb 2025 10:44:50 +0800 Subject: [PATCH 1/2] Support specifying a torch range --- setup.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index aeb0766c474..5310f91be62 100644 --- a/setup.py +++ b/setup.py @@ -96,8 +96,10 @@ def get_dist(pkgname): return None pytorch_dep = os.getenv("TORCH_PACKAGE_NAME", "torch") - if os.getenv("PYTORCH_VERSION"): - pytorch_dep += "==" + os.getenv("PYTORCH_VERSION") + if version_pin := os.getenv("PYTORCH_VERSION"): + pytorch_dep += "==" + version_pin + elif (version_pin_ge := os.getenv("PYTORCH_VERSION_GE")) and (version_pin_lt := os.getenv("PYTORCH_VERSION_LT")): + pytorch_dep += f">={version_pin_ge},<{version_pin_lt}" requirements = [ "numpy", From c8b2ccf5b74cf4ad36520852a6205ea5641e4ff4 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Wed, 26 Feb 2025 09:52:48 +0000 Subject: [PATCH 2/2] Add comment --- setup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup.py b/setup.py index 5310f91be62..a42aef69725 100644 --- a/setup.py +++ b/setup.py @@ -99,6 +99,10 @@ def get_dist(pkgname): if version_pin := os.getenv("PYTORCH_VERSION"): pytorch_dep += "==" + version_pin elif (version_pin_ge := os.getenv("PYTORCH_VERSION_GE")) and (version_pin_lt := os.getenv("PYTORCH_VERSION_LT")): + # This branch and the associated env vars exist to help third-party + # builds like in https://github.com/pytorch/vision/pull/8936. This is + # supported on a best-effort basis, we don't guarantee that this won't + # eventually break (and we don't test it.) pytorch_dep += f">={version_pin_ge},<{version_pin_lt}" requirements = [