Skip to content

Check SONiC dependencies before installation.#13850

Merged
xumia merged 13 commits intosonic-net:masterfrom
liushilongbuaa:test-msrc-submodule
Mar 2, 2023
Merged

Check SONiC dependencies before installation.#13850
xumia merged 13 commits intosonic-net:masterfrom
liushilongbuaa:test-msrc-submodule

Conversation

@liushilongbuaa
Copy link
Copy Markdown
Contributor

@liushilongbuaa liushilongbuaa commented Feb 17, 2023

Why I did it

SONiC related packages shouldn't be intalled from Pypi.
It is security compliance requirement.

How I did it

Check SONiC related packages when using setup.py.

How to verify it

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211

Description for the changelog

Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@liushilongbuaa liushilongbuaa changed the title test msrc fix for submodule Block setup.py to install sonic built submodules. Feb 23, 2023
@liushilongbuaa liushilongbuaa changed the title Block setup.py to install sonic built submodules. Check SONiC dependencies before installation. Feb 27, 2023
@liushilongbuaa liushilongbuaa marked this pull request as ready for review February 27, 2023 07:49
@xumia xumia requested a review from qiluo-msft February 27, 2023 08:02
Comment thread src/sonic-config-engine/setup.py Outdated
'sonic-yang-mgmt>=1.0',
'sonic-yang-models>=1.0'
]
sonic_dependencies += ['sonic-yang-mgmt', 'sonic-yang-models']
Copy link
Copy Markdown
Collaborator

@qiluo-msft qiluo-msft Feb 27, 2023

Choose a reason for hiding this comment

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

sonic_dependencies

sonic_dependencies could be generated based on dependencies. The rule should be:

  1. match pattern sonic-*
  2. remove the trailing version comparison.
  3. the generation does not depend on python version. #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We can't generate from dependencies. Something like swsssdk didn't have prefix sonic-*.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

sonic_dependencies could be ground truth, including the package names and version comparison.

  1. install_requires could take the package names and version comparison. No need to repeat each package.
  2. get_distribution check could take the package names, and fetch local versions, and compare with expected condition.

Comment thread src/sonic-config-engine/setup.py Outdated
try:
pkg_resources.get_distribution(package)
except pkg_resources.DistributionNotFound:
print(package+" is not found!")
Copy link
Copy Markdown
Collaborator

@qiluo-msft qiluo-msft Feb 27, 2023

Choose a reason for hiding this comment

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

print

Print 2 error messages to stderr. #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It should be used by python2 and python3.
we can't use print. Use sys.stderr.write instead.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

you can use print(msg, file=sys.stderr)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

python2 doesn't support it.

Comment thread src/sonic-config-engine/setup.py Outdated
@xumia xumia merged commit dcce42c into sonic-net:master Mar 2, 2023
xumia pushed a commit to xumia/sonic-buildimage-1 that referenced this pull request Mar 10, 2023
Why I did it
SONiC related packages shouldn't be intalled from Pypi.
It is security compliance requirement.

How I did it
Check SONiC related packages when using setup.py.

How to verify it
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.

3 participants