Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #55373

Re: Running code from source that includes extension modules

Subject Re: Running code from source that includes extension modules
From Michael Schwarz <michi.schwarz@gmail.com>
Date 2013-10-02 20:42 +0200
References <CABdB9Z4rvKmO0bdZrmBd4Cy6b1OJyzkFMNpwmrR=k55J1X39wg@mail.gmail.com> <C3C8E6C3C22C46268786D02E27C5C170@dev.null>
Newsgroups comp.lang.python
Message-ID <mailman.647.1380739372.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 2013-W40-3, at 19:15, "Gisle Vanem" <gvanem@yahoo.no> wrote:

> "Michael Schwarz" <michi.schwarz@gmail.com> wrote:
> 
>> So how do I run my code so it will find the built extension module? Do I
>> pass the output directory on the command line manually or is there some
>> other solution? I would like to still be able to run the code from the
>> source directory as I'm using PyCharm to edit and debug the code.
> 
> Doesn't Python on Linux (I assume that since you mentioned the module's .so)
> support having current-dir '.' in $PYTHONPATH? Works fine on Windows.

I'm running OS X 10.8 and Python 3.2, sorry I didn't mention it. But I assume the differences to Linux are minimal.

The current directory is included in sys.path, otherwise I wouldn't be able to import modules in the same directory. But the problem is that the built extension module is in a subdirectory of the "build" directory:

$ find -name '*.so'
./build/lib.macosx-10.8-x86_64-3.2/_foo.so

And so I can't import it without manually adding that directory to sys.path. I'm convinced, someone on this list can shout at me, telling me that I got it completely backwards and that there's a straightforward and intuitive way to develop extension modules!

Michael

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Running code from source that includes extension modules Michael Schwarz <michi.schwarz@gmail.com> - 2013-10-02 20:42 +0200

csiph-web