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

PIP runner introduction #6072

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

richtja
Copy link
Contributor

@richtja richtja commented Nov 26, 2024

This PR introduces a new dependency runner called pip. With this runner, avocado will be able to manipulate with python packages in test environment based on the test dependency configuration. The runner will install pip into the test environment, and then it can call pip install or pip uninstall commands. For example, this feature can be used for running coverage.py inside different environments than process.

Copy link

codecov bot commented Nov 26, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 9 lines in your changes missing coverage. Please review.

Please upload report for BASE (master@56b8eec). Learn more about missing BASE report.
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
avocado/plugins/runners/pip.py 80.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #6072   +/-   ##
=========================================
  Coverage          ?   68.67%           
=========================================
  Files             ?      203           
  Lines             ?    21970           
  Branches          ?        0           
=========================================
  Hits              ?    15087           
  Misses            ?     6883           
  Partials          ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@richtja richtja force-pushed the pip_runner branch 2 times, most recently from 35f623a to f7e4e99 Compare November 26, 2024 13:42
@richtja richtja force-pushed the pip_runner branch 2 times, most recently from 38d12f6 to 8266190 Compare November 28, 2024 09:31
Copy link
Contributor

@clebergnu clebergnu left a comment

Choose a reason for hiding this comment

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

Hi @richtja ,

This is a great idea, and a have a few comments for immediate changes, and somethings that can/should follow up later.

As for immediate changes, I mentioed the req-pac bits in the selftests.

Also, please add this variant to the nrunner-interface suite in selftests/check.py. While at it, add a selftests/functional/nrunner_interface.py.data/recipe_runnable_pip.json file (which can be a link or copy of the existing example file in this PR), but consider its actual execution and network access, etc.

It'd also be nice to add a test with a dependency as an example. I found that it's possible to do something like examples/tests/dependency_pip.py:

from avocado import Test, fail_on


class Pip(Test):
    """
    :avocado: dependency={"type": "pip", "name": "pip", "action": "install"}
    """

    @fail_on(ImportError)
    def test(self):
        import pip

It may seem pointless, but it's something that can run pretty much in every Python environment without causing disruption (installing extra modules).

As future points:

  1. This looks like it could be part of a replacement for the use of eggs for Avocado's own automatic deployment
  2. It would be nice to support the location destination where the pip modules will be installed (such as a venv). This would be especially useful for Avocado's own automatic deployment.
  3. Support for multiple pip packages instead of one at a time

selftests/functional/runner_pip.py Outdated Show resolved Hide resolved
selftests/functional/runner_pip.py Outdated Show resolved Hide resolved
This commit introduces a new dependency runner called `pip`. With this
runner, avocado will be able to manipulate with python packages in test
environment based on the test dependency configuration. The runner will
install pip into the test environment, and then it can call `pip
install` or `pip uninstall` commands. For example, this feature can be
used for running `coverage.py` inside different environments than
process.

Signed-off-by: Jan Richter <[email protected]>
@richtja
Copy link
Contributor Author

richtja commented Jan 2, 2025

Hi @clebergnu, thanks for your review. I have updated the PR based on your suggestions. Please have a look.

@richtja richtja requested a review from clebergnu January 2, 2025 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Review Requested
Development

Successfully merging this pull request may close these issues.

2 participants