The basic problem is that you're already importing from mydependence
before you're calling the setup()
method. I can see no way in which setuptools (or buildout for that matter) can ignore the ImportError
you will get.
If I look at some example code from, for instance, http://pythonhosted.org/py2app/examples.html I see code like this:
from setuptools import setup
setup(
app=["MyApplication.py"],
setup_requires=["py2app"],
)
Note that there's no import of py2app
. So setup_requires
apparently is a way to load "extensions" to the basic setuptools functionality. It is not a way to circumvent basic python import errors.
Update: see comment below by @MartijnPieters who has a solution in https://stackoverflow.com/a/12061891/27401 .
Martijn's example would look like this in your case:
import setuptools
setuptools.dist.Distribution(dict(setup_requires='mydependence'))
# `setup_requires` is parsed and acted upon immediately;
# from here on out the package `mydependence` is installed
# and importable.
from mydependence import build_ext
setup(
...
install_requires = [
'mydependence',
],
....
)