-
-
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 support for ext_modules in static setup.cfg #2220
Comments
Thanks for the report. Your instinct seems right here. I worry a little bit about the arbitrarily-named sections. Is there precedent for that? A quick look through the code, I suspect the Yes, I think it could work. I'm a little concerned about the Quickly scanning the docs, I see that Feel free to get started on a PR; I'm hopeful there are few decisions to be made before an implementation can be accepted. |
I agree with your point about using a different delimiter to separate the config namespace from the module name. I'm fine with One problem with all this I realized, is that while it would work fine for simple cases, I noticed that it's still fairly common in several of my packages to involve a little bit of code in configuring extension modules. Most commonly was using Of course, this could get arbitrarily complex to the point where not every case can be supported in a static config. I think there could be a way for code to provide extensions to the syntax while still allowing most of the configuration to be static. But maybe as a first pass it would be best to just implement the "obvious" static configuration and then figure out more complex cases later. |
Does there happen to be a roadmap for this? I'd be very interested to see this happen. |
I believe Setuptools has built-in support for building Cython modules without anything extra. Just needs (a) cython installed, which is possible through build-requires and even legacy setup_requries, and (b) the source is a .pyx file. I'd hope that would cover a lot of cases.
Numpy is important enough that it might deserve its own support... although I would be interested in exploring a generalizable technique for soliciting includes, independent of the configuration mechanism. For example, if Setuptools could solicit an entry point for
No roadmap; just what you see above. |
@embray I like this feature idea a lot. Did you start any work on it? If possible, you should also be able to compile and include C libraries through the "libraries" argument. |
+1 It will help to greatly reduce the code from setup.py, especially for projects that provide C bindings. |
Would like to have this feature for C bindings. |
I created a PR to add a similar feature to Python Poetry here. The PR is ready but the maintainers have said they don't have enough time to review it. If you guys want to have that functionality in Poetry, please go over there and help bug the maintainers for me. |
It's not clear to me why setuptools users care what some other tool does? How does this help achieve a world where setuptools can encode ext_modules statically? |
I made this out of frustration with the lack of this feature originally in setuptools. You can feel free to take note and maybe create something similar in setuptools. Or not. |
Since the poetry developers rejected the feature, maybe it would be interesting to rewrite it as a contribution to setuptools instead? |
I took a very brief look at the poetry proposal. Yikes! 43 files changed to add support for ext_modules? Not to impugn the motives of the contributor, but I can see why such a change might be daunting. I'm imagining here that an initial contribution to Setuptools would affect 2-5 files. I'd very much be interested in seeing at least a basic implementation that satisfies cases similar to what d2to1 did. You may want to reference the poetry PR, but I'd advise not to try to port it. |
To be fair, it was only 6 files if you don't count the directory of test fixtures. :) Granted, the actual core change was still a diffstat of Seems like the poetry developers were more daunted by the idea of causing people to depend on the setuptools API (?) which would prevent "more generic" tools. |
Thanks for the summary. I agree, it's probably wise for them not to rely on Setuptools APIs. I would like to expose the |
@eli-schwartz Poetry already relies very heavily on setuptools to package distributions, so IMO adding an additional dependency on setuptools in a sub-step of the packaging process shouldn't rule out consideration of a new feature in anticipation of a big effort to remove setuptools that they may or may not complete one day. And thanks for the suggestion, I am planning to look into it during my Christmas vacation. |
@jaraco @eli-schwartz And thanks for looking at my PR. I appreciate not dismissing it from an armchair. The json validation schema alone is +157 lines, so the true core diff is closer to (+237, -9), which is big but in my view not unreasonable to implement a complex new feature. If I take a crack at it in setuptools I will make sure to keep complexity to a minimum. I don't think most of the Python code can be "ported" since the files and functions changed are unique to Poetry's packaging pipeline. |
You're welcome for the summary. Although actually I disagree (hence my question mark when mentioning it). I think it is perfectly reasonable to use the setuptools APIs. It's at least as reasonable as any project writing their own setup.py and specifying setuptools as their build backend! Note that they specifically mentioned the (in)ability for poetry to change away from setuptools after users start to rely on it. I simply don't see how poetry providing their own configuration approach and guaranteeing nothing beyond "this will produce a compiled extension through whatever mechanism poetry pleases to use internally" causes projects to rely on the setuptools API. Poetry simply needs to make sure that the internal implementation detail is isolated and doesn't leak (for example, do not let projects control it by importing their own Extension objects). This would leave poetry free to refactor their approach to use any alternately end up preferring. It is of course entirely possible that they are concerned about the internal maintainability of poetry itself if it becomes tied to setuptools API (more than it is now?) but that's an entirely different point and IMHO it's not too hard to simply rip everything out as long as the initial implementation is reasonably isolated. So I don't think it's too problematic for poetry or other tools to rely on |
The poetry maintainers make me sad. Especially the part about too many people relying on it. Yikes! |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Restating from my hidden comment: I'd still love to see some static config for extension modules. I'd also like to consider some automatic detection such that static configuration is unnecessary for many cases (e.g. each C file in the package represents a module, or a particular arrangement of C files can represent a module). |
FTR, there's a related proposed PoC @ https://ofek.dev/extensionlib/. Not sure if it's been discussed on this tracker yet. |
That proposal is not related, as far as I'm aware. That proposal suggests an API for defining a PEP 517 build backend, which implements "extensionlib" as a mechanism for using pyproject.toml static configuration to declare that C-API extension "foobar" located in directory packagename/ gets built by running It is designed to let people build part of their project with cmake, part of their project with meson, part of their project with mypyc, part of their project with maturin, and part of their project with setuptools. |
Supported was added not exactly for |
In the process of porting an old project from the now defunct d2to1 I noticed a feature of d2to1 that is still missing from setuptools is support for configuring extension modules in
setup.cfg
.At least, that's what my reading of the source suggests, especially
ConfigOptionsHandler
In d2to1 this looks something like:
where each key/value pair correspond to
setuptools.Extension
arguments.For setuptools it might look something more like:
Though I'm open to other suggestions for the format, and would be happy to provide a PR once we agree on and nail down a format.
The text was updated successfully, but these errors were encountered: