Skip to content

Commit 893c9cc

Browse files
gh-102362: Fix macOS version number in result of sysconfig.get_platform() (GH-112942)
Change _osx_support.get_platform_osx() to make sure that the version number in the result includes at least a major and minor version (e.g. 14.2) even if MACOSX_DEPLOYMENT_TARGET is set to just a major version (e.g. 14). This matches the versions expected by pip when selecting appropriate wheels for installation.
1 parent 4cfce3a commit 893c9cc

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Lib/_osx_support.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,11 @@ def get_platform_osx(_config_vars, osname, release, machine):
507507
# MACOSX_DEPLOYMENT_TARGET.
508508

509509
macver = _config_vars.get('MACOSX_DEPLOYMENT_TARGET', '')
510+
if macver and '.' not in macver:
511+
# Ensure that the version includes at least a major
512+
# and minor version, even if MACOSX_DEPLOYMENT_TARGET
513+
# is set to a single-label version like "14".
514+
macver += '.0'
510515
macrelease = _get_system_version() or macver
511516
macver = macver or macrelease
512517

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Make sure the result of :func:`sysconfig.get_plaform` includes at least a
2+
major and minor versions, even if ``MACOSX_DEPLOYMENT_TARGET`` is set to
3+
only a major version during build to match the format expected by pip.

0 commit comments

Comments
 (0)