您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

覆盖cmdclass时将忽略python setuptools install_requires

覆盖cmdclass时将忽略python setuptools install_requires

我也遇到了同样的问题。似乎以某种方式触发setuptools进行“旧式安装” distutils,但确实不支持install_requires

您可以在setuptools / setuptools / command / install.py,第51-74行中调用install.run(self),后者会调用run(self)

https://bitbucket.org/pypa/setuptools/src/8e8c50925f18eafb7e66fe020aa91a85b9a4b122/setuptools/command/install.py?at=default

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

    # 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.
        _install.run(self)
    else:
        self.do_egg_install()

我不确定这种行为是否有意,但是要替换

install.run(self)

install.do_egg_install()

应该可以解决您的问题。至少它对我有用,但是我也希望得到更详细的答案。谢谢!

python 2022/1/1 18:47:59 有372人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