"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/unit/plugins/v2/test_python.py" between
snapcraft-4.5.1.tar.gz and snapcraft-4.5.2.tar.gz

About: Snapcraft is a build and packaging tool that makes it easy to incorporate components from different sources and build technologies or solutions.

test_python.py  (snapcraft-4.5.1):test_python.py  (snapcraft-4.5.2)
skipping to change at line 66 skipping to change at line 66
assert plugin.get_build_environment() == { assert plugin.get_build_environment() == {
"PATH": "${SNAPCRAFT_PART_INSTALL}/bin:${PATH}", "PATH": "${SNAPCRAFT_PART_INSTALL}/bin:${PATH}",
"SNAPCRAFT_PYTHON_INTERPRETER": "python3", "SNAPCRAFT_PYTHON_INTERPRETER": "python3",
"SNAPCRAFT_PYTHON_VENV_ARGS": "", "SNAPCRAFT_PYTHON_VENV_ARGS": "",
} }
_FIXUP_BUILD_COMMANDS = [ _FIXUP_BUILD_COMMANDS = [
dedent( dedent(
"""\ """\
for e in $(find "${SNAPCRAFT_PART_INSTALL}" -type f -executable) for e in $(find "${SNAPCRAFT_PART_INSTALL}" -type f -executable)
do do
if head -1 "${e}" | grep -q "python" ; then sed -i "1 s|^#\\!${SNAPCRAFT_PYTHON_VENV_INTERP_PATH}.*$|#\\!/us
sed \\ r/bin/env ${SNAPCRAFT_PYTHON_INTERPRETER}|" "${e}"
-r '1 s|#\\!.*python3?$|#\\!/usr/bin/env '${SNAPCRAFT_PYTHON done
_INTERPRETER}'|' \\ """
-i "${e}"
fi
done
"""
), ),
dedent( dedent(
"""\ """\
interp_path="${SNAPCRAFT_PART_INSTALL}/bin/${SNAPCRAFT_PYTHON_INTERPRETE determine_link_target() {
R}" opts_state="$(set +o +x)"
if [ -f "${interp_path}" ]; then interp_dir="$(dirname "${SNAPCRAFT_PYTHON_VENV_INTERP_PATH}")"
current_link=$(readlink "${interp_path}") target="${SNAPCRAFT_PYTHON_PATH}"
# Change link if in $SNAPCRAFT_PART_INSTALL for dir in "${SNAPCRAFT_PART_INSTALL}" "${SNAPCRAFT_STAGE}"; do
if echo "${current_link}" | grep -q "${SNAPCRAFT_PART_INSTALL}" ; th if echo "${SNAPCRAFT_PYTHON_PATH}" | grep -q "${dir}"; then
en target="$(realpath --strip --relative-to="${interp_dir}"
new_link=$(realpath \\ \\
--strip \\ "${SNAPCRAFT_PYTHON_PATH}")"
--relative-to="${SNAPCRAFT_PART_INSTALL}/bin/" \\ break
"${current_link}") fi
rm "${interp_path}" done
ln -s "${new_link}" "${interp_path}" echo "${target}"
fi eval "${opts_state}"
fi }
"""
target="$(determine_link_target)"
ln -sf "${target}" "${SNAPCRAFT_PYTHON_VENV_INTERP_PATH}"
"""
), ),
] ]
def test_get_build_commands(): def test_get_build_commands():
class Options: class Options:
constraints = list() constraints = list()
requirements = list() requirements = list()
python_packages = list() python_packages = list()
plugin = PythonPlugin(part_name="my-part", options=Options()) plugin = PythonPlugin(part_name="my-part", options=Options())
assert ( assert (
plugin.get_build_commands() plugin.get_build_commands()
== [ == [
'"${SNAPCRAFT_PYTHON_INTERPRETER}" -m venv ${SNAPCRAFT_PYTHON_VENV_A 'SNAPCRAFT_PYTHON_PATH="${SNAPCRAFT_PYTHON_PATH:-$(which "${SNAPCRAF
RGS} ' T_PYTHON_INTERPRETER}")}"',
'"${SNAPCRAFT_PART_INSTALL}"', '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 .", "[ -f setup.py ] && pip install -U .",
] ]
+ _FIXUP_BUILD_COMMANDS + _FIXUP_BUILD_COMMANDS
) )
def test_get_build_commands_with_all_properties(): def test_get_build_commands_with_all_properties():
class Options: class Options:
constraints = ["constraints.txt"] constraints = ["constraints.txt"]
requirements = ["requirements.txt"] requirements = ["requirements.txt"]
python_packages = ["pip", "some-pkg; sys_platform != 'win32'"] python_packages = ["pip", "some-pkg; sys_platform != 'win32'"]
plugin = PythonPlugin(part_name="my-part", options=Options()) plugin = PythonPlugin(part_name="my-part", options=Options())
assert ( assert (
plugin.get_build_commands() plugin.get_build_commands()
== [ == [
'"${SNAPCRAFT_PYTHON_INTERPRETER}" -m venv ${SNAPCRAFT_PYTHON_VENV_A 'SNAPCRAFT_PYTHON_PATH="${SNAPCRAFT_PYTHON_PATH:-$(which "${SNAPCRAF
RGS} ' T_PYTHON_INTERPRETER}")}"',
'"${SNAPCRAFT_PART_INSTALL}"', '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}"',
"pip install -c 'constraints.txt' -U pip 'some-pkg; sys_platform != '\"'\"'win32'\"'\"''", "pip install -c 'constraints.txt' -U pip 'some-pkg; sys_platform != '\"'\"'win32'\"'\"''",
"pip install -c 'constraints.txt' -U -r 'requirements.txt'", "pip install -c 'constraints.txt' -U -r 'requirements.txt'",
"[ -f setup.py ] && pip install -c 'constraints.txt' -U .", "[ -f setup.py ] && pip install -c 'constraints.txt' -U .",
] ]
+ _FIXUP_BUILD_COMMANDS + _FIXUP_BUILD_COMMANDS
) )
 End of changes. 4 change blocks. 
32 lines changed or deleted 40 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)