-
-
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
Add "python -m setuptools" invocation method #2080
Conversation
This fully replaces the use of "python setup.py <cmd>" with the equivalent "python -m setuptools <cmd>". In the process, we guarantee that a setup.py which imported only distutils will still get the enhanced setuptools treatment previously provided only by pip install. This opens the way for future improvements to setuptools, such as validating setup_requires (if listed in setup.cfg) before invoking the setup() function and running code. It is also the only way to invoke setuptools to build and install packages which fully moved to setup.cfg and no longer provide a stub setup.py with the content: ``` from setuptool import setup setup() ```
Add news fragment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm disinclined to accept this change, mainly because it deviates from the recommended practice (using pep 517 to build) and because it adds complexity to the codebase. setup_requires
needs to be deprecated. If you want a command to build setuptools-based projects, consider using pep517 with python -m pep517.build .
. Give that a try and let me know if it doesn't fully address your needs.
My needs are installing such projects, so a tool that only provides a "build" command cannot work. And I was hoping to reduce the confusion in the user experience, not add to it. I'm involved in distro packaging, so we need to be able to build from source, bootstrap setuptools with its dependencies, and build 1000+ more packages in a somewhat coherent manner. Currently we have a simple guideline: I'd like to replace that with " What I don't want is for packagers to have to think about every single package, decide whether it is a pep517 compliant package in which case to use one uniquely distinct program to build it ( I definitely don't want packagers to have to do a mad scramble when setup.py install which works everywhere, suddenly doesn't work for 2 out of 1000 packages, have no idea what to do, and then, after a lot of confusion and inability to package the project, settle on:
while simultaneously complaining and holding this up as a prime example of the nonstop, headlong rush towards confusion and "some project removed setup.py and replaced it with pip, @eli-schwartz please help me what do I do". As a matter of curiosity, how is (Which leads me to the question: do you actually really intend to completely remove setup.py install functionality? How do you intend to handle the many projects still on PyPI which have setup.py using the historic, de facto standard of setuptools, which will never be updated and hence also won't be updated to have a pep517 pyproject.toml? Will you hold a mass deletion party one day where you unceremoniously give them all the boot?) |
I personally don't care even the slightest bit about |
You should use |
We're definitely not using pip to install pip or its dependencies, that would be an irreconcilable bootstrap violation. And I just got finished explaining that my interest is distro packaging and we don't need anyone's help to handle dependencies at all, so I'm confused why it's being brought up again. In fact, it's utterly forbidden in the strongest possible terms to handle build dependencies like that. It's required to convert build dependencies into an externally managed distribution package manager build graph, and build each member in isolation using non-python tools to manage dependency resolution, chroot containers, and build steps (the build steps will, at last, use a python tool). |
@eli-schwartz First of all, I think I should say thank you for putting in the effort to do this, and for explaining your use case. I do think that we're very unlikely to accept this change. I myself suggested something similar in issue #1515, or at least opened the discussion for a path forward that does not involve invoking Regarding this:
No one says you have to install With regards to the change in general, the reason we think this is going in the wrong direction is that for a long time there was pretty strong "vertical integration" in build tools - your build tool did the installation for you. With PEP 517, we've moved to a more modular system with standard and well-defined roles for build backends and build front-ends, which makes things much easier for tools like Previously, Adding a way to invoke |
Hopefully it won't surprise you to learn that Linux distributions build pip from source rather than using vendor blobs in python? One advantage of this is that we push users to always have the the latest version of pip... no one on Arch Linux has ever had to install python+pip, then run
That's all fine and well if you have a replacement to point people to. I'm living in a world where I don't have a replacement for setup.py install, and you're telling me "just use pip for everything". I don't want a non-modular tool with extremely sharp edges such as downloading and installing dependencies I haven't authorized, attempting to remove older versions from /usr/lib/python3.8/site-packages when I've specified a custom --root, respecting the --user flag in $HOME/.config/pip/pip.conf which is intended for controlling how the user's interactive pip experience operates, not how my isolated package building process creates a distro package, etc. etc. pip is always something to fight against and wrangle into submission by hammering it with options. pip also builds in mysterious randomly generated directories in /tmp/ and embeds non-reproducible binary output based on these directory paths. pip is also 24 different packages which need to be bootstrapped (because we devendor it, and this has so far worked pretty darn well), and in order to build manual pages we also need sphinx (26 packages partially overlapping) as a build-only dependency, so there's another cascade of packages for a grand total of 50. 50 packages before we can use the humongous footprint of pip to emulate 'setup.py install'. As you said, we're moving to a more modular system. ... tl;dr I would greatly appreciate it if there were some option other than pip for installing pep517 wheels, and I believe that until that happens, it is reasonable to consider setuptools install as a transition tool. Since we're not ready to get rid of setup.py install anyway, it seems like a practical win, rather than an ideological loss, to consolidate the scene a bit by at least encouraging everyone using setuptools's install to at least do so with one codepath. You could also get people used to the idea of running a program ("the setuptools program") instead of executing a setup.py file. This is sort of kind of the case with pip, if pip was something everyone was happy to use. Eventually, tell them to use a different program, because "we discontinued setuptools, the new one is lots better". This PR was intended to solve that by moving some code buried in the guts of setuptools.build_meta:_BuildMetaBackend as a class method, and making it usable to consumers. Though I'm not entirely sure what it's trying to do there, I do think it would be nice to make it rely on a single run_setup function. It could also feasibly obsolete this: https://github.com/pypa/pip/blob/9cbe8fbdd0a1bd1bd4e483c9c0a556e9910ef8bb/src/pip/_internal/utils/setuptools_build.py#L14-L47 |
The "vendor blob" is a zip file containing the source code of
You're welcome to consider it that, but it's an unsupported path and the maintainers of In any case, our policy here for years has been that if someone opens a bug that can be solved by switching from It's also trivial to write your own wrapper that just does this and maintain it outside of setuptools, so if you insist on using the unsupported install mechanism (that we plan to actively remove as soon as possible), then I recommend writing a command line utility of your own that invokes |
Oh, I should note that If you really don't want to use |
I'm talking about "vendor" blobs, and you're attempting to argue the counterpoint that it isn't a "binary" blob because it can be validated. Nice attempt at dodging, I guess? The disconnect here is sufficient that I'm not sure why I expected to have a rational conversation. We're not even talking about the same topic, it seems. Nevertheless, I will try. So here you go: https://pip.pypa.io/en/stable/development/vendoring-policy/ This policy violates our policy, and therefore we The existence of the As a matter of curiosity, can you point me to some sort of reference for your alternative definition? |
I would ask that you assume good faith here, as it's hard to remain constructive in a hostile and adversarial discussion. One can see two problems with "vendored blobs", one is that it's vendored (and thus changes cannot be centralized) and the other is that it's a blob (and thus you cannot build it from source). I mistakenly thought that you were concerned with the "blobs" part, which is a common issue with people who do not want to use wheels and prefer to "build from source", even pure Python wheels (which are just zip files containing the source code). If you're more concerned about the "vendored" part, then yes, wheel vs. sdist is not really a concern. In any case, I'm going to go ahead and close this, because unfortunately we simply do not have the resources to maintain a setuptools-specific installer, particularly when the one we have is horribly broken in many circumstances. This issue seems to be popular lately, and the discussion of what, if anything, will be done to allow downstream distributors to avoid using |
I apologize for losing my temper.
This much, I don't have strong feelings about. I think using wheels can be workable, at least depending on whether any patches need to be applied (backports, system integration fixes, etc.). Another issue is that we typically run unittests to ensure the package works in our environment, and while we can often (but not always) get tests from an sdist, wheels... not so much. So it might only be practical for 1) pure-python wheels, 2) whose developers don't have unittests anyway. As pep517 is fairly easy to bootstrap (setuptools+friends, and toml), we can probably use that to generate wheels from sources in such cases anyway, the problem then gets back to "how to install them", which is where I'm currently baffled...
Hmm, well, I will hope for some movement there, I suppose... |
Summary of changes
This fully replaces the use of "python setup.py " with the equivalent "python -m setuptools ". In the process, we guarantee that a setup.py which imported only distutils will still get the enhanced setuptools treatment previously provided only by pip install.
This opens the way for future improvements to setuptools, such as validating setup_requires (if listed in setup.cfg) before invoking the setup() function and running code.
It is also the only way to invoke setuptools to build and install packages which fully moved to setup.cfg and no longer provide a stub setup.py with the content:
Pull Request Checklist