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


Groups > comp.lang.python > #55377 > unrolled thread

Re: Running code from source that includes extension modules

Started byStefan Behnel <stefan_ml@behnel.de>
First post2013-10-02 21:15 +0200
Last post2013-10-02 21:15 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Running code from source that includes extension modules Stefan Behnel <stefan_ml@behnel.de> - 2013-10-02 21:15 +0200

#55377 — Re: Running code from source that includes extension modules

FromStefan Behnel <stefan_ml@behnel.de>
Date2013-10-02 21:15 +0200
SubjectRe: Running code from source that includes extension modules
Message-ID<mailman.649.1380741319.18130.python-list@python.org>
Michael Schwarz, 02.10.2013 17:38:
> I've just started looking into distutils because I need to write an
> extension module in C (for performance reasons) and distutils seems to be
> the most straight-forward way.
> 
> I've had success building a C file into a Python extension module using
> "python setup.py build" but I am wondering what the recommended way for
> using that module during development is. While writing Python code I'm used
> to just run the code from the source directory. But the built extension
> module's .so of course does not just end up on sys.path magically.
> 
> 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.

You can run

	python setup.py build_ext -i

That will build your extension module and install it right into your
package structure.

BTW, if you use Cython instead of plain C, you can use pyximport to get
on-the-fly extension module builds during development.

Stefan

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web