Esempio n. 1
0
    def test_get_build_packages(self):
        plugin = PythonPlugin(part_name="my-part", options=lambda: None)

        self.assertThat(
            plugin.get_build_packages(),
            Equals({"findutils", "python3-venv", "python3-dev"}),
        )
Esempio n. 2
0
def test_get_build_environment():
    plugin = PythonPlugin(part_name="my-part", options=lambda: None)

    assert plugin.get_build_environment() == {
        "PATH": "${SNAPCRAFT_PART_INSTALL}/bin:${PATH}",
        "SNAPCRAFT_PYTHON_INTERPRETER": "python3",
        "SNAPCRAFT_PYTHON_VENV_ARGS": "",
    }
Esempio n. 3
0
    def test_get_build_environment(self):
        plugin = PythonPlugin(part_name="my-part", options=lambda: None)

        self.assertThat(
            plugin.get_build_environment(),
            Equals({
                "SNAPCRAFT_PYTHON_INTERPRETER": "python3",
                "SNAPCRAFT_PYTHON_VENV_ARGS": "",
            }),
        )
Esempio n. 4
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_INTERPRETER}" -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)
Esempio n. 5
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)
Esempio n. 6
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
Esempio n. 7
0
    def test_get_build_commands(self):
        class Options:
            constraints = list()
            requirements = list()
            python_packages = list()

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

        self.assertThat(
            plugin.get_build_commands(),
            Equals([
                '"${SNAPCRAFT_PYTHON_INTERPRETER}" -m venv ${SNAPCRAFT_PYTHON_VENV_ARGS} '
                '"${SNAPCRAFT_PART_INSTALL}"',
                '. "${SNAPCRAFT_PART_INSTALL}/bin/activate"',
                "[ -f setup.py ] && pip install  -U .",
            ] + self._FIXUP_BUILD_COMMANDS),
        )
Esempio n. 8
0
def test_get_build_packages():
    plugin = PythonPlugin(part_name="my-part", options=lambda: None)

    assert plugin.get_build_packages() == {
        "findutils", "python3-venv", "python3-dev"
    }