【问题标题】:setup.py custom command apt-get throws error code 100setup.py 自定义命令 apt-get 抛出错误代码 100
【发布时间】:2020-05-03 03:38:00
【问题描述】:

我正在使用 apache-beam 推荐的格式创建一个 setup.py 文件:(Apache Beam Python 3.5 SDK 2.20.0)https://github.com/apache/beam/blob/master/sdks/python/apache_beam/examples/complete/juliaset/setup.py

当我有一个 apt-get install 命令时,一切都很好。一旦我添加了两个 apt-get 安装:

工作:

CUSTOM_COMMANDS = [['echo', 'Custom command worked!'],
                   ['apt-get', 'update'],
                   ['apt-get', 'install', '-y', 'unzip']]

解压安装时触发错误:

CUSTOM_COMMANDS = [['echo', 'Custom command worked!'],
                   ['apt-get', 'update'],
                   ['apt-get', 'install', '-y', 'unzip'],
                   ['apt-get', 'install', '-y', 'default-jre'],
                   ['apt-get', 'install', '-y', 'perl']]

错误:

RuntimeError: Command ['apt-get', 'install', '-y', 'unzip'] failed: exit code: 100

知道我错过了什么吗?

谢谢, 爱拉兰

【问题讨论】:

    标签: python-3.x google-cloud-dataflow apache-beam setup.py


    【解决方案1】:

    我重新创建了您的场景,并在 ApacheBeam SDK 2.20.0 版本上遇到了与您相同的错误。当我更改2.16.02.19.0 的版本时,它开始正常工作,没有任何问题。

    这就是我的setup.py 文件的外观:

    from __future__ import absolute_import
    from __future__ import print_function
    
    import subprocess
    
    from distutils.command.build import build as _build
    
    import setuptools
    
    CUSTOM_COMMANDS = [['apt-get', 'update'],
        ['apt-get', '--assume-yes', 'install', 'unzip'],
        ['apt-get', '--assume-yes', 'install', 'default-jre'],
        ['apt-get', '--assume-yes', 'install', 'perl']]
    
    class CustomCommands(setuptools.Command):
        """A setuptools Command class able to run arbitrary commands."""
    
        def initialize_options(self):
            pass
    
        def finalize_options(self):
            pass
    
        def RunCustomCommand(self, command_list):
            print
            'Running command: %s' % command_list
            p = subprocess.Popen(
                command_list,
                stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
            # Can use communicate(input='y\n'.encode()) if the command run requires
            # some confirmation.
            stdout_data, _ = p.communicate()
            print
            'Command output: %s' % stdout_data
            if p.returncode != 0:
                raise RuntimeError(
                    'Command %s failed: exit code: %s' % (command_list, p.returncode))
    
        def run(self):
            for command in CUSTOM_COMMANDS:
                self.RunCustomCommand(command)
    
    REQUIRED_PACKAGES = [
    
    ]
    
    PACKAGE_NAME = 'my_package'
    PACKAGE_VERSION = '0.0.1'
    
    setuptools.setup(
        name=PACKAGE_NAME,
        version=PACKAGE_VERSION,
        description='Test project',
        install_requires=REQUIRED_PACKAGES,
        packages=setuptools.find_packages(),
        cmdclass={
            'build': build,
            'CustomCommands': CustomCommands,
        }
    )
    

    目前,解决方法是使用旧版本的ApacheBeam SDK。我相信ApacheBeam SDK 2.20.0有bug,你可以填写form在IssueTracker上报告bug。

    希望以上信息对您有用。

    【讨论】:

    • 您尚未包含如何从 _build 模块创建 build 类。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-09-30
    • 1970-01-01
    • 2014-02-26
    • 2016-12-18
    • 2018-12-03
    相关资源
    最近更新 更多