|
Revision 64, 2.0 kB
(checked in by KirkMcDonald, 2 years ago)
|
PydMain?; build improvements (no more colliding object files); examples and docs updated to use PydMain?
|
| Line | |
|---|
| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
|---|
| 2 |
<html> |
|---|
| 3 |
<head> |
|---|
| 4 |
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
|---|
| 5 |
<link href="pyd.css" rel="stylesheet" type="text/css"> |
|---|
| 6 |
<title>Pyd: Connecting D and Python</title> |
|---|
| 7 |
</head> |
|---|
| 8 |
|
|---|
| 9 |
<body> |
|---|
| 10 |
%(nav)s |
|---|
| 11 |
<div id="content"> |
|---|
| 12 |
|
|---|
| 13 |
<h1>Pyd</h1> |
|---|
| 14 |
<p>Pyd is a library for the D programming language that wraps the raw <a href="http://docs.python.org/api/api.html">Python/C API</a> with a cleaner, simpler interface. It makes exposing raw D functions and classes to Python almost trivially simple. It bears certain similarities to <a href="http://www.boost.org/libs/python/doc/">Boost.Python</a>, and indeed Boost.Python is a major influence on Pyd. Pyd was written by Kirk McDonald.</p> |
|---|
| 15 |
|
|---|
| 16 |
<p>Pyd also comes with its own extension to Python's <a href="http://docs.python.org/dist/dist.html">distutils</a>, called <a href="celerid.html">CeleriD</a>, making the building of extension modules quite easy. CeleriD was originally written by David Rushby and is currently maintained by Kirk McDonald.</p> |
|---|
| 17 |
|
|---|
| 18 |
<p>Pyd includes the <code>meta.Nameof</code> package by Don Clugston. The source files meta.Nameof and meta.Demangle are copyright © 2005-2006 Don Clugston.</p> |
|---|
| 19 |
|
|---|
| 20 |
<p>Pyd's Trac page can be found <a href="http://dsource.org/projects/pyd/wiki">here</a>.</p> |
|---|
| 21 |
|
|---|
| 22 |
<p>A simple "hello, world" module might look like this:</p> |
|---|
| 23 |
|
|---|
| 24 |
<pre class="code"><span class="keyword">import</span> pyd.pyd; |
|---|
| 25 |
<span class="keyword">import</span> std.stdio; |
|---|
| 26 |
|
|---|
| 27 |
<span class="keyword">void</span> hello_func() { |
|---|
| 28 |
writefln(<span class="string">"Hello, world!"</span>); |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
<span class="keyword">extern</span> (C) <span class="keyword">void</span> PydMain() { |
|---|
| 32 |
def!(hello_func); |
|---|
| 33 |
module_init(); |
|---|
| 34 |
}</pre> |
|---|
| 35 |
|
|---|
| 36 |
<p>When <a href="celerid.html">compiled</a>, the module can be loaded and used from Python like any other module:</p> |
|---|
| 37 |
|
|---|
| 38 |
<pre class="code">>>> import testdll |
|---|
| 39 |
>>> testdll.hello_func() |
|---|
| 40 |
Hello, world!</pre> |
|---|
| 41 |
|
|---|
| 42 |
</div> |
|---|
| 43 |
|
|---|
| 44 |
</body> |
|---|
| 45 |
</html> |
|---|