Пользовательская команда setup.py apt-get выдает код ошибки 100 - PullRequest
0 голосов
/ 03 мая 2020

Я создаю файл setup.py в формате apache, рекомендованном для луча: (Apache Луч 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

Есть идеи, что мне не хватает?

thans, eilalan

1 Ответ

0 голосов
/ 05 мая 2020

Я пересоздал ваш сценарий и получил ту же ошибку, что и вы, в версии ApacheBeam SDK 2.20.0. Когда я сменил версию на 2.16.0 и 2.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 есть ошибка, вы можете заполнить форму , чтобы сообщить об ошибке в IssueTracker.

Надеюсь, вы найдете приведенные выше сведения полезными.

...