Skip to content

Commit cba5050

Browse files
committed
python-setuptools: add support for py_limited_api
This makes distutils link against python3 instead of python3.x when py_limited_api is set on the extension. With MSVC this is solved via pragma, which doesn't have an alternative with our toolchains. This depends on libpython3.dll being installed, so msys2-contrib/cpython-mingw#148
1 parent 2b373d9 commit cba5050

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--- setuptools-68.0.0/setuptools/command/build_ext.py.orig 2023-06-19 17:52:37.000000000 +0200
2+
+++ setuptools-68.0.0/setuptools/command/build_ext.py 2023-08-21 18:39:55.475275100 +0200
3+
@@ -340,6 +340,18 @@
4+
if os.path.exists(stub_file) and not self.dry_run:
5+
os.unlink(stub_file)
6+
7+
+ def get_libraries(self, ext):
8+
+ libraries = _build_ext.get_libraries(self, ext)
9+
+ if getattr(ext, 'py_limited_api') and self.plat_name.startswith('mingw'):
10+
+ # XXX Since gcc/clang don't support linking specific libraries via
11+
+ # pragma like CPython does with MSVC (see PC/pyconfig.h in cpython),
12+
+ # and because py_limited_api is a setuptools feature and not a
13+
+ # distutils one, this is the only place where we can check and force
14+
+ # it to link against python3 instead of python3.x
15+
+ versioned = 'python' + get_config_var('LDVERSION')
16+
+ return ['python3' if l == versioned else l for l in libraries]
17+
+ return libraries
18+
+
19+
20+
if use_stubs or os.name == 'nt':
21+
# Build shared libraries

mingw-w64-python-setuptools/PKGBUILD

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}"
99
"${MINGW_PACKAGE_PREFIX}-python2-setuptools<42.0.2")
1010
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
1111
pkgver=68.0.0
12-
pkgrel=2
12+
pkgrel=3
1313
pkgdesc="Easily download, build, install, upgrade, and uninstall Python packages (mingw-w64)"
1414
arch=('any')
1515
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
@@ -49,7 +49,8 @@ source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realna
4949
'0006-fix-tests-path.patch'
5050
'0007-windows-arm64.patch'
5151
'0008-default-stdlib-distutils.patch'
52-
'0009-launcher-revert-symlink-resolve.patch')
52+
'0009-launcher-revert-symlink-resolve.patch'
53+
'0010-support-py_limited_api.patch')
5354
sha256sums=('baf1fdb41c6da4cd2eae722e135500da913332ab3f2f5c7d33af9b492acb5235'
5455
'7b196884ac0151801f9638dabbf9a789fa9070a3b07a4c9e625c5523e8d47387'
5556
'fa54581e3dddb9f4edd332dedbc101f48939a9ca5878e13cf9cf9b3408bc8c22'
@@ -58,7 +59,8 @@ sha256sums=('baf1fdb41c6da4cd2eae722e135500da913332ab3f2f5c7d33af9b492acb5235'
5859
'dbdd96a7ead797b2db9f02dfe19ce853d3775337ccf8fd836377fe3c2a9d1c24'
5960
'cb897bc7292a733167fa48b5ca18323d76d3374683a7f5e9986c9df63f5332cc'
6061
'db9a6e2c18d4adfd7c88d17d28268d57afba8845556c1cf1e5c92f513bf36847'
61-
'391d682a8b8832d7e4be3ac0c3327cfe3c8e520f16e25b43d4441df8036bf147')
62+
'391d682a8b8832d7e4be3ac0c3327cfe3c8e520f16e25b43d4441df8036bf147'
63+
'ccb276f9d2d26587d29ecfd4d47a3d4e96fb58738cfaf3a600a8b942c79fc439')
6264

6365
prepare() {
6466
cd "${srcdir}/setuptools-${pkgver}"
@@ -78,6 +80,9 @@ prepare() {
7880
# (from what I see the launcher code itself deals with it fine)
7981
patch -R -p1 -i ${srcdir}/0009-launcher-revert-symlink-resolve.patch
8082

83+
# https://github.com/msys2-contrib/cpython-mingw/issues/149
84+
patch -p1 -i ${srcdir}/0010-support-py_limited_api.patch
85+
8186
cd "${srcdir}"
8287
rm -rf python-build-${MSYSTEM} | true
8388
cp -r "${_realname}-$pkgver" "python-build-${MSYSTEM}"

0 commit comments

Comments
 (0)