Greengrass Install Script Re-installs pip3 components every time

1

I have a greengrass component, written in python, with an "Install" script of:

"Install": "pip3 install --user boto3 && pip3 install --user awsiotsdk"

Every time I re-install this component, it re-installs both boto3 and awsiotsdk. I would have assumed that the pip3 install command would work once, at the first installation, and from then on, that the ggc_user would have those packages installed locally.

Are pip3 installations per-user (in this case the ggc_user), or per-component installation?

질문됨 2년 전1057회 조회
4개 답변
2

Hello, The install command will be run every time Greengrass starts up and anytime the component version changes. Since a version of boto3/awsiotsdk already exists, pip's logic should be to simply move on. So yes, while the command will be run, it shouldn't actually be installing anything unless it is missing.

Using the --user flag with pip is the right thing to do as it will install the library for the current user. The user will be ggc_user or whatever user that component is configured to run as. Components be default will run as ggc_user, but they can be set in a deployment to run as any other user on the system.

AWS
전문가
답변함 2년 전
0

My suggestion would be to use a virtual environment in the work directory of the component. This has 2 advantages:

  1. you can easily check for the existence of the virtual environment and skip the installation
  2. with the --user flag, if you deploy other components using conflicting libraries, the last component installed will win. By using virtual environments you avoid such situations.

You can see this approach applied here https://github.com/awslabs/aws-greengrass-labs-jupyterlab/blob/main/recipes/aws.greengrass.labs.jupyterlab.yaml

AWS
전문가
답변함 2년 전
0

The component recipe also allow the use of a "skipif" key, so the script may be skipped if an executable is found or if a file exists. This could be use to skip the installation if the pip package file exists. Doc: https://docs.aws.amazon.com/greengrass/v2/developerguide/component-recipe-reference.html

TSpark
답변함 2년 전
0

My recipe skips awsiot because its already installed. I am trying to upgrade from 1.11.2 to 1.11.3. Is there a way to force an update?

답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