Ensure build_ext runs before build_py

The setup.py build and install commands run a number of subcommands, including build_ext, which runs SWIG to generate openbabel.py, and build_py, which copies openbabel.py and other python sources to the build directory.

The default ordering is for build_py to be run before build_ext, causing errors as build_py attempts to copy openbabel.py before it exists. This change ensures build_ext is always run first at the start of both the build and install commands.
This commit is contained in:
Matt Swain
2014-01-20 18:07:07 +00:00
parent b94f4b7f83
commit d6a44bcd40

View File

@@ -1,8 +1,10 @@
#!/usr/bin/env python
from setuptools import setup, Extension
import os
import subprocess
import sys
from distutils.command.build import build
from setuptools.command.install import install
from setuptools import setup, Extension
__author__ = 'Noel O\'Boyle'
@@ -52,6 +54,20 @@ obextension = Extension('_openbabel',
libraries=['openbabel'])
class CustomBuild(build):
"""Ensure build_ext runs first in build command."""
def run(self):
self.run_command('build_ext')
build.run(self)
class CustomInstall(install):
"""Ensure build_ext runs first in install command."""
def run(self):
self.run_command('build_ext')
self.do_egg_install()
setup(name='openbabel',
version=__version__,
author=__author__,
@@ -61,6 +77,7 @@ setup(name='openbabel',
description='Python interface to the Open Babel chemistry library',
long_description=long_description,
zip_safe=True,
cmdclass={'build': CustomBuild, 'install': CustomInstall},
py_modules=['openbabel', 'pybel'],
ext_modules=[obextension],
classifiers=[