I'm working with a setup.py that creates a whole bunch of SWIG interface files during the build_ext step. This needs to run first, because subsequent build steps need a full list of the python files to work properly (like copying the python files to the package directory, creating the egg, creating the sources list, etc.).
This is what currently happens when you do setup.py install
:
running install
running bdist_egg
running egg_info
running install_lib
running build_py
running build_ext
The build_py
step tries to copy all the python files that it finds to the build directory. Those files don't exist until build_ext
runs (swig creates a bunch of .py files).
This answer recommends changing sub_commands
but that didn't appear to do anything.
I tried just subclassing the install
command class like this to run build_ext
before anything else:
class Build_ext_first(setuptools.command.install.install):
def run(self):
self.run_command("build_ext")
super(Build_ext_first, self).run()
..and then working it in to setup with cmdclass
:
setup(
...
cmdclass = {'install' : Build_ext_first}
)
But that didn't work because super
doesn't work with old-style classes and install
apparently doesn't inherit from object
.
How do I do build_ext
first?