Code Monkey home page Code Monkey logo

pydmagic's Introduction

PydMagic

Ipython/Jupyter magic for inline D code in a python notebook

Liable to change. Depends on pyd (https://github.com/ariovistus/pyd), mergedict (https://pypi.python.org/pypi/mergedict) and dub (http://code.dlang.org)

To install, just enter

in [1]: %install_ext https://raw.githubusercontent.com/DlangScience/PydMagic/master/pyd_magic.py

in any ipython instance.

To use, first enter

in [2]: %load_ext pyd_magic

then write your pyd extension in a cell marked with %%pyd e.g.

in [3]: %%pyd

        @pdef!() string hello() {
            return "Hello World!";
        }

        @pdef!(Docstring!"takes a single int, returns that int converted to a string")
        string intToStr(int b)
        {
            import std.conv;
            return b.to!string;
        }

        @pdef!(PyName!"binary_zebra") int zebra()
        {
            return 101010101;
        }

        @pdef!() long[] whereExactlyIntegral(double[] data)
        {
            import std.algorithm, std.array;
            return data.filter!(x => x == cast(long)x).map!(x => cast(long)x).array;
        }

        @pdef!()
        struct S
        {
            @pdef!() string bleep = "bloop";
            @pdef!() int bar(int w) { return w * 42; }
        }

and run. After it has finished building, your extension should be automatically imported and ready to use, like so:

in [4]: hello()
out[4]: 'Hello World!'

in [5]: intToStr(435)
out[5]: '435'

in [6]: whereExactlyIntegral([3.0, 2.4, 7.0, 1.001])
out[6]: [3, 7]

in [7]: s = S();
        s.bleep
out[7]: 'bloop'

in [8]: s.bleep = 'blah'
        s.bleep
out[8]: 'blah'

in [9]: s.bar(2)
out[9]: 84

see examples/test.ipynb for an example using numpy arrays.

Builds are cached just like with cython magic. Some basic flags are supported as arguments to %%pyd such as --dub_args, run %%pyd? for more info.

The pdef UDA instructs the extension to wrap the function/type/member for use in python. It takes any template arguments that pyd.pyd.def takes.

dub integration

Adding a dependency on a dub package or any other part of a dub.json is as easy as %%pyd --dub_config={"dependencies":{"someDubPackage":"~>1.2.5"}} and command line arguments to dub can similarly by added with --dub_args. See %%pyd? for more info.

PydMagic provides its own PydMain, so you can't define your own. You can, however, define 2 functions preInit() and postInit(), which PydMagic will call before and after calling pyd's module_init() respectively. You can use this to manually wrap functions, types, anything else pyd supports.

I have tested on OS X and linux. Everything works fine on linux, but on OS X you can't import more than one extension per python instance (including modifications of the same extension) or python will crash. This is due to shared libraries not being supported on OS X. Windows is almost but not quite working.

This code is heavily based on the %%cython magic implementation.

pydmagic's People

Contributors

john-colvin avatar

Stargazers

Jonas Meeuws avatar Vassil Verguilov avatar  avatar Jonathan McHugh avatar Matt Turner avatar Sven Haile avatar Lunardog avatar James Thompson avatar Ilia Ki avatar Shigeki Karita avatar Jon Degenhardt avatar Sebastian Wilzbach avatar Andrei Amatuni avatar Fredrik Boulund avatar Yannick Koechlin avatar Joakim Brännström avatar  avatar  avatar Andrew Spott avatar Laeeth Isharc avatar

Watchers

James Cloos avatar  avatar

pydmagic's Issues

move to sdl for dub / REPL mode

Point 3.1 below is the quick win. 1 and 2 are easy enough. 3.2 needs thought

  1. way to use pdef to wrap entire struct recursively with some UDA to disable members you don't want converted.

  2. should allow use of sdl type package format as well as json as it becomes a pain for maintenance having some stuff in sdl and some in json. a hassle, but not hard.

  3. if you wrap everything with pdef it won't compile if you are compiling code without pydmagic. it's tiresome to have to put a version(pydmagic) around every pdef. could we have that as a build option. in other words when you build your code from the command line with dub without pydmagic then you should have an option to use the pdefs as sugar way to access pyd. but you should also have a build option to ignore them so you can use the same code as pure D with no pyd/pydmagic stuff going on. when pydmagic compiles it from the notebook, it should automatically enable the appropriate build option. so it's transparent.

  1. not sure if its feasible but could we think about some kind of eval or repl mode? this is useful in two ways: 3.1) for quick things, and 3.2) for extended exploration of something.

