Add support for ext_modules in static setup.cfg
See original GitHub issueIn 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:
[extension=<module_name>]
sources = <file1> <file2> ...
language = c
<keyword> = <value>
where each key/value pair correspond to setuptools.Extension
arguments.
For setuptools it might look something more like:
[options.ext_modules.<module_name>]
<key>=<value>
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.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:17 (5 by maintainers)
Top Results From Across the Web
Building Extension Modules - Setuptools
Setuptools can build C/C++ extension modules. The keyword argument ext_modules of setup() should be a list of instances of the setuptools.Extension class.
Read more >How to build a C extension in keeping with PEP 517, i.e. with ...
Any items that are dynamic or determined at install-time, as well as extension modules or extensions to setuptools , need to go into...
Read more >2. Writing the Setup Script — Python 3.11.1 documentation
The Distutils' own setup script, shown here, is used to install the package into ... supports a great deal of flexibility in describing...
Read more >static metadata for distutils - Fetchez le Python
from distutils.core import setup setup(name='MyDistribution', ... We wanted to extend the Metadata fields list in order to add a "requires" ...
Read more >Build systems - pybind11 documentation
To use pybind11 inside your setup.py , you have to have some system to ensure ... and pybind11 supports all four: You can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Does there happen to be a roadmap for this? I’d be very interested to see this happen.
I agree with your point about using a different delimiter to separate the config namespace from the module name. I’m fine with
:
, I think it’s a good choice.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
numpy.get_include()
to get the path to the Numpy headers. Another is usingcythonize
to build Cython modules. In d2to1 I believe I included special cases for both of these, but hard-coding special cases doesn’t scale well.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.