-
Notifications
You must be signed in to change notification settings - Fork 3k
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
let me use setup_requires somehow so I can have abstractions in setup.py #1820
Comments
yes, see here: https://pip.pypa.io/en/latest/reference/pip_install.html#controlling-setup-requires
see the Packaging User Guide Projects page for current links: http://packaging.python.org/en/latest/projects.html
I rarely use setup_requires myself, but are your imports after the
I'm not seeing that in a case I just worked up. can you paste your details? |
With a fresh environment I can't reproduce. There are some other shenanigans going on in this |
So |
I'm pretty sure this won't actually work. |
btw, I only said that after I tried it. imports of |
Right, the imports themselves will work, but you can't use those imports to pass anything into the |
yea, I guess there's nothing proper you'd ever want to be doing after the |
Yeah my original understanding was that I was supposed to call |
I've thought about defining a simple setup.cfg variable install-requires = x y z These would not necessarily be the full build requirements and would not require us to finish Metadata 2.0. Just what is required to execute setup.py itself. I have a feeling that it could be messy to implement this in pip, but I haven't looked into it deeply. |
I think I am against adding an ad hoc setup.cfg variable like that. |
One thing we could do is change from a two pass system to a three pass system. The downside to that is that it would make the packages that rely on that pip specific which would do the wrong thing outside of pip. I don't think I actually like that very much to be honest though. |
Whatever the hocness, there isn't another place to put it. You can't get setup.py's own requirements out of setup.py without running it and you can't run setup.py without installing its requirements. It will still work about the same if you just run setup.py as long as you already have setup.py's requirements. |
An alternative would be to allow setup_requires.txt in the root of the sdist. It is a pip requirements file. If pip finds it, then it will install it before running setup.py. However we do it, static setup_requires would be a simple improvement that we can implement without having to invent anything else. I think people would love it and it would put us in a much better position to have alternative setup.py implementations. We would not be breaking anything since the whole point of this is to enable cases where setup_requires doesn't work. |
It looks like the thing to do is to write a new boilerplate setup.py that contains only a check to see whether the requirement were already installed, a subprocess call to "pip install the requirements in some directory" ; modify sys.path ; eval real-setup.py. It would read the setup_requires from a simple text file. This would be sortof like what it does now with easy_install except it could possibly actually work, since the dependency-installing would happen before the dependency-importing does. No setup.py commands would need to be implemented in the new boilerplate file because the arguments are all just passed along to the implementation in the real-setup.py file. |
Here's my first stab at the problem. Put a list of requirements, blank lines, and # comment lines in setup-requires.txt; rename setup.py to real-setup.py, and go. The script will subprocess.call() pip to install anything that's not installed into the setup-requires directory, and then calls the real setup.py in the same way pip does with exec(compile(...)). https://gist.github.com/dholth/5c2296b5bfdf32deffb0 We should make sure it's polyglot, make it terser and see whether it works when a conflicting version of one of the setup-requirements is already installed. |
Here's the full project. Copy setup.py into your own project to use. https://bitbucket.org/dholth/setup-requires |
Interesting; thanks for that. |
No, this isn't a way to upgrade pip. The linked setup-requires implementation installs things into a directory ./setup-requires/ and only adds them to PYTHONPATH for the duration of setup.py's execution. This is desirable for the use case. |
I think this is a dupe of #769 |
Interesting, this is another piece of the puzzle that's needed for reliable I see that |
I've very skeptical about the viability of recursive call into pip - it caused massive issues for OpenStack when pbr did that, and when pip start locking environments to fix the known race conditions around distribution metadata changes, I expect it to break. |
The intention is that pip should support setup-requires itself so that On Mon, Oct 26, 2015, at 08:59 PM, rbtcollins wrote:
Links: |
Closing this as a duplicate of #3691, which is the mechanism we will use to support this feature. |
The recommended mechanism for determining a project's version at setup time is completely ridiculous, and determining your own version is far from the most complicated thing that one might wish to do at setup / build time.
For years, I've wanted to write some abstractions for Twisted plugin developers to be able to properly install plugins without hand-crafting a solution in every single setup.py, and for years we've been stymied by the lack of any mechanism for setup.py itself to depend upon or import things.
The
setup_requires
field ostensibly solves this problem, except for the fact that it doesn't actually work. I can't figure out why it doesn't work, really, or how you're actually supposed to use it. It appears to invokeeasy_install
? It also appears to install the dependencies multiple times, but also not re-runsetup.py
to get correct information after they've been installed.In the meanwhile, should I be looking to create a tool which, instead, generates a
setup.py
automatically?(This is probably actually a distutils or setuptools bug, but I couldn't figure out which of the 9 bug trackers those projects have variously used in their forks and external maintenance and suchlike to use. But there's also some involvement from
pip
here, like, what the heck is going on with theeasy_install
ed eggs of things I have perfectly good wheels of in my cache already…)The text was updated successfully, but these errors were encountered: