[Distutils] Re: build subcommand order

Thomas Heller theller at python.net
Thu Mar 25 14:49:26 EST 2004


Dan Schult <dschult at mail.colgate.edu> writes:

> I have been using swig 1.3 along with distutils to make a package
> and I'm having trouble with the subcommand order for "build".
> The order is set at the bottom of command.build.py to be:
> build_py
> build_clibs
> build_ext
> build_scripts
>
> My problem is that swig gets run during build_ext and creates a 
> class definition in a new *.py file.  That python file needs to 
> be moved into the staging area, but build_py doesn't find it 
> because it is created AFTER build_py is run.
>
> I propose a simple change of the order of the build commands
> so that build_py is last.  
>
> It is unlikely that build_py would make any actions that 
> affect the other command, but quite likely (especially given 
> the nature of Swig) that other actions may create
> python files.
>
> I know one can always use:
> python setup.py build_ext build_py
> but I don't think every person that is packaging
> (or unpackaging) a swig distribution should have to
> document that --or figure it out.

You can change the order in the setup script yourself. Here is what I do
in one of them. This is because my build_py command already requires the
extension modules built in build_ext:

class my_build(build.build):
    # different order: build_ext *before* build_py, so that
    # build_py can already use ctypes!
    sub_commands = [('build_ext',     build.build.has_ext_modules),
                    ('build_py',      build.build.has_pure_modules),
                    ('build_clib',    build.build.has_c_libraries),
                    ('build_scripts', build.build.has_scripts),
                   ]

setup(name="ctypes",
      ext_modules = extensions,
      packages = packages,
      version="0.6.0",
      cmdclass = {'test': test,
                  'build_py': my_build_py,
                  'build': my_build
                  },
      **options
      )

Thomas




More information about the Distutils-SIG mailing list