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


Groups > comp.lang.python > #97437

Re: packaging code with compiled libraries

Path csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <oscar.j.benjamin@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'binary': 0.05; 'setup.py': 0.07; 'subject:code': 0.07; 'cc:addr:python-list': 0.09; "'build'": 0.09; 'logic': 0.09; 'separately': 0.09; 'python': 0.10; 'def': 0.13; 'appropriate': 0.14; '"python': 0.16; 'cc:name:python list': 0.16; 'compile.': 0.16; 'compilers': 0.16; 'conditional': 0.16; 'libs': 0.16; 'packaging.': 0.16; 'phase,': 0.16; 'run(self):': 0.16; 'setup.py.': 0.16; 'setuptools': 0.16; 'subject:packaging': 0.16; 'wrote:': 0.16; '(not': 0.20; 'library': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'extension': 0.20; 'work,': 0.21; 'libraries': 0.22; 'code,': 0.23; 'code.': 0.23; 'bit': 0.23; 'seems': 0.23; 'tim': 0.24; 'header:In-Reply-To:1': 0.24; 'install': 0.25; 'installed': 0.26; 'distribute': 0.27; 'mostly': 0.27; 'packaging': 0.27; 'wonder': 0.27; 'question': 0.27; 'message-id:@mail.gmail.com': 0.27; 'idea': 0.28; 'subdirectory': 0.29; 'code': 0.30; '[1]': 0.32; 'run': 0.33; 'class': 0.33; 'url:python': 0.33; 'platforms.': 0.33; 'handle': 0.34; 'skip:d 20': 0.34; 'running': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'should': 0.36; 'url:org': 0.36; 'modules': 0.36; 'subject:: ': 0.37; 'building': 0.38; 'files': 0.38; 'copying': 0.38; 'end': 0.39; 'url:en': 0.39; 'subject:with': 0.40; 'called': 0.40; 'some': 0.40; 'care': 0.60; 'your': 0.60; 'share': 0.61; 'yes': 0.62; 'course': 0.62; 'needing': 0.63; 'more': 0.63; 'brain': 0.66; 'interest.': 0.79; '(once': 0.84; 'bundling': 0.84; 'oscar': 0.84; 'precompiled': 0.84; 'wheel': 0.84; 'wheels': 0.84; 'absolutely': 0.88; 'url:latest': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=OMdrBKWT5NinMar8kUeb1K+0nk5fyS0ISB/2pK3TYX4=; b=BS5LdP/d4pRMDqh8cWvWox8WwsdcX/+RAW1DOSUuNJK5GC8ZWJaU9t7VItdP3FXUu8 iyFT2hz0Y5ITt5WgvNzV2Ehzz0i9Cp1VBORh4kWWFrJOUYD+HiqWZQTErEXMQBtvsQTx vidCU/Tf/obysZDC4dSL+RlXswI7oQTEpL0+hQ8xNXsv87xya2ZtLucbb13lMZlHbwn2 Ixi1IK1mq8K4g0JeifYDMXa1huRWXIxO3QRuHCAZTuqs9ZmWOEO653pOKQd6i6JJ7BkH i4G/VRR/yPzkFHxVQvToqu0j4hxgUIHLQ1570NH3gPo5FFRnArj2ncJI/Q3ju16ckQyT UqOQ==
X-Received by 10.112.141.228 with SMTP id rr4mr11709666lbb.48.1444125058697; Tue, 06 Oct 2015 02:50:58 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <67eacdc3-e493-44fe-859c-51b016995a3a@googlegroups.com>
References <67eacdc3-e493-44fe-859c-51b016995a3a@googlegroups.com>
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Date Tue, 6 Oct 2015 10:50:39 +0100
Subject Re: packaging code with compiled libraries
To Tim <jtim.arnold@gmail.com>
Cc Python List <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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.415.1444125066.28679.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1444125066 news.xs4all.nl 23787 [2001:888:2000:d::a6]:52995
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:97437

Show key headers only | View raw


On 5 October 2015 at 20:43, Tim <jtim.arnold@gmail.com> wrote:
>
> I have a package I want to share but have a question about packaging.
>
> Mostly the package is pure python code, but it also requires some binary libraries (*.so, *.dll, *.dylib).  I want to bundle these libs so users don't have to compile. The package will run on *nix/windows/mac platforms.
>
> Currently I handle this in setup.py. In the 'build' phase, I copy the platform-specific libs to a subdirectory called 'libs'.
>
>     class MyBuilder(build_py):
>         def run(self):
>             conditional logic for copying
>             appropriate library files to 'libs'
>             etc etc.
>             build_py.run()
>
> And that seems to work, but after reading more from the Python Packaging Authority, I wonder if that is the right way.  Should I be using wheels instead?
> I think my brain fried a little bit while going through the doc.

The idea of a wheel is that you want to distribute your code fully
precompiled to end users who will be able to install it without
needing any C compilers etc. Of course this requires you to supply
wheels for each platform of interest. If this is what you want to do
then yes absolutely use wheels. Note that if you have installed
setuptools and wheel and you use setuptools in your setup.py then
building a wheel is as simple as running "python setup.py bdist_wheel"
(once your setup.py is complete).

If the binary libraries in question are extension modules then you
should just declare them as such in your setup.py and
distutils/setuptools/wheel will take care of bundling them into the
wheel.

If the binary libraries are not extension modules and you are building
them separately (not using distutils) then you can declare them as
"datafiles" [1] so that they will be bundled into your wheel and
installed alongside your python code.

[1] https://packaging.python.org/en/latest/distributing/#package-data

--
Oscar

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


Thread

packaging code with compiled libraries Tim <jtim.arnold@gmail.com> - 2015-10-05 12:43 -0700
  Re: packaging code with compiled libraries Rustom Mody <rustompmody@gmail.com> - 2015-10-05 19:42 -0700
  Re: packaging code with compiled libraries Tim Golden <mail@timgolden.me.uk> - 2015-10-06 08:16 +0100
  Re: packaging code with compiled libraries Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2015-10-06 10:50 +0100
    Re: packaging code with compiled libraries Tim <jtim.arnold@gmail.com> - 2015-10-06 08:40 -0700

csiph-web