MNT: Replace some distutils imports with setuptools#10571
MNT: Replace some distutils imports with setuptools#10571mwcraig merged 2 commits intoastropy:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Yes, seems related to recent changes in setuptools: But the real motivation for this is a bit older: All of this makes sense when executing setup.py and with the recent changes in the packaging ecosystem, but I guess that also means that we should really avoid using setuptools in the package itself. |
|
Instead of importing at the top level, which would add a runtime dependency on setuptools, I think we should fix any of the distutils imports in would become: I think there is one instance not in a setup_package.py file which is: and I think for that it's also safe to use setuptools (if needed, the test using it - if any - can be made to be conditional on setuptools being installed). Basically we should just not have any direct distutils imports. |
|
Not sure how to get rid of usage of |
|
tl;dr -- Just fixing |
|
Numpy ended up pinning the version: numpy/numpy#16870. From the discussion at pypa/setuptools#2261, it would seem best to do as @astrofrog noted, try to use p.s. I still like the idea of the package providing a way to test itself |
|
Thanks for the links, @mhvk ! Given pypa/setuptools#2261 (comment), maybe we want to wait a bit before going forward with this PR. In the meantime, I think @jdavies-st 's suggestion to whitelist is a very good one -- see #10576 . (Sorry for the inconvenience caused, James!) p.s. I avoided pinning setuptools like Numpy because pinning a max version had bitten us in the past. |
|
Update: I reduced the scope of this PR. Should now be uncontroversial. There are still some leftover |
|
Oh weird. What I thought was uncontroversial made |
mhvk
left a comment
There was a problem hiding this comment.
Looks good to me. Ideally, we'd have working links to setuptools.Extension (see in-line), and a suggestion to get rid of log. But neither are very important, so approving.
| anywhere in the package, and then looks for a function called ``get_extensions`` | ||
| inside each of these files. This function should return a list of | ||
| :class:`distutils.core.Extension` objects, and these are combined into an | ||
| ``setuptools.Extension`` objects, and these are combined into an |
There was a problem hiding this comment.
Would be good to fix this to point to the right documentation. Would adding an intersphinx_mapping['setuptools'] to docs/conf.py help?
| from contextlib import contextmanager | ||
|
|
||
| from setuptools import Command | ||
| from distutils import log |
There was a problem hiding this comment.
Since it is basically not used except to give some info messages, I think it can be either replaced with import logging as log or the commands replaced with print. In favour of the earlier option is:
https://github.com/python/cpython/blob/164b04c47e61bd35d55e61bc74f9fd646eba81bb/Lib/distutils/log.py#L3-L4
There was a problem hiding this comment.
I'll leave this as future exercise but I'll look into intersphinx. Thanks for the review!
One can probably use |
Yes, this is...interesting: https://github.com/astropy/astropy/blob/master/astropy/utils/introspection.py#L144 My inclination is to use the vendored version of Shall I open a separate PR to do that? |
Yes, please. 😉 |
|
ok, I'm going to go ahead and merge this since it has been approved. Thanks @pllim! |
|
While See #10581 |
|
Note: one advantage of |
|
FWIW, maybe the reply at pypa/setuptools#2261 (comment) is helpful. |
It is odd that something like this is not part of the standard library. I think many of the places it is used it is in files that are part of the test suite; adding In any event, I'll open a PR later today for further (and more concrete) discussion. |
MNT: Replace some distutils imports with setuptools
|
@pllim - this turns out to be pretty complicated of a backport to v4.0.x . Before trying to do it, I want to confirm: Does it really need to be in 4.0.x ? I'm a bit worried of unintended consequences in things like logging that might be surprising in an LTS... |
|
Yeah, okay, no need to backport then, as long as this below is in 4.0.x, should be fine until Python org really pulls the plug but I doubt they would do it so soon. Line 112 in d65dabb |
|
p.s. I'll leave it for you to re-milestone. Sorry for the trouble, @eteq ! |
No trouble at all! |
Update
This follows up on #10576 to replace some
distutilsimports withsetuptools. This should now be uncontroversial but it does not completely remove the warning that #10576 is ignoring.Also see #10578 for the future.
Original Description
This pull request is to addressthis error that started showing up during test collection in CI.I think this is due to new
setuptoolsrelease 49.2.0 but I am not 100% sure.