D extensions to python, inline in an ipython/jupyter notebook
John Colvin via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Thu Jul 2 13:26:03 PDT 2015
On Thursday, 2 July 2015 at 18:28:50 UTC, Russel Winder wrote:
> On Tue, 2015-06-30 at 18:20 +0000, John Colvin via Digitalmars-d
> -announce
> […]
>>
>> Ditched distutils in favour of dub. This is easier for me to
>> maintain and fits much better with the rest of the D ecosystem
>
> I am not convinced by this, though cleary my feeling carry no
> weight in decision making :-)
>
> For building C, and C++ extension (and indeed Chapel ones) it
> is assumed distutils will be used, allowing for:
>
> python3 setup.py build
>
> python3 setup.py install
>
> SCons can do this but every one demands distutils. Can dub
> really replace distutils for installing extensions as well as
> building them? Will people installing extensions be prepared to
> switch to a non -standard system? Whilst perhaps they should,
> they won't. I fear that without a distutils installation, the
> extension will never be installed outside the development team.
> It's not the D community that must be convinced, it is the
> Python one.
There are 2 seperate points where a build/install system is
needed:
1) Installing the extension. It's just one python file, which
makes it a good fit for %install_ext but of course I could wrap
it in a trivial setup.py to make people feel more comfortable /
make it fit in with easy_install/pip or related tools.
2) building the inline D code and sorting out linking to other
libraries etc. The basics of this can be done with distutils
(it's how pyd traditionally does it), but seeing as it's all D
code from this point, dub is a better fit, otherwise people have
to have manually install any D libraries they want to use.
I originally modelled PydMagic on how the %%cython inline magic
works. %%cython uses distutils under the scenes with minor
leakage for the compilation options and PydMagic uses dub, with
similar levels of leakage.
The recently-spun-off-from-PydMagic work of making a nicer API
for pyd ( github.com/John-Colvin/ppyd which PydMagic pulls in via
dub) is independent of the build system, so you can use pyd's
distutils extensions or dub. This is the project you would use if
you want to write a proper python extension in D, as opposed to
little snippets in a Jupyter notebook.
More information about the Digitalmars-d-announce
mailing list