Fix license check for setuptools>=77 (#151158)

Fixes #151157

See issue for more information
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151158
Approved by: https://github.com/malfet
This commit is contained in:
Yichen Yan 2025-04-12 13:41:12 +00:00 committed by PyTorch MergeBot
parent 7dd2ed1197
commit 5b16a0704e

View File

@ -45,7 +45,11 @@ class TestLicense(TestCase):
'Found too many "torch-*dist-info" directories '
f'in "{site_packages}, expected only one'
)
with open(os.path.join(os.path.join(distinfo[0], "LICENSE"))) as fid:
# setuptools renamed *dist-info/LICENSE to *dist-info/licenses/LICENSE sicne 77.0
license_file = os.path.join(distinfo[0], "licenses", "LICENSE")
if not os.path.exists(license_file):
license_file = os.path.join(distinfo[0], "LICENSE")
with open(license_file) as fid:
txt = fid.read()
self.assertTrue(starting_txt in txt)