so 3.1) would avoid having to type in main() and import headers. maybe you could use rdmd for this (it has eval and loop arguments). it's nice if you want to check syntax of something, or see what you actually get from a library function when you call it with some argument. so you can do this:

  rdmd --eval='writefln("%s",sqrt(2.0))'

but not this (it doesn't throw, just doesn't print anything):

  rdmd --eval='sin(100.0)'

you can also do this fwiw (I didn\t know till Andrei pointed it out). may not be helpful for pydmagic though:

  rdmd --loop='writefln("%s",sqrt(line.to!double))'

[user enters] 3.0
[D prints] 1.73205

you could have %pyd_eval and %pyd_loop I guess [if %pyd doesn't take arguments - I don't know jupyter well].

as an aside would be really nice if rdmd worked with dub/code.dlang.org - so you could specify your library in the dub.sdl/dub.json and call it quickly from rdmd.

3.2) at the moment one can maintain state via storing D in python. that's a bit slow which mostly doesn't matter but sometimes might. it also depends on having conversions working and set up for your particular data. and I think if you wrap everything with pdef it won't compile if you are compiling code without pyd. so for example suppose I have:

@pdef auto priceBars(string ticker)
{
  //  go and get the data
  return bars;
}

The line below works in the notebook and will convert bars to python object.
bars=priceBars("NASDAQ/AAPL")

But some D structures may be a pain to write conversions for, and it would be nice to be able to use Jupyter as a pure D repl.

Suppose you wrap D objects as a typed blob. In other words within a %%pyd section at the moment immediate commands are illegal eg:

import std.math;
auto a=sqrt(2.0);
writefln("%s",a);

But within pydmagic you could:

  • a wrap the immediate code in a function and call it
  • recognize the assignment to a global variable, serialize it (msgpack or something else) and store it as a blob in python, along with its name and type information.

Going back to more realistic example:
auto bars=priceBars("NASDAQ/AAPL");

So bars are serialized to msgpack with name and type. That code might turn in to:

@pdef struct PydImmediateVariable
{
  @pdef string name;
  @pdef string typeinfo;
  @pdef ubyte[] data;
}
@pdef PydImmediateVariable pydMagicImmediateBars000001()
{
  //imports
  auto bars=priceBars("NASDAQ/AAPL");
  return bars.toPydImmediateVariable!"bars"; // I guess alias would keep name
}
PydImmediateVariable(string name,T)(T arg)
{
  import msgpack;
  PydImmediateVariable ret;
  ret.data=pack!T(arg)
 ret.name=name;
  ret.typeinfo=T.stringof; // or something
  return ret;
}

then you have python code that calls pydMagicImmediateBars00001() and sticks return value in a blob hashmap indexed by variable name

Then when someone enters immediate code in the next cell:
prettyPrint(bars);

and prettyPrint is defined as:

  void prettyPrint(PriceBar[] bars)
  {}

you can lookup bars, get the type, deserialize it to the write type and call prettyPrint.

still some overhead, but this way you can write pure D in immediate mode.

thoughts? I think it sounds more complicated than it is to actually do. the bits that would take me some time to figure out would just be getting typetuple of global variables. am I missing a barrier that would prevent this working?

I know it sounds fiddly, but interactivity can be super useful. also for new users.

  1. Compiler Error messages. You get a line number, but you can't see line numbers in the ipython notebook for your D code. It shouldn't be hard to find a solution, but I can't think of one immediately.
  2. D returning PNG (sounds, videos etc)
    Python code like matlab can display an image in the notebook. Nice for plotting data etc. I haven't yet tried, but I guess the D code could write to a file and then python code could do:
    from IPython.display import Image
    Image(filename='test.png')

