-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Adopt distutils #417
Comments
Original comment by ncoghlan (Bitbucket: ncoghlan, GitHub: ncoghlan): I think this could work well with an eventual approach like the following:
There'd need to be a transition period where setuptools did the injection by default, as the monkeypatching of distutils is currently implicit in importing setuptools Longer term, we could eventually aim to move distutils out of the normal standard library update cycle, and instead install it via ensurepip (such that it evolves at the pace of the Python packaging ecosystem, rather than at the pace of the underlying language runtime) |
Original comment by qwcode (Bitbucket: qwcode, GitHub: qwcode): I love the possibility. btw, I recall this being discussed a couple years back. At the time, I guess it was too radical to gain any traction. as for Nick's 1/2/3 points, wouldn't vendoring it, effectively give it a new namespace, and avoid any concerns with conflicts? |
Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco): My thinking was more along the lines with what Marcus is suggesting. Thanks to Nick's comments, I'm reminded that pip install (of non-binary distributions) and also setup.py install (where setuptools is somehow imported) are expected to run with setuptools' overrides. Maintaining that expectation could be tricky, but is probably achievable. |
Original comment by ncoghlan (Bitbucket: ncoghlan, GitHub: ncoghlan): Python does depend on distutils to build some extension modules, but not the core interpreter itself. However, unbundling per se probably isn't worth the hassle, as implementing the 1/2/3 approach I suggested above based on a "setuptool._distutils" vendored copy should provide most of the benefits with a fraction of the pain. The key will be ensuring the stdlib distutils is kept in sync with the setuptools vendored copy for bug fixes (all versions) and new features (future versions). |
Original comment by RonnyPfannschmidt (Bitbucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt): i fear this will result in a certain hell, there is no reasonable way to get rid of the current legacy within setuptools without creating many lines of compatibility breaks |
Original comment by ralfgommers (Bitbucket: ralfgommers, GitHub: Unknown): I don't quite understand how the "vendoring and put in a new namespace" idea would help. There are other packages that extend (and monkeypatch) |
Original comment by andi0661 (Bitbucket: andi0661, GitHub: Unknown): I like the idea of separating |
@xoviat : To answer your question from the other ticket, I'd very much appreciate a PR. |
Okay, I'll send one your way sometime soon. |
Distutils branch now exists, created against the latest master. Is that what you had in mind? |
Yes. |
Is there anything left to do other than merging |
Theoretically more testing is needed though. |
@xoviat @jaraco Is We've kept https://docs.python.org/3/distutils/ and https://docs.python.org/3/install/ around and linked from https://docs.python.org/3/library/distutils.html because there are things documented in there that aren't documented anywhere else, but it would be nice to see that content migrated somewhere that's more actively maintained. The other key question I would have relates to the setuptools injection in While I know I suggested making that override opt-in in the original BitBucket discussion, I'm now thinking that you're going to have to keeping doing it implicitly as a side effect of import to maintain backwards compatibility with the expectations of installation tools. |
So the current plan is to always attempt to override the builtin distutils package with the version provided by setuptools if setuptools is installed. In addition, importing setuptools should guarantee this behavior. Related to this, setuptools will preserve compatibility will all existing projects (numpy distutils included) as it has always done. Setuptools is not currently providing any documentation for distutils, but I see no reason why that would not be moved over (one step at a time). |
Cool, sounds like a good plan to me. Given that, I think the one specific thing I would request is to have a dedicated page somewhere in the setuptools documentation about "Overriding distutils with setuptools". The premise behind that is to have a specific thing we can link to and/or update as folks find potential migration issues (similar to what we have for the pypi.org migration in https://packaging.python.org/guides/migrating-to-pypi-org/ ). |
Looking at the code, setuptools will now patch it's own internal version of distutils, how will this work with pip? Pip expects setuptools to patch distutils so pure distutils projects are supported. |
|
Right, provided setuptools is imported first, its version of distutils will be used. |
@seawolf42 @Zelgius FYI |
Substantial progress has been made on this effort in the distutils branch, though I haven't reviewed it. |
Looking at the distutils branch, it seems that we're just vendoring My thinking on the matter is that we should actually unify the codebases and just move the code from Basically I think the pypa/packaging-problems#127 model of making |
@RonnyPfannschmidt He is not the only one working on In fact, I think it would be much worse if Most of the The main problems I could foresee this causing are people doing |
It's also worth noting that we can almost certainly do the "move all of the |
I agree we don’t want setuptools to present distutils (which that Branch currently does). Rather, for the sake of incrementalism, I’d suggest that it include distutils as a private package (e.g. setuptools._distutils)... and eventually integrate the functionality into one unified implementation. Perhaps it makes sense to have an even less ambitious adoption of only a portion of distutils. I welcome any efforts, but compatibility (including the current expectation that some packages rely on the monkey patching of distutils) needs to be addressed, probably by deprecating distutils. |
While CPython as a whole has many contributors, we don't have many folks contributing to So the challenge for pypa/packaging-problems#127 is as follows:
The scope of the eventual So @jaraco's suggestion sounds like a reasonable starting point to me: give Building a suitable facade (with a |
As an aside about implementing this, I could be way over-estimating the abilities of the average student, but this feel like approximately the right size project for a GSoC student. Too late for this year I'm sure, but if this isn't done by next year we might want to consider applying. |
@pganssle while you consider the abilities of a student right, i believe there is an underestimation on the complexity of legacy not so nice apis and their interaction in setuptools - unfortunately both codebases are already hard to navigate, and their interaction makes things even more tricky |
As a past GSoC student, the thing that hits hard "right in the face" is the technical debt -- working with and around it, is very much not something that formal education prepares students for. Anyway, now would be a good time to get started on figuring out GSoC-sized projects within the PyPA and identifying mentors for them, if we're interested in having projects under PSF's GSoC umbrella for 2020 with decent amount of preparation/planning. |
In #2143, I've drafted a PR that adopts Setuptools from CPython master, retaining history and attribution. This is essentially the second step outlined in pypa/packaging-problems#127. I've asked a few key contributors to review, but I welcome review or comments or questions from anyone. |
Typo, it's really: pypa/packaging-problems#127 :) |
The Setuptools 48 release incorporates the fix and closes this issue, although there is still a lot of work to do to actually merge the functionality and remove the monkey patching. |
Originally reported by: jaraco (Bitbucket: jaraco, GitHub: jaraco)
Setuptools builds on the distutils framework of the Python Stdlib. Doing so has benefits of depending on a standard, extensible framework, but also has downsides, such as limiting the advancement of distutils (across many Python versions) but simultaneously adding monkey patches to patch bugs in distutils.
I'd like to consider if Setuptools should adopt distutils (or a version of it). Doing so would decouple Setuptools from distutils, freeing Setuptools from the constraints of distutils and freeing distutils from the expectations of Setuptools.
Doing so would allow distutils to adapt at the same pace as Setuptools, addressing issues and vetting patches that could be ported back to distutils in CPython.
I've once proposed this idea and it was promptly dismissed by @RonnyPfannschmidt. Why is vendoring distutils in Setuptools not an option?
The text was updated successfully, but these errors were encountered: