PyD status and tutorials

Ellery Newcomer ellery-newcomer at utulsa.edu
Wed Apr 3 20:50:03 PDT 2013


On 04/03/2013 05:58 PM, Ellery Newcomer wrote:
>
> Somehow I still haven't gotten around to building gdc yet, but
> supporting gdc for embedding python would just be a matter of updating
> the CeleriD configurations and ensuring everything links. Might as well
> do that tonight. Stay tuned.
>

Actually, it looks like pyd is working just fine with gdc built from 
master, so have some randomly diced NetworkX Quick Example:

// thimble.d

import std.stdio;
import pyd.pyd, pyd.embedded;

void main() {
     py_init();

     auto ctxt = new InterpContext();
     ctxt.py_stmts("import networkx as nx");
     ctxt.py_stmts(q"<
G=nx.Graph()
G.add_node("spam")
 >");
     ctxt.G.add_edge(1,2);
     ctxt.py_stmts("print(G.nodes())");
     // **(^*(& corner case with properties
     writeln(ctxt.G.edges.opCall());
}

// setup.py

from celerid.support import setup, Extension

setup(
     name="thimble",
     version='1.0',
     ext_modules=[
     Extension("thimble", ["thimble.d"],
     build_deimos=True
         )
     ],
)

// command line:

 > python setup.py pydexe --compiler=gdc
 > ./thimble

[1L, 2L, 'spam']
[(1L, 2L)]


More information about the Digitalmars-d-learn mailing list