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

Enforce the use of a virtual environment in the integration testing script. #266

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

jatkinson1000
Copy link
Member

@jatkinson1000 jatkinson1000 commented Jan 30, 2025

Closes #265

Enforces use of a venv through setting PIP_REQUIRE_VIRTUALENV=true in the unix tests script.

Running without a virtual environment will give:

./run_test_suite.sh --verbose --integration-only
ERROR: Could not find an activated virtualenv (required).
Error: Process completed with exit code 3.

@jatkinson1000 jatkinson1000 force-pushed the testscript_venv_check branch 2 times, most recently from 8aa4033 to 5819c7c Compare January 30, 2025 11:49
Copy link
Contributor

@jwallwork23 jwallwork23 left a comment

Choose a reason for hiding this comment

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

I can confirm that this does the trick, although I get a different output to what you mention in the PR because the system python first in my path doesn't have pip installed:

$ ./run_test_suite.sh --verbose --integration-only
/usr/local/bin/python: No module named pip

If I switch to python3 -m pip -q install ... in the script then I get the expected error.

@matthewfeickert
Copy link
Contributor

matthewfeickert commented Jan 31, 2025

I can confirm that this does the trick, although I get a different output to what you mention in the PR because the system python first in my path doesn't have pip installed:

$ ./run_test_suite.sh --verbose --integration-only
/usr/local/bin/python: No module named pip

If I switch to python3 -m pip -q install ... in the script then I get the expected error.

The relevant bit is that your not in a virtual environment and there is no need to specify python3. The error that you're getting is a different unrelated one and if you were in a virtual environment python would be python3 already.

You're simply hitting the fact that you're trying to use the system Python for your own personal use, which you should never do. The system Python is its Python and you should act like it doesn't exist to you. If you want to use Python as a developer or user you should install your own.

The PR looks great though!

(edit: Rereading your original comment I think I'm just telling you things that you already know. Sorry for noise in that case. 😬 )

@jwallwork23
Copy link
Contributor

You're simply hitting the fact that you're trying to use the system Python for your own personal use, which you should never do. The system Python is its Python and you should act like it doesn't exist to you. If you want to use Python as a developer or user you should install your own.

Agreed, I usually use virtual environments for everything.

(edit: Rereading your original comment I think I'm just telling you things that you already know. Sorry for noise in that case. 😬 )

No worries!

@jatkinson1000 jatkinson1000 merged commit 783f582 into main Feb 3, 2025
6 of 8 checks passed
@jatkinson1000 jatkinson1000 deleted the testscript_venv_check branch February 3, 2025 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test suite pip installs into current environment
3 participants