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


Groups > comp.lang.python > #55386

Re: Running code from source that includes extension modules

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <michi.schwarz@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'output': 0.05; 'debug': 0.07; 'distutils': 0.07; 'subject:code': 0.07; 'setup.py': 0.09; 'subject:modules': 0.09; 'python': 0.11; 'language,': 0.12; 'project,': 0.12; '"python': 0.16; 'build_ext': 0.16; 'configuring': 0.16; "module's": 0.16; 'module?': 0.16; 'non- python': 0.16; 'sys.path': 0.16; 'do,': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'module': 0.19; 'stefan': 0.19; 'written': 0.21; 'seems': 0.21; 'command': 0.22; 'to:name:python-list@python.org': 0.22; 'install': 0.23; '(by': 0.24; 'directory.': 0.24; 'simpler': 0.24; "i've": 0.25; 'source': 0.25; 'extension': 0.26; 'pass': 0.26; '(for': 0.26; 'header:In-Reply-To:1': 0.27; 'michael': 0.29; 'wondering': 0.29; "i'm": 0.30; 'code': 0.31; 'received:10.0.0': 0.31; 'subject:that': 0.31; 'file': 0.32; 'run': 0.32; 'running': 0.33; 'development.': 0.33; 'plain': 0.33; 'actual': 0.34; 'maybe': 0.34; 'subject:from': 0.34; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'building': 0.35; 'there': 0.35; 'really': 0.36; 'charset:us-ascii': 0.36; 'thanks': 0.36; 'received:10.0': 0.36; 'received:10': 0.37; 'performance': 0.37; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'is.': 0.60; 'manually': 0.60; 'most': 0.60; 'success': 0.61; 'course': 0.61; 'header:Message-Id:1': 0.63; 'for!': 0.84; 'subject:source': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:message-id:mime-version:subject:date:references :to:in-reply-to; bh=l90h0dW+IBf3d9hf+73dcBZjofn+p6TzxfyrSs1/gbA=; b=xvbSxrf3kJRu6lUNprIHovAGKf9K9bzQBlXcd+JW6Ovj8V6zWjL0wtT2UDAHfzA6QR ELDnb04j/phm50H1zj/a6dQlhWPfMaMTPk9kO4fNce77x+MMQAM5qni8oGGiyg19ZRjP tyl3AM7ttZh03xDRTVEf1VU2YX1crNGhUmX8ZpeCMYLlT6Q/LOl2eJY+PbyMVcc5vdOh chQfY9i7B//WvW7pXJ1QSipjqrcaxUDJSAZsMBX9wF0SAVWUjH5dlgxAAH64Uf/MfN9U 5FXEuzY7/2uKg6u9le0Q38msL65VnqcPJgWuynuC64sptdIn4YDMI/SZLExOXlMjsl9f zYWQ==
X-Received by 10.14.37.4 with SMTP id x4mr7243188eea.16.1380752880869; Wed, 02 Oct 2013 15:28:00 -0700 (PDT)
From Michael Schwarz <michi.schwarz@gmail.com>
Content-Type multipart/signed; boundary="Apple-Mail=_C7766E77-C6A3-453A-989B-7CCAB96EEEEC"; protocol="application/pkcs7-signature"; micalg=sha1
Mime-Version 1.0 (Mac OS X Mail 6.6 \(1510\))
Subject Re: Running code from source that includes extension modules
Date Thu, 3 Oct 2013 00:28:18 +0200
References <CABdB9Z4rvKmO0bdZrmBd4Cy6b1OJyzkFMNpwmrR=k55J1X39wg@mail.gmail.com> <l2hrbf$uc9$1@ger.gmane.org>
To "python-list@python.org" <python-list@python.org>
In-Reply-To <l2hrbf$uc9$1@ger.gmane.org>
X-Mailer Apple Mail (2.1510)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.656.1380752882.18130.python-list@python.org> (permalink)
Lines 105
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1380752882 news.xs4all.nl 15994 [2001:888:2000:d::a6]:51955
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:55386

Show key headers only | View raw


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

On 2013-W40-3, at 21:15, Stefan Behnel <stefan_ml@behnel.de> wrote:

> 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.

This is really very much what I was looking for! I've set up PyCharm to run this command (by configuring it as an "external tool", maybe there's a simpler way), before running the actual application. \o/

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

I will look into that too, that sounds very convenient. But am I right, that to use Cython the non-Python code needs to be written in the Cython language, which means I can't just copy&past C code into it? For my current project, this is exactly what I do, because the C code I use already existed.

Thanks
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-03 00:28 +0200

csiph-web