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


Groups > comp.lang.python > #44472

Re: Adding new source types to distutils?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
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; 'python.': 0.02; 'ideally': 0.04; 'resulting': 0.04; 'compiler': 0.07; 'distutils': 0.07; 'bindings': 0.09; 'linker': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'setup.py': 0.09; 'wrote': 0.14; '"right"': 0.16; 'build_ext': 0.16; 'command.': 0.16; 'does,': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'scripts.': 0.16; 'subclassing': 0.16; 'subject:Adding': 0.16; 'subject:distutils': 0.16; 'extensions': 0.16; 'files.': 0.16; 'flexibility': 0.16; 'code.': 0.18; 'module': 0.19; 'passing': 0.19; 'replacing': 0.19; 'stefan': 0.19; 'header:User-Agent:1': 0.23; 'case.': 0.24; 'days,': 0.24; 'lets': 0.24; 'prototype': 0.24; 'replace': 0.24; 'specify': 0.24; 'versions': 0.24; 'source': 0.25; 'options': 0.25; 'compiled': 0.26; 'extension': 0.26; 'pass': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; '(which': 0.31; 'gives': 0.31; 'code': 0.31; 'easier': 0.31; 'too.': 0.31; 'about.': 0.31; 'allows': 0.31; 'this.': 0.32; 'running': 0.33; 'sources': 0.33; "i'd": 0.34; 'problem': 0.35; "can't": 0.35; 'something': 0.35; 'received:84': 0.35; 'add': 0.35; 'useful': 0.36; 'subject:?': 0.36; 'similar': 0.36; 'should': 0.36; 'example,': 0.37; 'so,': 0.37; 'list': 0.37; 'subject:new': 0.38; 'problems': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'list,': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'users': 0.40; 'remove': 0.60; 'future': 0.60; 'above,': 0.60; 'is.': 0.60; 'tell': 0.60; 'new': 0.61; 'simply': 0.61; 'such': 0.63; 'more': 0.64; 'due': 0.66; 'between': 0.67; 'influence': 0.74; 'yourself': 0.78; 'avoids': 0.84; 'conflicts': 0.84; 'received:arcor-ip.net': 0.84; 'received:pools.arcor-ip.net': 0.84; 'subject:source': 0.84; 'toy': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Stefan Behnel <stefan_ml@behnel.de>
Subject Re: Adding new source types to distutils?
Date Sun, 28 Apr 2013 20:24:58 +0200
References <CABicbJK7DUYie9i4_seSCbs-Zq-DZ_cLQHHKZ7qLySqZX0pVDQ@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host dslb-084-056-034-012.pools.arcor-ip.net
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5
In-Reply-To <CABicbJK7DUYie9i4_seSCbs-Zq-DZ_cLQHHKZ7qLySqZX0pVDQ@mail.gmail.com>
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1138.1367173525.3114.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1367173525 news.xs4all.nl 15994 [2001:888:2000:d::a6]:39306
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44472

Show key headers only | View raw


Devin Jeanpierre, 28.04.2013 19:55:
> Last night I wrote a toy prototype module that lets one compile Rust
> crates into extension modules for Python. The problem is, I don't know
> the "right" way to do this. Ideally I'd just want to tell build_ext
> that there's a new source type I want to handle (.rc and .rs), and
> also tell distutils that it should handle it by running the code that
> I specify (which can compile the .rs/.rc files, remove them from the
> sources list, and add the resulting object files and such to the
> linker arguments)
> 
> The problem is that, as I understand it, the way to do this is
> subclassing and then replacing the build_ext command. At least, that's
> what Cython does. The problem is, that's what Cython does, so if I do
> that, it means you can't use Cython and Rust together -- that's bad,
> because Cython would be useful for writing bindings to Rust crates,
> too. So I don't want to write my own subclass. In place of that, I
> don't know what the right approach is.

That approach is discouraged for Cython. The compiler comes with a
cythonize() function these days, which users can simply call from their
setup.py scripts. It spits out a list of Extensions that you can pass into
setup(). So, for example, you can say

    extensions = cythonize('mypackage/*.pyx')

and it would do the right thing. You can also pass configuration options
into cythonize() to influence the way Cython translates your code.
Alternatively, you can pass in a list of Extensions and cythonize() will
process that and replace .pyx files by the compiled .c files. That also
makes it easier to build without having Cython installed, by simply
replacing the .pyx files by .c yourself and passing the Extensions directly
into setup(). And it allows for more complex Extension configurations that
Cython doesn't have to care about.

You might want to do something similar in your case. It gives users much
more flexibility when using source code preprocessors and also avoids
conflicts between packages like the one you describe above, or problems
with future versions of distutils due to fragile build setups.

Stefan

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


Thread

Re: Adding new source types to distutils? Stefan Behnel <stefan_ml@behnel.de> - 2013-04-28 20:24 +0200

csiph-web