From 3e733e4342414a4bc668984f6c2816ddc0217bee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20La=C3=ADns?= Date: Wed, 28 Sep 2022 23:02:12 +0100 Subject: [PATCH 1/2] BUG: honor MACOSX_DEPLOYMENT_TARGET MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Filipe Laíns --- mesonpy/__init__.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/mesonpy/__init__.py b/mesonpy/__init__.py index 896ac45a6..d55e513ed 100644 --- a/mesonpy/__init__.py +++ b/mesonpy/__init__.py @@ -261,15 +261,25 @@ def platform_tag(self) -> str: # fix it later if there are system dependencies (eg. replace it with a manylinux tag) platform_ = sysconfig.get_platform() parts = platform_.split('-') - if parts[0] == 'macosx' and parts[1] in ('11', '12'): - # Workaround for bug where pypa/packaging does not consider macOS - # tags without minor versions valid. Some Python flavors (Homebrew - # for example) on macOS started to do this in version 11, and - # pypa/packaging should handle things correctly from version 13 and - # forward, so we will add a 0 minor version to MacOS 11 and 12. - # https://github.com/FFY00/meson-python/issues/91 - # https://github.com/pypa/packaging/issues/578 - parts[1] += '.0' + if parts[0] == 'macosx': + target = os.environ.get('MACOSX_DEPLOYMENT_TARGET') + if target: + print( + '{yellow}MACOSX_DEPLOYMENT_TARGET is set so we are setting the ' + 'platform tag to {target}{reset}'.format(target=target, **_STYLES) + ) + parts[1] = target + + if parts[1] in ('11', '12'): + # Workaround for bug where pypa/packaging does not consider macOS + # tags without minor versions valid. Some Python flavors (Homebrew + # for example) on macOS started to do this in version 11, and + # pypa/packaging should handle things correctly from version 13 and + # forward, so we will add a 0 minor version to MacOS 11 and 12. + # https://github.com/FFY00/meson-python/issues/91 + # https://github.com/pypa/packaging/issues/578 + parts[1] += '.0' + platform_ = '-'.join(parts) elif parts[0] == 'linux' and parts[1] == 'x86_64' and sys.maxsize == 0x7fffffff: # 32-bit Python running on an x86_64 host From 65cef0631899509bd36d812d9be7fd3e0ed1ad7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20La=C3=ADns?= Date: Thu, 29 Sep 2022 08:47:49 +0100 Subject: [PATCH 2/2] ENH: cache platform tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will prevent the duplicated MACOSX_DEPLOYMENT_TARGET message. Signed-off-by: Filipe Laíns --- mesonpy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesonpy/__init__.py b/mesonpy/__init__.py index d55e513ed..40d0adcf9 100644 --- a/mesonpy/__init__.py +++ b/mesonpy/__init__.py @@ -253,7 +253,7 @@ def abi_tag(self) -> str: return selected_tag.abi return 'none' - @property + @cached_property def platform_tag(self) -> str: if self.is_pure: return 'any'