-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Disallow --user installs if site.ENABLE_USER_SITE is False. #8796
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
base: main
Are you sure you want to change the base?
Conversation
@uranusjr Do you still think this is the correct thing to do? @pelson Apologies for no one ever replying, pip is currently maintained by only volunteers, I'd like to clear out our backlog of PRs, but I don't have much time either. However if this is agreed to be the right approach, it would need atleast one test, and and update to the docs. |
@notatallshaw - totally understand 👍 In terms of the change being proposed here, I still stand by the fact that it doesn't make any sense to install to I'd be fine to add a test here, if you have a suggestion on the best way to go about it (perhaps point me to an existing test that I can adapt?) - do you want an integration test, or a unit test? |
@pelson I spent five minutes on writing a test. I think something along the lines of this should work: diff --git a/tests/functional/test_install_user.py b/tests/functional/test_install_user.py
index 0b1e025cb..436e519bc 100644
--- a/tests/functional/test_install_user.py
+++ b/tests/functional/test_install_user.py
@@ -120,6 +120,19 @@ class Tests_UserSite:
"visible in this virtualenv." in result.stderr
)
+ def test_install_user_nositepkgs_fails(
+ self, script: PipTestEnvironment, data: TestData
+ ) -> None:
+ script.environ["PYTHONNOUSERSITE"] = "1"
+ run_from = data.packages.joinpath("FSPkg")
+ result = script.pip(
+ "install", "--user", curdir, cwd=run_from, expect_error=True
+ )
+ assert (
+ "Can not perform a '--user' install. User site-packages are "
+ "disabled for this Python."
+ ) in result.stderr
+
@pytest.mark.network
def test_install_user_conflict_in_usersite(
self, script: PipTestEnvironment |
@pelson since you were active recently, are you interested in repicking this up or not? I can push a test and changes to the docs if needed. |
34bb799
to
a4d4850
Compare
a4d4850
to
b62ef2b
Compare
Thanks for the test @ichard26 - I added it directly and rebased. |
Windows CI failure is because of this: #13598, but Ubuntu test failure looks like because of this PR:
|
b62ef2b
to
8cb5ae6
Compare
Spent quite a bit of time trying to get a test for this. Since we are running For now, I just create a temporary script with the right setup, and call main in the subprocess. |
#8794 highlighted that
site.ENABLE_USER_SITE
was being ignored whenpip install --user
is being set (when not in a virtualenvironment). This is in contrast to the behaviour forvirtualenvs
which raises anInstallationError
since the installed packages wouldn't be on thesys.path
afterwards.This MR brings about the symmetry by preventing the user from being able to do
--user
whensite.ENABLE_USER_SITE
is set. I wasn't sure on the best testing strategy for this change, so didn't implement any tests at this point (happy to take advice).