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

make --no-input flag work with install git+http and git+ssh schemes #13228

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

iTrooz
Copy link

@iTrooz iTrooz commented Feb 21, 2025

Fix #12718

Copy link
Member

@ichard26 ichard26 left a comment

Choose a reason for hiding this comment

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

This does fix the specific problem in the original issue, but shouldn't we set these environment variables globally so every Git command is run with interactivity turned off?

We could achieve this by overriding the run_command() method in the Git VSC class to extend the environment before delegating to the parent run_command() method.

I'm also not a huge fan of relying on os.environ to pass configuration state down to the VSC code, but I haven't investigated how painful it would be to do it properly with the current VSC backend design. This is accepted practice in the codebase, so unless it's easy to pass the configuration state properly, I wouldn't bother redoing this.

@ichard26
Copy link
Member

Also hi! Welcome to pip. Let us know if you need anything. Thanks for your interest in improving pip!

@iTrooz
Copy link
Author

iTrooz commented Feb 23, 2025

shouldn't we set these environment variables globally so every Git command is run with interactivity turned off?
We could achieve this by overriding the run_command() method in the Git VSC class to extend the environment before delegating to the parent run_command() method.

Seems like a good idea ! Done

I'm also not a huge fan of relying on os.environ to pass configuration state down to the VSC code, but I haven't investigated how painful it would be to do it properly with the current VSC backend design. This is accepted practice in the codebase, so unless it's easy to pass the configuration state properly, I wouldn't bother redoing this.

Unfortunately, this looks complicated to do (seems like I have to pass the data through 15 stack calls or so) and I don't have enough experience with the codebase to make a change like that the right way

Copy link
Member

@ichard26 ichard26 left a comment

Choose a reason for hiding this comment

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

The new test is going to hang ~forever if we ever regress which is not great. Unfortunately, scripttest (the testing framework that implements the subprocess functionality) doesn't support the timeout subprocess parameter.

Looking into the state of scripttest, it turns out that being a pip maintainer gives me the commit bit on pypa/scripttest as well. The project seems rather unmaintained (although not-last-release-from-2013 level of unmaintained). I'll take a look at the project at some point.

@iTrooz
Copy link
Author

iTrooz commented Feb 23, 2025

I just tried, and removing the --no-input flag make the test fail instead of hanging, probably because you disable stdin in the tests

Plus, you also have a test above to check for the authentication prompt:

def test_prompt_for_authentication(

@ichard26
Copy link
Member

The point of this bugfix is to ensure --no-input is respected by any Git or SSH commands pip invokes. Removing that from the test (and relying on lack of a STDIN) would render the test pointless IMO. We should update scripttest to support a timeout parameter and use that instead.

@iTrooz
Copy link
Author

iTrooz commented Feb 23, 2025

I'm not sure what the problem is. Why would the test hang in any case ? stdin is always disabled (AFAIK), so the test will never actually prompt for a username/password. It will just display the prompt message, and then crash because stdin will not be available.

@ichard26
Copy link
Member

ichard26 commented Feb 23, 2025

I dunno. It seems to hang locally if I keep the test but revert the fix ¯\_(ツ)_/¯

@iTrooz
Copy link
Author

iTrooz commented Feb 23, 2025

Oh ! Indeed it does. I'm not sure why. I will investigate, thank you

@iTrooz
Copy link
Author

iTrooz commented Feb 23, 2025

Okay, I found out the problem ! git clone uses terminal device instead of stdin to prompt for username/password, that's why you still get the prompt locally. I'm not sure how to properly fix this

@iTrooz
Copy link
Author

iTrooz commented Feb 23, 2025

Ok, done ! I used start_new_session=True to isolate the process and disable terminal device prompts
Now even in case of regressing, the test won't hang locally (and shouldn't hang in the server in any case since there won't be a terminal associated to the test, I think ?)

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.

pip --no-input will still prompt for git and ssh
2 participants