Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44471 > unrolled thread
| Started by | Devin Jeanpierre <jeanpierreda@gmail.com> |
|---|---|
| First post | 2013-04-28 13:55 -0400 |
| Last post | 2013-04-28 13:55 -0400 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
Adding new source types to distutils? Devin Jeanpierre <jeanpierreda@gmail.com> - 2013-04-28 13:55 -0400
| From | Devin Jeanpierre <jeanpierreda@gmail.com> |
|---|---|
| Date | 2013-04-28 13:55 -0400 |
| Subject | Adding new source types to distutils? |
| Message-ID | <mailman.1137.1367171799.3114.python-list@python.org> |
Last night I wrote a toy prototype module that lets one compile Rust crates into extension modules for Python. The problem is, I don't know the "right" way to do this. Ideally I'd just want to tell build_ext that there's a new source type I want to handle (.rc and .rs), and also tell distutils that it should handle it by running the code that I specify (which can compile the .rs/.rc files, remove them from the sources list, and add the resulting object files and such to the linker arguments) The problem is that, as I understand it, the way to do this is subclassing and then replacing the build_ext command. At least, that's what Cython does. The problem is, that's what Cython does, so if I do that, it means you can't use Cython and Rust together -- that's bad, because Cython would be useful for writing bindings to Rust crates, too. So I don't want to write my own subclass. In place of that, I don't know what the right approach is. One possibility is that I subclass Cython's build_ext if it exists, otherwise distutils'. This seems like it's a terrible thing to do, since it locks out any Cython alternative that I may not be aware of, and any other kind of extension to build_ext. I don't know what else I can do. (What I ended up doing, just so that I could actually write the code, was write a new Extension type that compiles the rust code when the extra_link_args attribute is accessed. This is, of course, absolutely terrible, and only barely does the job. It's not as bad as what I had to do to get the linker arguments from rustc, though...) -- Devin
Back to top | Article view | comp.lang.python
csiph-web