That might be cool as part of a demo anyway, but is there a way to do this directly as a blob without going to disk ?

better messages back from compilation process?

At the moment there are no error messages for me when compilation fails. I know that it fails, but not why. %tb produces traceback on python side, but not stderr during dmd compilation. I realize it's at an early stage, but worth incorporating when you have more time.

Laeeth.

No need to track loaded state.

def load_ipython_extension(ip):
    global _loaded
    if not _loaded:
        ip.register_magics(PydMagics)
        _loaded = True

Any recent enough IPython take care of that for you. Define a unload_ipython_extension if you want a specific step to be take care of during reload.

Python 3 Support

I am working on upgrading the extension to work in Python3.

Just wondering if there is a reason this hasn't been done?

It should work right?

Also, planning on releasing to official extensions to help out with install.

no property needs_shim, call

Am I doing something wrong ?

%%pyd
@PDEF!() struct Test
{
double[] mynumbers;
string[] mystrings;
}

@PDEF!() Test makeTest(double a)
{
Test t;
t.mynumbers=[1.0,2.0,3.9,4.2];
t.mystrings=["why","are2","we","waiting"];
return t;
}

Building _pyd_magic_7c8a7283575fef42aa3d0f1dc803a275 ~master configuration "library", build type debug.
Compiling using dmd...
registering module _pyd_magic_7c8a7283575fef42aa3d0f1dc803a275.object
not registered
registering module _pyd_magic_7c8a7283575fef42aa3d0f1dc803a275.ppyd
not registered
registering module _pyd_magic_7c8a7283575fef42aa3d0f1dc803a275.Test
as aggregate type
registering Test.mynumbers
with class/struct parent
as member
registering Test.mystrings
with class/struct parent
as member
../../home/laeeth/.dub/packages/pyd-0.9.7/infrastructure/pyd/class_wrap.d(1500): Error: no property 'needs_shim' for type 'void'
../../home/laeeth/.dub/packages/pyd-0.9.7/infrastructure/pyd/class_wrap.d(1503): Error: no property 'call' for type 'void'
../../home/laeeth/.dub/packages/pyd-0.9.7/infrastructure/pyd/class_wrap.d(1500): Error: no property 'needs_shim' for type 'void'
../../home/laeeth/.dub/packages/pyd-0.9.7/infrastructure/pyd/class_wrap.d(1503): Error: no property 'call' for type 'void'
../../home/laeeth/.dub/packages/ppyd-0.1.1/ppyd.d(110): Error: template instance pyd.class_wrap.wrap_class!(Test, void, void) error instantiating
../../home/laeeth/.dub/packages/ppyd-0.1.1/ppyd.d(176): instantiated from here: registerAggregateType!("Test", _pyd_magic_7c8a7283575fef42aa3d0f1dc803a275)
../../home/laeeth/.dub/packages/ppyd-0.1.1/ppyd.d(203): instantiated from here: registerModuleScopeSymbol!("Test", _pyd_magic_7c8a7283575fef42aa3d0f1dc803a275)
../../home/laeeth/.cache/ipython/pyd/_pyd_magic_7c8a7283575fef42aa3d0f1dc803a275/_pyd_magic_7c8a7283575fef42aa3d0f1dc803a275.d(5): instantiated from here: registerAll!(_pyd_magic_7c8a7283575fef42aa3d0f1dc803a275)
FAIL ../../home/laeeth/.cache/ipython/pyd/_pyd_magic_7c8a7283575fef42aa3d0f1dc803a275/.dub/build/library-debug-linux.posix-x86_64-dmd_2067-D1EC05E432582762C580ECB068D9114B/ _pyd_magic_7c8a7283575fef42aa3d0f1dc803a275 dynamicLibrary
Error executing command build:
dmd failed with exit code 1.

wrapping templated structs

Hi.

Is it possible to do this using @PDEF?
alias PriceBar_=PriceBar!(PriceBarType(PriceBarFlags.Default),FloatingPoint);
@PDEF!() PriceBar_;

