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


Groups > comp.lang.python > #44471

Adding new source types to distutils?

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <jeanpierreda@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'ideally': 0.04; 'resulting': 0.04; 'attribute': 0.07; 'distutils': 0.07; 'arguments': 0.09; 'bindings': 0.09; 'linker': 0.09; 'wrote': 0.14; '"right"': 0.16; 'build_ext': 0.16; 'command.': 0.16; 'does,': 0.16; 'doing,': 0.16; 'exists,': 0.16; 'subclass': 0.16; 'subclassing': 0.16; 'subject:Adding': 0.16; 'subject:distutils': 0.16; 'do,': 0.16; 'do.': 0.18; 'module': 0.19; 'replacing': 0.19; 'seems': 0.21; 'code,': 0.22; 'lets': 0.24; 'prototype': 0.24; 'specify': 0.24; 'source': 0.25; 'extension': 0.26; 'possibility': 0.29; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'code': 0.31; 'too.': 0.31; 'this.': 0.32; 'running': 0.33; 'sources': 0.33; "i'd": 0.34; 'could': 0.34; 'problem': 0.35; "can't": 0.35; 'received:google.com': 0.35; 'add': 0.35; 'useful': 0.36; 'subject:?': 0.36; 'should': 0.36; 'subject:new': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'list,': 0.38; 'that,': 0.38; 'does': 0.39; 'bad': 0.39; 'to:addr:python.org': 0.39; 'remove': 0.60; 'is.': 0.60; 'tell': 0.60; 'new': 0.61; 'kind': 0.63; 'such': 0.63; 'accessed.': 0.84; 'compiles': 0.84; 'subject:source': 0.84; 'terrible': 0.84; 'toy': 0.84; 'absolutely': 0.87
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:from:date:message-id:subject:to :content-type; bh=b92MEPv1hXBaT71NOmc/HwtjmQJPEdolmSqqyhEJXHI=; b=Gc7LwNQER9ZYGVfC92wXUP1hzBBxzRAgXuLD8t7TfcVFUG1dpiEAPOG+mA1wUXmKKS a0mzVMaANmu22FStFtjRcFWCthgehAo1IvEab5mFvKpqkASaQI/Ad5VbStea4uaWjUF1 xLtlVNRtlWPTTcpNsDOlaH5S1meAKztb//lpsZXHOdZe11ufLt/jJ+oU9zX3ruo9oLMQ Hv4z4hW3z3KAA/DE9qLl1oT7UhiDCIE0wyjgluQSvln82KhnUkfdpK1m9pDWL5d0Zbb/ ++CLPbwRXfX51JrThcVFGHwt3xfKYyb/P+i00qqduMVtf7OCXTkrYpUOzwN+fGRC5mb4 1V9A==
X-Received by 10.220.66.212 with SMTP id o20mr4476118vci.2.1367171790944; Sun, 28 Apr 2013 10:56:30 -0700 (PDT)
MIME-Version 1.0
From Devin Jeanpierre <jeanpierreda@gmail.com>
Date Sun, 28 Apr 2013 13:55:47 -0400
Subject Adding new source types to distutils?
To "comp.lang.python" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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.1137.1367171799.3114.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1367171799 news.xs4all.nl 15908 [2001:888:2000:d::a6]:35650
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44471

Show key headers only | View raw


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.

One possibility is that I subclass Cython's build_ext if it exists,
otherwise distutils'. This seems like it's a terrible thing to do,
since it locks out any Cython alternative that I may not be aware of,
and any other kind of extension to build_ext. I don't know what else I
can do.

(What I ended up doing, just so that I could actually write the code,
was write a new Extension type that compiles the rust code when the
extra_link_args attribute is accessed. This is, of course, absolutely
terrible, and only barely does the job. It's not as bad as what I had
to do to get the linker arguments from rustc, though...)

-- Devin

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


Thread

Adding new source types to distutils? Devin Jeanpierre <jeanpierreda@gmail.com> - 2013-04-28 13:55 -0400

csiph-web