Page MenuHomePhabricator

distutils_rust: add distutils extension to compile Rust extension modules
ClosedPublic

Authored by mbthomas on Nov 14 2017, 12:39 PM.

Diff Detail

Repository
rFBHGX Facebook Mercurial Extensions
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

mbthomas created this revision.Nov 14 2017, 12:39 PM
Herald added a reviewer: Restricted Project. · View Herald TranscriptNov 14 2017, 12:39 PM
quark accepted this revision.Nov 18 2017, 12:32 AM
quark added a subscriber: quark.

Maybe also add from __future__ import absolute_import stuff. But otherwise looks pretty good to me.

distutils_rust/__init__.py
56

Should this be None or False?

This revision is now accepted and ready to land.Nov 18 2017, 12:32 AM
mbthomas updated this revision to Diff 3662.Nov 20 2017, 12:21 PM
durham accepted this revision.Nov 21 2017, 12:13 PM
durham added a subscriber: durham.

freeshrugs

Cool series! I was curious what your plans are to support Windows. That's the part that has been tripping me up in my quest to integrate Rust into the core Mercurial project. Keep in mind that official distributions of Python 2.7 are compiled with MSVC 2008 and link against its CRT. So there are CRT implications depending on how the Rust code is built.

Also, what about PyPy and other non-CPython distributions? Is it necessary to use Python extensions (as opposed to ctypes or cffi) for performance?

quark added a comment.EditedNov 22 2017, 12:38 AM

Also, what about PyPy and other non-CPython distributions? Is it necessary to use Python extensions (as opposed to ctypes or cffi) for performance?

From my experience, it's not only about performance but also code cleanness. I tried the C API + Cython (could replace Cython with cffi) approach. Error handling is much less pleasant (Rust Err -> C special return value -> Python exception) than just implementing Into<PyErr>.

mbthomas updated this revision to Diff 3832.Nov 24 2017, 11:53 AM

I was curious what your plans are to support Windows. That's the part that has been tripping me up in my quest to integrate Rust into the core Mercurial project. Keep in mind that official distributions of Python 2.7 are compiled with MSVC 2008 and link against its CRT. So there are CRT implications depending on how the Rust code is built.

The plan is to support Windows with the caveat that compatibly compiled Python interpreter is used. It's fairly commonplace on the Windows platform to ship programs with their interpreter precompiled alongside the source, so we're expecting that to be acceptable for Windows users. We don't have any details yet, however.

Also, we ship our windows version of Mercurial with a Python 2.7 that has been built against MSVC 2015. Not sure if that helps.

This revision was automatically updated to reflect the committed changes.