[Distutils] Swig build_py ran before build_ext

Jari Pennanen jari.pennanen at gmail.com
Tue Dec 22 10:49:22 CET 2009

Well, if that is so, I will paste my workaround for the sake of
completeness if other people come here to wonder:

   #!/usr/bin/env python
   from distutils.core import setup, Extension
   from distutils.command.build_py import build_py

   dist = setup(...)

   # Rerun the build_py to ensure that swig generated py files are also copied
   build_py = build_py(dist)

Btw, this could be mentioned in
http://docs.python.org/distutils/setupscript.html since SWIG is rather
common tool... it took me a notable time to figure this out.

(Sorry about duplicate mail)

2009/12/22 David Cournapeau <cournape at gmail.com>:
> On Tue, Dec 22, 2009 at 7:16 AM, Jari Pennanen <jari.pennanen at gmail.com> wrote:
>> Hi!
>> I have old/new problem, once mentioned in 2004 at this same mailing
>> list ( http://mail.python.org/pipermail/distutils-sig/2004-March/003807.html
>> ) but surely that implementation is bad... But the problem persists, I
>> use SWIG and had to Google all over to only find out build order
>> cannot be changed.
>> Someone should implement build_order keyword argument to setup, e.g.:
>>    setup(..., build_order=['build_ext', 'build_py'])
>> If some orders are missing, like in above example: build_clib,
>> build_scripts, they would be appended as last. Anyways, the point is
>> make the build order customizable through setup keyword.
> This would need to be tested/confirmed on real packages, but I am
> afraid it would break a lot of packages, especially the ones extending
> distutils.
> cheers,
> David

  Tmi: Jari Pennanen
  Y-tunnus: 1867270-2
  Puh: 050 4911400

More information about the Distutils-SIG mailing list