-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
PEP 632: Proposed deprectation of distutils
#7702
Comments
distutils is only used to decide if extensions should link against libpython to follow the platform defaults (Debian patched to not link, default was to link). With Python 3.8 upstream Python default changed to not link to libpython by default, so if distutils ever gets removed, meson can just default to not linking always: https://docs.python.org/3/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build |
Note that in #9288 we added an additional reliance on distutils (in the same exact introspection command that already imports distutils). In addition to detecting whether to link against libpython, we now also use distutils to detect whether sysconfig is completely crippled by the vendor and unable to tell the truth about install paths. Handling libpython linking could be done by a try/except that reacts to an ImportError by saying "clearly this must be Handling debian paths cannot be resolved other than by waiting on debian to fix things. As we get closer to the final removal of distutils in 3.12 we will need to both consider that try/except for libpython, and keep an eye on the debian situation. |
adapted from numpy's meson branch:
|
FYI, there's been a migration among packaging tools to use the standalone, modern |
We already use sysconfig for most things. There is:
I'll try to see if I can get news on both counts in the near future. Because one of them is totally dependent on Debian's timeframe and they already know about the problem but have been flatly ignoring it for years, I've been letting the general issue slide, hoping that if I check in on it closer to the cutoff point it will finally resolve itself. But I didn't think about people using the alphas for 3.12 a year before the cutoff point. :) |
I see, thanks. In that case, I'd suggest opening a CPython issue for the former as soon as possible (and the latter, if there's anything needed on the upstream end), to allow plenty of time before the beta freeze in less than 6 months for discussion, implementation, review and merging, and preferably allow you, distros and others to test with it. |
The suggestion of installing a setuptools 60+ worked for getting meson to work with py312. |
It seems that recent Debian patches Edit: it looks like the |
It would be great to have some input from the Debian Python maintainers on this. |
Probably worth checking https://www.debian.org/doc/packaging-manuals/python-policy/ |
I've done some more archeology. The The other meson/mesonbuild/modules/python.py Lines 366 to 370 in 47d1a55
|
See https://ffy00.github.io/blog/02-python-debian-and-the-install-locations/ if you want some more archeology 😛
python/cpython#88611 is the proposed fix. |
IIUC, the linked issue is about where to find the headers, not about whether to link or not with libpython. Aren't these separate issues? |
Yes, sorry, I misread it. |
The reason Debian patches Python in this way is python/cpython#65735. I am trying to understand if it is still relevant, or if we can just revert to looking at |
Well, yes. For Linux, it depends on the python version, and on older versions of python, it also depends on whether there's a Debian patch. There's other rules for other platforms. |
But older platforms will have distutils available to do the check, we need to figure out if this is still relevant on newer versions, and if so, figure out a way to support it without distutils. |
@FFY00 In python/cpython#88611 the conclusion is that Python itself should not bother defining the include path. This means that whatever solution will be identified will be in one of the PyPA packages. Which makes it unsuitable for consumption by Meson because of the no-external-dependencies policy. What's the plan B? |
@FFY00 I have the impression that your analysis in https://ffy00.github.io/blog/02-python-debian-and-the-install-locations/ is not complete for recent Python distributed by Debian. Debian patches Python 3.10 to also update the paths returned by |
I finally got around to this (plus a bit more research into all the moving parts): python/cpython#99942 And in #11133 I have a draft PR that fully removes distutils, but may need a CPython fix. It actually turns out that there's a sysconfig variable that almost gives us what we need for link_libpython. Debian should simply work without fuss after a version gate, mid-3.10.x |
I have two PRs linked to that issue, and it would be great to have confirmation that I'm on the right track here (obviously I think I am). Also, I think that maybe to handle Android correctly, we need to drop the pkg-config detection method? 🤔 This isn't tested in CI, but Cygwin is. Cygwin works okay, because Cygwin patches it to be correct. Assuming that CPython upstream agrees with me, I think we can handle this reasonably okay on our end. |
I've pinged about it to the core dev team. |
I just tested doing a meson build with Python 3.12.0b3. |
@danyeaw, currently you need to install |
@dnicolodi Correct, but meson finds the system Python, not necessarily the activated virtualenv. This may require users to install setuptools system wide, which isn't great. |
How can I help, are we still waiting on CPython to do something? |
No changes from CPython's side are required to fix this, and nothing significant will happen there until 3.14 at least anyway. |
Disagreement between distutils and sysconfig have been resolved for Python 3.12, see python/cpython#100356 and python/cpython#100967 This is the other half of the fix for mesonbuild#7702.
Since 3.10.3, Debian finally started patching sysconfig with custom paths, instead of just distutils. This means we can now go use that instead. It reduces our reliance on the deprecated distutils module. Partial fix for mesonbuild#7702.
Disagreement between distutils and sysconfig have been resolved for Python 3.12, see python/cpython#100356 and python/cpython#100967 This is the other half of the fix for mesonbuild#7702.
Since 3.10.3, Debian finally started patching sysconfig with custom paths, instead of just distutils. This means we can now go use that instead. It reduces our reliance on the deprecated distutils module. Partial fix for mesonbuild#7702.
Disagreement between distutils and sysconfig have been resolved for Python 3.12, see python/cpython#100356 and python/cpython#100967 This is the other half of the fix for mesonbuild#7702.
Since 3.10.3, Debian finally started patching sysconfig with custom paths, instead of just distutils. This means we can now go use that instead. It reduces our reliance on the deprecated distutils module. Partial fix for mesonbuild#7702.
Disagreement between distutils and sysconfig have been resolved for Python 3.12, see python/cpython#100356 and python/cpython#100967 This is the other half of the fix for mesonbuild#7702.
Since 3.10.3, Debian finally started patching sysconfig with custom paths, instead of just distutils. This means we can now go use that instead. It reduces our reliance on the deprecated distutils module. Partial fix for mesonbuild#7702
…nt python On python >=3.8, this information is expected to be encoded in the sysconfig vars. In distutils, it is always necessary to link to libpython on Windows; for posix platforms, it depends on the value of LIBPYTHON (which is the library to link to, possibly the empty string) as generated by configure.ac and embedded into python.pc and python-config.sh, and then coded a second time in the distutils python sources. There are a couple of caveats which have ramifications for Cygwin and Android: - python.pc and python-config.sh disagree with distutils when python is not built shared. In that case, the former act the same as a shared build, while the latter *never* links to libpython - python.pc disagrees with python-config.sh and distutils when python is built shared. The former never links to libpython, while the latter do The disagreement is resolved in favor of distutils' behavior in all cases, and python.pc is correct for our purposes on python 3.12; see: python/cpython#100356 python/cpython#100967 Although it was not backported to older releases, Cygwin at least has always patched in a fix for python.pc, which behavior is now declared canonical. We can reliably assume it is always correct. This is the other half of the fix for mesonbuild#7702
This is the current recommendation in mesonbuild/meson#7702 to deal with Python 3.12's removal of distutils.
This is the current recommendation in mesonbuild/meson#7702 to deal with Python 3.12's removal of distutils.
This is the current recommendation in mesonbuild/meson#7702 to deal with Python 3.12's removal of distutils.
Since 3.10.3, Debian finally started patching sysconfig with custom paths, instead of just distutils. This means we can now go use that instead. It reduces our reliance on the deprecated distutils module. Partial fix for mesonbuild#7702
…nt python On python >=3.8, this information is expected to be encoded in the sysconfig vars. In distutils, it is always necessary to link to libpython on Windows; for posix platforms, it depends on the value of LIBPYTHON (which is the library to link to, possibly the empty string) as generated by configure.ac and embedded into python.pc and python-config.sh, and then coded a second time in the distutils python sources. There are a couple of caveats which have ramifications for Cygwin and Android: - python.pc and python-config.sh disagree with distutils when python is not built shared. In that case, the former act the same as a shared build, while the latter *never* links to libpython - python.pc disagrees with python-config.sh and distutils when python is built shared. The former never links to libpython, while the latter do The disagreement is resolved in favor of distutils' behavior in all cases, and python.pc is correct for our purposes on python 3.12; see: python/cpython#100356 python/cpython#100967 Although it was not backported to older releases, Cygwin at least has always patched in a fix for python.pc, which behavior is now declared canonical. We can reliably assume it is always correct. This is the other half of the fix for mesonbuild#7702
Since 3.10.3, Debian finally started patching sysconfig with custom paths, instead of just distutils. This means we can now go use that instead. It reduces our reliance on the deprecated distutils module. Partial fix for mesonbuild#7702 (cherry picked from commit 40f897f)
…nt python On python >=3.8, this information is expected to be encoded in the sysconfig vars. In distutils, it is always necessary to link to libpython on Windows; for posix platforms, it depends on the value of LIBPYTHON (which is the library to link to, possibly the empty string) as generated by configure.ac and embedded into python.pc and python-config.sh, and then coded a second time in the distutils python sources. There are a couple of caveats which have ramifications for Cygwin and Android: - python.pc and python-config.sh disagree with distutils when python is not built shared. In that case, the former act the same as a shared build, while the latter *never* links to libpython - python.pc disagrees with python-config.sh and distutils when python is built shared. The former never links to libpython, while the latter do The disagreement is resolved in favor of distutils' behavior in all cases, and python.pc is correct for our purposes on python 3.12; see: python/cpython#100356 python/cpython#100967 Although it was not backported to older releases, Cygwin at least has always patched in a fix for python.pc, which behavior is now declared canonical. We can reliably assume it is always correct. This is the other half of the fix for mesonbuild#7702 (cherry picked from commit 2d6c109)
Since 3.10.3, Debian finally started patching sysconfig with custom paths, instead of just distutils. This means we can now go use that instead. It reduces our reliance on the deprecated distutils module. Partial fix for mesonbuild#7702
…nt python On python >=3.8, this information is expected to be encoded in the sysconfig vars. In distutils, it is always necessary to link to libpython on Windows; for posix platforms, it depends on the value of LIBPYTHON (which is the library to link to, possibly the empty string) as generated by configure.ac and embedded into python.pc and python-config.sh, and then coded a second time in the distutils python sources. There are a couple of caveats which have ramifications for Cygwin and Android: - python.pc and python-config.sh disagree with distutils when python is not built shared. In that case, the former act the same as a shared build, while the latter *never* links to libpython - python.pc disagrees with python-config.sh and distutils when python is built shared. The former never links to libpython, while the latter do The disagreement is resolved in favor of distutils' behavior in all cases, and python.pc is correct for our purposes on python 3.12; see: python/cpython#100356 python/cpython#100967 Although it was not backported to older releases, Cygwin at least has always patched in a fix for python.pc, which behavior is now declared canonical. We can reliably assume it is always correct. This is the other half of the fix for mesonbuild#7702
Since 3.10.3, Debian finally started patching sysconfig with custom paths, instead of just distutils. This means we can now go use that instead. It reduces our reliance on the deprecated distutils module. Partial fix for #7702
…nt python On python >=3.8, this information is expected to be encoded in the sysconfig vars. In distutils, it is always necessary to link to libpython on Windows; for posix platforms, it depends on the value of LIBPYTHON (which is the library to link to, possibly the empty string) as generated by configure.ac and embedded into python.pc and python-config.sh, and then coded a second time in the distutils python sources. There are a couple of caveats which have ramifications for Cygwin and Android: - python.pc and python-config.sh disagree with distutils when python is not built shared. In that case, the former act the same as a shared build, while the latter *never* links to libpython - python.pc disagrees with python-config.sh and distutils when python is built shared. The former never links to libpython, while the latter do The disagreement is resolved in favor of distutils' behavior in all cases, and python.pc is correct for our purposes on python 3.12; see: python/cpython#100356 python/cpython#100967 Although it was not backported to older releases, Cygwin at least has always patched in a fix for python.pc, which behavior is now declared canonical. We can reliably assume it is always correct. This is the other half of the fix for #7702
There is a PEP proposed for deprecating
distutils
. Meson usesdistutils
in thepython
module for, if I am correct, building extension modules, so this PEP may be of interest to you.The text was updated successfully, but these errors were encountered: