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

Pygame pollutes stdio with spammy message #985

Closed
Julian-O opened this issue Jul 14, 2019 · 7 comments
Closed

Pygame pollutes stdio with spammy message #985

Julian-O opened this issue Jul 14, 2019 · 7 comments

Comments

@Julian-O
Copy link
Contributor

Unfortunately, the maintainer of the PyGame repository has decided to add a spammy message that gets printed to stdio the first time pygame is imported. Complaints about it have been dismissed with feeble justifications.

MoviePy will import pygame if it is installed, meaning command-line MoviePy applications will start up with an unrelated message about PyGame, which is likely to confuse most users.

Fortunately, a workaround has now been included:

If the PYGAME_HIDE_SUPPORT_PROMPT environment variable is present, the message is not displayed.

Asking direct clients to create this variable before importing pygame is onerous, but expecting a client of MoviePy to understand what they need to do to suppress it is worse.

Therefore, I recommend that in each of the places that PyGame is imported, the environment variable be set first.

(Perhaps a single shim file that does this work-around and imports PyGame in one place would be better. Then the shim could be imported instead of pygame in each location.)

Expected Behavior

 >>> from moviepy.editor import VideoFileClip
 >>>

Actual Behavior

 >>> from moviepy.editor import VideoFileClip
 pygame 1.9.6
 Hello from the pygame community. https://www.pygame.org/contribute.html
 >>>

Steps to Reproduce the Problem

Install pygame>=1.9.5 and moviepy, and run import moviepy.editor for example.

@Julian-O
Copy link
Contributor Author

Perhaps a single shim file that does this work-around and imports PyGame in one place would be better.

I became so enamoured with this idea, I have made it its own package:

https://github.com/Julian-O/pygamesilent

Hasn't hit PyPi yet.

@CanadaHonk
Copy link

You can just put:

os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"

Before importing moviepy. It does require importing os though, I suppose.

@Julian-O
Copy link
Contributor Author

Yes, you can do that. With sufficient commenting to explain the intent of this magic incantation, and repeated in every location that pygame is imported.

I have gone with a shim based on DRY principles.

@tburrows13
Copy link
Collaborator

I'd agree with @Oj18, which is just a one-liner inside moviepy.editor

@Julian-O
Copy link
Contributor Author

Julian-O commented Oct 1, 2019

I am not going to the mat on this one, but it is at least three lines repeated identically in three files.

@tburrows13
Copy link
Collaborator

Yes, fair point. I'll let someone else decide between #985 and #1017.

@tburrows13
Copy link
Collaborator

#1017 has been merged 👍🏼

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

No branches or pull requests

3 participants