pinterface / burgled-batteries

A bridge between Python and Lisp (FFI bindings, etc.)
Other
113 stars 21 forks source link

Change the python path #7

Closed alainux closed 9 years ago

alainux commented 9 years ago

I didn't find anything about this in the code. Can I change the python path from /usr/bin/python to something else? Note this is not my default python used when I type python in the console.

pinterface commented 9 years ago

I'm not really sure what you mean? b-b doesn't use the python executable, it uses the libpython shared library (see DEFINE-FOREIGN-LIBRARY in ffi-interface.lisp). Actually finding the libpython file is delegated to CFFI, which /should/ use whatever search path is appropriate for the underlying system.

Perhaps if you could give me a little more detail about what exactly you're trying to do, I might be able to be more helpful.

alainux commented 9 years ago

What I'm trying to do is reference the music21 library with the python module I'm calling from ccl. I have it installed on the python interpreter I use usually. No idea how to do that with cpython. Thanks for the quick help.

pinterface commented 9 years ago

Okay. I think I understand. It sounds like you want to add the library's path to python's module search path, so "import music21" will find it, yes?

In python itself, that'd be something like: import sys sys.path.append("/path/to/music21")

hopefully it works now

import music21

The most straightforward way to do that in burgled-batteries is basically to wrap the append line in a call to #'RUN: (burgled-batteries:import "sys") (burgled-batteries:run "sys.path.append(\"/path/to/music21\")") ;; hopefully it works now (burgled-batteries:import "music21")

That append-call-in-a-string bit is a bit ugly, but my brain is not working at the moment so I don't recall if there's an easy way to do a direct call to append.

alainux commented 9 years ago

Thank you! this worked