Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate running on macOS 12 (and 13, for arm64) #21569

Merged
merged 7 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/notes/2.24.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ We offer [formal sponsorship tiers for companies](https://www.pantsbuild.org/spo
### Deprecations

- **Python 2.7**: As announced in the v2.23.x release series, Pants v2.24 and later are not proactively tested in CI with Python 2.7 since [Python 2.7 is no longer supported by its maintainers as of 1 January 2020](https://www.python.org/doc/sunset-python-2/). While Pants may continue to work with Python 2.7 in the near term, Pants no longer officially supports use of Python 2.7, and, consequently, any remaining support for Python 2.7 may "bit rot" and diverge over time. Contributions to fix issues with Python 2.7 support will continue to be accepted, but will depend on any community contributions and will not constitute continued official support for Python 2.7.
- **macOS verisons**: as announced in the v2.23.x release series, Pants v2.24 is built on macOS 12 and so may not work on versions of macOS 10.15 and 11 (which Apple no longer supports).
- **macOS versions**: Pants v2.24 is the last version that will support macOS 12, as macOS 12 is reaching the end of Apple's support. Future versions of Pants will require macOS 14 or newer (on arm64), and macOS 13 or newer (on x86-64). In addition, as announced in the v2.23.x release series, Pants v2.24 is built on macOS 12 and so may not work on versions of macOS 10.15 and 11 (which Apple no longer supports).


### General
Expand Down
2 changes: 1 addition & 1 deletion pants.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ cache_content_behavior = "fetch"

# Our current macOS 10.15 and 11 infrastructure is working okay, so for now (i.e. 2.24 dev
# releases), we'll just keep building on them:
allow_deprecated_macos_before_12 = true
allow_deprecated_macos_versions = ["10", "11"]

[DEFAULT]
# Tell `scie-pants` to use our `./pants` bootstrap script.
Expand Down
86 changes: 66 additions & 20 deletions src/python/pants/bin/pants_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from pants.option.option_value_container import OptionValueContainer
from pants.option.options_bootstrapper import OptionsBootstrapper
from pants.util.docutil import doc_url
from pants.util.osutil import is_macos_before_12
from pants.util.osutil import get_normalized_arch_name, is_macos_before_12, macos_major_version
from pants.util.strutil import softwrap

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -124,25 +124,7 @@ def run(self, start_time: float) -> ExitCode:
),
)

if (
not global_bootstrap_options.allow_deprecated_macos_before_12
and is_macos_before_12()
):
warn_or_error(
"2.24.0.dev0",
"using Pants on macOS 10.15 - 11",
softwrap(
f"""
Future versions of Pants will only run on macOS 12 and newer, but this machine
appears older ({platform.platform()}).

You can temporarily silence this warning with the
`[GLOBAL].allow_deprecated_macos_before_12` option. If you have questions or
concerns about this, please reach out to us at
{doc_url("community/getting-help")}.
"""
),
)
_validate_macos_version(global_bootstrap_options)

# N.B. We inline imports to speed up the python thin client run, and avoids importing
# engine types until after the runner has had a chance to set __PANTS_BIN_NAME.
Expand All @@ -167,3 +149,67 @@ def run(self, start_time: float) -> ExitCode:
options_bootstrapper=options_bootstrapper,
)
return runner.run(start_time)


# for each architecture, indicate the first Pants version that doesn't support the given version of
# macOS, if it is (soon to be) unsupported:
_MACOS_VERSION_BECOMES_UNSUPPORTED_IN = {
# macos-14 is currently oldest github hosted runner for arm
"arm64": {
10: "2.24.0.dev0",
11: "2.24.0.dev0",
12: "2.25.0.dev0",
13: "2.25.0.dev0",
# adding new values here should update the phrasing of the message below
},
# macos-13 will soon be the oldest (and only) github hosted runner for x86-64 (see https://github.com/pantsbuild/pants/issues/21333)
"x86_64": {
10: "2.24.0.dev0",
11: "2.24.0.dev0",
12: "2.25.0.dev0",
# adding new values here should update the phrasing of the message below
},
}


def _validate_macos_version(global_bootstrap_options: OptionValueContainer) -> None:
"""Check for running on deprecated/unsupported versions of macOS, and similar."""

macos_version = macos_major_version()
if macos_version is None:
# Not macOS, no validation/deprecations required!
return

if global_bootstrap_options.allow_deprecated_macos_before_12 and is_macos_before_12():
# If someone has set this (deprecated) option, and the system is older than macOS 12,
# they'll don't want messages, so just skip.
return

arch_versions = _MACOS_VERSION_BECOMES_UNSUPPORTED_IN[get_normalized_arch_name()]
unsupported_version = arch_versions.get(macos_version)

is_permitted_deprecated_macos_version = (
str(macos_version) in global_bootstrap_options.allow_deprecated_macos_versions
)

if unsupported_version is not None and not is_permitted_deprecated_macos_version:
warn_or_error(
unsupported_version,
"using Pants on older macOS",
softwrap(
f"""
Recent versions of Pants only support macOS 13 and newer (on x86-64) and macOS
14 and newer (on arm64), but this machine appears older ({platform.platform()}
implies macOS version {macos_version}). This version also isn't permitted by your
`[GLOBAL].allow_deprecated_macos_versions` configuration
({global_bootstrap_options.allow_deprecated_macos_versions}).

Either upgrade your operating system(s), or silence this message (and thus opt-in to
potential breakage) by adding "{macos_version}" to the
`[GLOBAL].allow_deprecated_macos_versions` list.

If you have questions or concerns about this, please reach out to us at
{doc_url("community/getting-help")}.
"""
),
)
16 changes: 16 additions & 0 deletions src/python/pants/option/global_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1801,6 +1801,22 @@ def file_downloads_max_attempts(self) -> int:
Silence warnings about running Pants on macOS 10.15 - 11. In future versions, Pants will
only be supported on macOS 12 and newer.

If you have questions or concerns about this, please reach out to us at
{doc_url("community/getting-help")}.
"""
),
removal_version="2.26.0.dev0",
removal_hint='Upgrade your operating system or write `allow_deprecated_macos_versions = ["10", "11"]` instead.',
)

allow_deprecated_macos_versions = StrListOption(
default=[],
advanced=True,
help=softwrap(
f"""
Silence warnings/errors about running Pants on these versions of macOS. Pants only supports
recent versions of macOS. You can try running on older versions, but it may or may not work.

If you have questions or concerns about this, please reach out to us at
{doc_url("community/getting-help")}.
"""
Expand Down
6 changes: 3 additions & 3 deletions src/python/pants/util/osutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def get_normalized_arch_name() -> str:
return normalize_arch_name(get_arch_name())


def _macos_major_version() -> None | int:
def macos_major_version() -> None | int:
if not hasattr(platform, "mac_ver"):
return None

Expand All @@ -108,12 +108,12 @@ def _macos_major_version() -> None | int:


def is_macos_big_sur() -> bool:
return _macos_major_version() == 11
return macos_major_version() == 11


def is_macos_before_12() -> bool:
"""MacOS 11 support ended Sep 2023."""
version = _macos_major_version()
version = macos_major_version()
return version is not None and version < 12


Expand Down
Loading