Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Framework] Add error detection to python pip calls #5927

Merged
merged 6 commits into from
Jan 27, 2024

Conversation

mreid-tt
Copy link
Contributor

@mreid-tt mreid-tt commented Nov 15, 2023

Description

This proposed framework update aims to rectify issues associated with Python-based package installations. Specifically, it addresses a situation where, in the presence of installation errors, the system erroneously reports a successful installation to the user.

Fixes #5926

Checklist

  • Build rule all-supported completed successfully
  • Any needed documentation is updated/created

Type of change

  • Bug fix
  • Includes small framework changes

@mreid-tt mreid-tt requested a review from th0ma7 November 15, 2023 01:58
@mreid-tt mreid-tt self-assigned this Nov 15, 2023
Comment on lines 78 to 81
if ! python3 -m pip install --upgrade pip; then
echo "Error: Python upgrade failed" 1>&2
exit 1
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should only log, but not exit on error.
the following set_unix_permissions is mandatory for DSM 6.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the error is already logged now as shown in the referenced issue. the challenge is that it results in a package being installed that is incomplete (see #5926).

Copy link
Contributor

@th0ma7 th0ma7 Dec 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggesting we always refer back to python packaged pip version... such as:

read -r -a PIP_VERSION 2>/dev/null <<< $(python3 -m pip --version)
[ "${PIP_VERSION[1]}" ] && PIP="pip==${PIP_VERSION[1]}" || PIP="pip"
if ! python3 -m pip install --upgrade ${PIP}; then
   echo "Error: Python upgrade failed" 1>&2
fi

This way when ever we update pip in python3x, module installation will also follow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the error is already logged now as shown in the referenced issue. the challenge is that it results in a package being installed that is incomplete (see #5926).

And I am also tempted to agree, to do exit 1 to confirm package did not installed correctly.

@hgy59
Copy link
Contributor

hgy59 commented Dec 3, 2023

We should add an error detection in validate_preinst (when ever possible) to prevent the installation in such situations.

If the validate_preinst succeeds but the later installation fails, we must handle such error ("exit 1" ?) in a way, that the DSM Package Center "repair" button (introduced with DSM 7) works as expected. I.e. the package repair will retry the download and if it succeeds the package should be correctly installed.

Since the DSM Developer Guide is not very useful, we need some investigations to make this work.
The only hint in this guide is, that such packages are not able to start.
We have to find out first, whether the repair tries to start the package only, or any of the preinstall and postinstall functions are called again.

@th0ma7
Copy link
Contributor

th0ma7 commented Dec 3, 2023

Agreed but that's outside the scope of this pr. I believe that what was the intent in here is now captured and could be merged.

Additional optimizations you propose should be done in a separate pr.

@mreid-tt
Copy link
Contributor Author

@th0ma7, is this good to merge now?

@th0ma7
Copy link
Contributor

th0ma7 commented Dec 13, 2023

I believe so. @hgy59 are you fine with comments above and merging?

@th0ma7 th0ma7 self-assigned this Jan 10, 2024
@th0ma7
Copy link
Contributor

th0ma7 commented Jan 10, 2024

Catching-up... @hgy59 any issues with merging this? (see comments above)

@hgy59
Copy link
Contributor

hgy59 commented Jan 10, 2024

I would drop the whole pip check/update/downgrade stuff in install_python_virtualenv ()

and add --disable-pip-version-check to pip install command in install_python_wheels ()

@th0ma7
Copy link
Contributor

th0ma7 commented Jan 11, 2024

and add --disable-pip-version-check to pip install command in install_python_wheels ()

forgot, good call, done

@th0ma7
Copy link
Contributor

th0ma7 commented Jan 11, 2024

I would drop the whole pip check/update/downgrade stuff in install_python_virtualenv ()

I've been re-reading the code and indeed it's useless: its been using default python3 from PATH and checking its pip version, thus updating if not matching default python3 package (being called in the first place from PATH).

Now only printing it out.

(untested yet but change is trivial) - feel free to test in the meantime.

@th0ma7 th0ma7 force-pushed the framework-python-wheels-fix branch from dfce23a to 2d20333 Compare January 27, 2024 14:48
Copy link
Contributor

@th0ma7 th0ma7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this morning and working well. It actually expedite the installation a bit.

@th0ma7 th0ma7 merged commit bc2327f into SynoCommunity:master Jan 27, 2024
1 check passed
@mreid-tt mreid-tt deleted the framework-python-wheels-fix branch January 27, 2024 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Framework] Install failures for Python packages
3 participants