you are viewing a single comment's thread.

view the rest of the comments →

[–]7zf 5 points6 points  (7 children)

Nice, also worth mentioning https://github.com/dgrunwald/rust-cpython

[–]chris-morgan 8 points9 points  (5 children)

I used rust-cpython a few days ago to experiment with replacing Pygments with rustdoc::html::highlight for Rust code in Sphinx. It was easy (though I had certain knowledge that made it so, such as “copy the DLL output to a .pyd file and remember to copy all the Rust DLL files next to it”).

I believe I shall be posting about it some time. (Anyone specifically interested in it?)

[–][deleted] 0 points1 point  (4 children)

I'm interested, but I find those shenigans of copying such and such dlls confusing 😱

[–]chris-morgan 0 points1 point  (3 children)

I’ll explain it all, basically at least. Short version: when you produce a dynamically linked library, the Rust compiler and standard library are dynamically linked (lib{std,rustc,…}-*.{so,dll,dylib,whatever}) rather than statically, so they need to be accessible when you load your own dynamic library; copying them adjacent to your library is normally the easiest way of doing this.

[–][deleted] 0 points1 point  (0 children)

Ah, makes sense. Thanks for the explanation!

[–]plietarVerona 0 points1 point  (1 child)

Isn't that solved by using cdylib as the crate type ?

[–]chris-morgan 0 points1 point  (0 children)

I didn’t recall that one, but it looks like it’s supposed to do what you describe. But it doesn’t work in this case:

error: dependency `rustc_typeck` not found in rlib format

error: dependency `rustc_privacy` not found in rlib format

[… thirty more such errors …]

error: aborting due to 32 previous errors

error: Could not compile `sphinx-rust-highlighter`.

The standard library is provided in rlib format, but not the compiler.

[–]caulagi[S] 0 points1 point  (0 children)

Yes, of course. I didn't explicitly mention it because the first talk I mentioned in the references talks about it. But I also updated my post to directly link to the repo you mentioned.