doesnt seem to work.

Thanks.

unicode vs str problem on hello world example

Hi John.

I am using arch linux with python 2.7.9 (Anaconda) on 64 bit machine.

%%pyd

@PDEF!() string hello() {
return "Hello World!";
}


TypeError Traceback (most recent call last)
in ()
----> 1 get_ipython().run_cell_magic(u'pyd', u'', u'\n@pdef!() string hello() {\n return "Hello World!";\n}')

/home/laeeth/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_cell_magic(self, magic_name, line, cell)
2160 magic_arg_s = self.var_expand(line, stack_depth)
2161 with self.builtin_trap:
-> 2162 result = fn(magic_arg_s, cell)
2163 return result
2164

/home/laeeth/.ipython/extensions/pyd_magic.pyc in pyd(self, line, cell)

/home/laeeth/anaconda/lib/python2.7/site-packages/IPython/core/magic.pyc in (f, _a, *_k)
191 # but it's overkill for just that one bit of state.
192 def magic_deco(arg):
--> 193 call = lambda f, _a, *_k: f(_a, *_k)
194
195 if callable(arg):

/home/laeeth/.ipython/extensions/pyd_magic.pyc in pyd(self, line, cell)
149
150 with io.open(pyd_dub_file, 'w', encoding='utf-8') as f:
--> 151 f.write(json.dumps(pyd_dub_json)+'\n')
152 try:
153 os.remove(os.path.join(lib_dir, 'dub.selections.json'))

TypeError: must be unicode, not str

-f doesn't work for me

%%pyd -f

import std.stdio;
import std.string;
import std.conv;

@PDEF!() string zhello() {
return "zHello World!";
}


TypeError Traceback (most recent call last)
in ()
----> 1 get_ipython().run_cell_magic(u'pyd', u'-f', u'\nimport std.stdio;\nimport std.string;\nimport std.conv;\n\n@pdef!() string zhello() {\n return "zHello World!";\n}\n \n')

/home/laeeth/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_cell_magic(self, magic_name, line, cell)
2160 magic_arg_s = self.var_expand(line, stack_depth)
2161 with self.builtin_trap:
-> 2162 result = fn(magic_arg_s, cell)
2163 return result
2164

/home/laeeth/.ipython/extensions/pyd_magic.pyc in pyd(self, line, cell)

/home/laeeth/anaconda/lib/python2.7/site-packages/IPython/core/magic.pyc in (f, _a, *_k)
191 # but it's overkill for just that one bit of state.
192 def magic_deco(arg):
--> 193 call = lambda f, _a, *_k: f(_a, *_k)
194
195 if callable(arg):

/home/laeeth/.ipython/extensions/pyd_magic.pyc in pyd(self, line, cell)
163 # Force a new module name by adding the current time to the
164 # key which is hashed to determine the module name.
--> 165 key += time.time()
166
167 if args.name:

TypeError: can only concatenate tuple (not "float") to tuple

strangeness with std.net.curl import

This fails:
%%pyd -lcurl
import std.stdio;
import std.net.curl;

@PDEF!() string test()
{
download("google.com","/home/laeeth/test.html");
return "hello";
}

This works:
%%pyd -lcurl
import std.stdio;

@PDEF!() string test()
{
import std.net.curl;
download("google.com","/home/laeeth/test.html");
return "hello";
}

Side note - might be good to have some way to have the full output from compiler, as there are so many files for PyD. When compilation fails one just gets a message it has failed, not the full trace (not sure if capturing stderr).

Laeeth

