Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'output': 0.05; 'debug': 0.07; 'distutils': 0.07; 'subject:code': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'setup.py': 0.09; 'subject:modules': 0.09; 'python': 0.11; '"python': 0.16; 'build_ext': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; "module's": 0.16; 'module?': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sys.path': 0.16; 'code.': 0.18; 'module': 0.19; 'stefan': 0.19; 'seems': 0.21; 'command': 0.22; 'install': 0.23; 'header :User-Agent:1': 0.23; 'directory.': 0.24; "i've": 0.25; 'source': 0.25; 'extension': 0.26; 'pass': 0.26; '(for': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'michael': 0.29; 'wondering': 0.29; "i'm": 0.30; 'code': 0.31; 'subject:that': 0.31; 'file': 0.32; 'run': 0.32; 'development.': 0.33; 'plain': 0.33; 'subject:from': 0.34; 'received:84': 0.35; 'but': 0.35; 'building': 0.35; 'there': 0.35; 'performance': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'is.': 0.60; 'manually': 0.60; 'most': 0.60; 'success': 0.61; 'course': 0.61; 'received :arcor-ip.net': 0.84; 'received:pools.arcor-ip.net': 0.84; 'subject:source': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Stefan Behnel Subject: Re: Running code from source that includes extension modules Date: Wed, 02 Oct 2013 21:15:04 +0200 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: dslb-084-056-007-135.pools.arcor-ip.net User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130803 Thunderbird/17.0.8 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1380741319 news.xs4all.nl 15965 [2001:888:2000:d::a6]:35960 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:55377 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