python setuptools install_requires is ignored when overriding cmdclass

The same problem just happened to me. It somehow seems like something triggers setuptools to do an ‘old-style install’ with distutils, which indeed does not support install_requires.

You call which calls run(self) in setuptools/setuptools/command/, line 51-74

def run(self):
    # Explicit request for old-style install?  Just do it
    if self.old_and_unmanageable or self.single_version_externally_managed:

    # Attempt to detect whether we were called from setup() or by another
    # command.  If we were called by setup(), our caller will be the
    # 'run_command' method in 'distutils.dist', and *its* caller will be
    # the 'run_commands' method.  If we were called any other way, our
    # immediate caller *might* be 'run_command', but it won't have been
    # called by 'run_commands'.  This is slightly kludgy, but seems to
    # work.
    caller = sys._getframe(2)
    caller_module = caller.f_globals.get('__name__','')
    caller_name = caller.f_code.co_name

    if caller_module != 'distutils.dist' or caller_name!='run_commands':
        # We weren't called from the command line or setup(), so we
        # should run in backward-compatibility mode to support bdist_*
        # commands.

I’m not sure whether this behaviour is intended, but replacing



should solve your problem. At least it works for me, but I would also appreciate a more detailed answer. Thanks!

Leave a Comment