running build
running build_ext
building 'pyd_magic_decc0785a0314a07cd5f0a31d512cf86' extension
gcc -c /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/d/so_ctor.c -fPIC -o build/temp.linux-x86_64-2.7/infra/so_ctor.o
dmd -c -fPIC -version=PydPythonExtension -version=Python_2_4_Or_Later -version=Python_2_5_Or_Later -version=Python_2_6_Or_Later -version=Python_2_7_Or_Later -version=Python_Unicode_UCS4 -debug -I/home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure -ofbuild/temp.linux-x86_64-2.7/infra/temp.o /home/laeeth/.cache/ipython/pyd/pyd_magic_decc0785a0314a07cd5f0a31d512cf86.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/pyd/class_wrap.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/pyd/ctor_wrap.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/pyd/def.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/pyd/embedded.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/pyd/exception.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/pyd/extra.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/pyd/func_wrap.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/pyd/make_object.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/pyd/make_wrapper.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/pyd/op_wrap.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/pyd/pyd.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/pyd/pydobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/pyd/references.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/pyd/struct_wrap.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/pyd/thread.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/util/conv.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/util/typeinfo.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/util/typelist.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/util/multi_index.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/util/replace.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/meta/Demangle.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/meta/Nameof.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/abstract.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/ast.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/boolobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/bufferobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/bytearrayobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/bytesobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/cellobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/ceval.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/classobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/cobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/codecs.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/code.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/compile.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/complexobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/cStringIO.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/datetime.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/descrobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/dictobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/enumobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/errcode.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/eval.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/fileobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/floatobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/frameobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/funcobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/genobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/grammar.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/import
.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/intobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/intrcheck.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/iterobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/listobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/longintrepr.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/longobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/marshal.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/memoryobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/methodobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/modsupport.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/moduleobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/node.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/object.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/objimpl.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/parsetok.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/pgenheaders.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/pyarena.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/pyatomic.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/pycapsule.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/pydebug.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/pyerrors.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/pymem.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/pyport.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/pystate.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/pystrcmp.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/pystrtod.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/Python.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/pythonrun.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/pythread.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/rangeobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/setobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/sliceobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/stringobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/structmember.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/structseq.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/symtable.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/sysmodule.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/timefuncs.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/traceback.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/tupleobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/unicodeobject.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/deimos/python/weakrefobject.d build/temp.linux-x86_64-2.7/infra/pydmain.d /home/laeeth/anaconda/lib/python2.7/site-packages/pyd/infrastructure/d/python_so_linux_boilerplate.d
An exception has occurred, use %tb to see the full traceback.

SystemExit: error: command 'dmd' failed with exit status 1

Traceback not so useful:

%tb

SystemExit Traceback (most recent call last)
in ()
----> 1 get_ipython().run_cell_magic(u'pyd', u'-lcurl', u'import std.stdio;\nimport std.net.curl;\n\n@pdef!() string test()\n{\n download("google.com","/home/laeeth/test.html");\n return "hello";\n}')

/home/laeeth/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_cell_magic(self, magic_name, line, cell)
2160 magic_arg_s = self.var_expand(line, stack_depth)
2161 with self.builtin_trap:
-> 2162 result = fn(magic_arg_s, cell)
2163 return result
2164

/home/laeeth/.ipython/extensions/pyd_magic.pyc in pyd(self, line, cell)

/home/laeeth/anaconda/lib/python2.7/site-packages/IPython/core/magic.pyc in (f, _a, *_k)
191 # but it's overkill for just that one bit of state.
192 def magic_deco(arg):
--> 193 call = lambda f, _a, *_k: f(_a, *_k)
194
195 if callable(arg):

/home/laeeth/.ipython/extensions/pyd_magic.pyc in pyd(self, line, cell)
189 d_lump=True
190 )
--> 191 pyd.support.setup(ext_modules=[extension],script_name="setup.py",script_args=["build", "--build-lib", lib_dir, "-q", "--compiler="+args.compiler])
192
193 if not have_module:

/home/laeeth/anaconda/lib/python2.7/site-packages/pyd/support.pyc in setup(_args, *_kwargs)
228 kwargs['cmdclass'] = {}
229 kwargs['cmdclass']['pydexe'] = build_pyd_embedded_exe
--> 230 base_setup(_args, *_kwargs)

/home/laeeth/anaconda/lib/python2.7/distutils/core.pyc in setup(**attrs)
164 raise
165 else:
--> 166 raise SystemExit, "error: " + str(msg)
167
168 return dist

SystemExit: error: command 'dmd' failed with exit status 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.