Skip to content

Commit 92f1794

Browse files
authored
[tvOS] Replace mac_toolchain pkg_resources fix with upstream one (#7082)
This PR essentially replaces the fix from #7061 with the upstream one that does not require manual installation of extra Python packages (and also means one less conflict to deal with in the rebases). Installing extra dependencies gets extra confusing when one also has Python from e.g. Homebrew in addition to the system version: in this case it is very likely that `gn.py` will be invoked with Homebrew's Python while `gn` itself will invoke the system-wide `python3` binary, so even if one does install the `packaging` module it is possible that it will still not be picked up by the right Python interpreter. Bug: 442908995 --- Original commit description: mac_toolchain.py used pkg_resources.parse_version to parse and ultimately compare version numbers. pkg_resources is deprecated per https://setuptools.pypa.io/en/latest/pkg_resources.html and pypa/setuptools a1aeda391a0c (2023-03-05), in setuptools 67.5.0. pkg_resources.parse_version’s implementation has been packaging.version.Version since pypa/setuptools db23abf7ef84 (2020-12-20), and when available, since pypa/setuptools 9382fa0c05e5 (2014-09-25). However, pkg_resources as installed does’t always depend directly on the packaging.version module, it often depends on a pkg_resources._vendor.packaging.version snapshot. This means that the historical presence of pkg_resources doesn’t necessarily indicate that packaging.version will be available by that name. Rather than relying on an external module for version parsing, just split the version string on dots. It appears that these version strings only ever take the form 15.0 (for Xcode 15.0), and don’t ever contain letters or other confounding characters. Change-Id: Iea7260629030503f0f90ce33da8816e0da9faaca Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4936301 Cr-Commit-Position: refs/heads/main@{#1209652}
1 parent c6e661e commit 92f1794

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

build/mac_toolchain.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import argparse
2222
import os
23-
from packaging import version
2423
import platform
2524
import plistlib
2625
import shutil
@@ -156,8 +155,8 @@ def InstallXcodeBinaries():
156155
current_license_plist = LoadPList(current_license_path)
157156
xcode_version = current_license_plist.get(
158157
'IDEXcodeVersionForAgreedToGMLicense')
159-
if (xcode_version is not None and version.parse(xcode_version)
160-
>= version.parse(cipd_xcode_version)):
158+
if (xcode_version is not None
159+
and xcode_version.split('.') >= cipd_xcode_version.split('.')):
161160
should_overwrite_license = False
162161

163162
if not should_overwrite_license:

0 commit comments

Comments
 (0)