Exemplo n.º 1
0
def test_get_build_commands():
    class Options:
        constraints = list()
        requirements = list()
        python_packages = list()

    plugin = PythonPlugin(part_name="my-part", options=Options())

    plugin.get_build_commands() == [
        '"${SNAPCRAFT_PYTHON_INTERPRETER}" -m venv ${SNAPCRAFT_PYTHON_VENV_ARGS} '
        '"${SNAPCRAFT_PART_INSTALL}"',
        '. "${SNAPCRAFT_PART_INSTALL}/bin/activate"',
        "[ -f setup.py ] && pip install  -U .",
    ] + _FIXUP_BUILD_COMMANDS
Exemplo n.º 2
0
def test_get_build_commands_with_all_properties():
    class Options:
        constraints = ["constraints.txt"]
        requirements = ["requirements.txt"]
        python_packages = ["pip"]

    plugin = PythonPlugin(part_name="my-part", options=Options())

    plugin.get_build_commands() == [
        '"${SNAPCRAFT_PYTHON_INTERPRETER}" -m venv ${SNAPCRAFT_PYTHON_VENV_ARGS} '
        '"${SNAPCRAFT_PART_INSTALL}"',
        '. "${SNAPCRAFT_PART_INSTALL}/bin/activate"',
        "pip install -c 'constraints.txt' -U pip",
        "pip install -c 'constraints.txt' -U -r 'requirements.txt'",
        "[ -f setup.py ] && pip install -c 'constraints.txt' -U .",
    ] + _FIXUP_BUILD_COMMANDS
Exemplo n.º 3
0
def test_get_build_commands():
    class Options:
        constraints = list()
        requirements = list()
        python_packages = list()

    plugin = PythonPlugin(part_name="my-part", options=Options())

    assert (plugin.get_build_commands() == [
        'SNAPCRAFT_PYTHON_PATH="${SNAPCRAFT_PYTHON_PATH:-$(which "${SNAPCRAFT_PYTHON_INTERPRETER}")}"',
        'SNAPCRAFT_PYTHON_PATH="$(readlink -e "${SNAPCRAFT_PYTHON_PATH}")"',
        '"${SNAPCRAFT_PYTHON_PATH}" -m venv ${SNAPCRAFT_PYTHON_VENV_ARGS} "${SNAPCRAFT_PART_INSTALL}"',
        'SNAPCRAFT_PYTHON_VENV_INTERP_PATH="${SNAPCRAFT_PART_INSTALL}/bin/${SNAPCRAFT_PYTHON_INTERPRETER}"',
        "[ -f setup.py ] && pip install  -U .",
    ] + _FIXUP_BUILD_COMMANDS)
Exemplo n.º 4
0
def test_get_build_commands_with_all_properties():
    class Options:
        constraints = ["constraints.txt"]
        requirements = ["requirements.txt"]
        python_packages = ["pip", "some-pkg; sys_platform != 'win32'"]

    plugin = PythonPlugin(part_name="my-part", options=Options())

    assert (plugin.get_build_commands() == [
        '"${SNAPCRAFT_PYTHON_INTERPRETER}" -m venv ${SNAPCRAFT_PYTHON_VENV_ARGS} "${SNAPCRAFT_PART_INSTALL}"',
        'SNAPCRAFT_PYTHON_VENV_INTERP_PATH="${SNAPCRAFT_PART_INSTALL}/bin/${SNAPCRAFT_PYTHON_INTERPRETER}"',
        "pip install -c 'constraints.txt' -U pip 'some-pkg; sys_platform != '\"'\"'win32'\"'\"''",
        "pip install -c 'constraints.txt' -U -r 'requirements.txt'",
        "[ -f setup.py ] && pip install -c 'constraints.txt' -U .",
    ] + _FIXUP_BUILD_COMMANDS)