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

Python script shebang cleanup #37859

Merged

Conversation

jbytheway
Copy link
Contributor

Summary

SUMMARY: None

Purpose of change

There was some inconsistency and ambiguity in how the #! lines in the CDDA Python scripts were written. Want to fix that to make them easier to use and understand.

Describe the solution

  • In #! line, always use /usr/bin/env to find Python executable.
  • When the script only works in Python 2, make sure the #! line says python2.
  • If the script has a #! line, make sure it is executable.
  • Don't have a space after the #!.

Describe alternatives you've considered

There are a couple of scripts still that don't specify Python 2 vs 3. Based on comments in the script, it looks like this is deliberate and they should work in both. @mlangsdorf would you prefer that they do specify a particular Python version?

I considered writing something for the CI to check our Python scripts satisfied these properties, but it didn't seem quite worth it.

Testing

Some scripts can now display a help message when they previously couldn't (because my default Python is 3). I didn't actually try to use the scripts 'for real', though.

Additional context

I was about to write a new Python script and came across these inconsistencies which bugged me.

These tools used '#!/usr/bin/env python' but required Python 2.  This no
longer works on systems where Python 3 is the default.

Tweak their #! lines to specify python2.
The scripts in tools/gfx_tools were running /bin/python directly.  The
convention is to use /usr/bin/env python, so switch to that.

Also, they were not executable.  Make them so.
Some Python scripts had #! lines but were not executable.  Make them so.
Co-Authored-By: anothersimulacrum <[email protected]>
@ifreund ifreund added the [Python] Code made in Python label Feb 9, 2020
@ZhilkinSerg ZhilkinSerg merged commit f2881ee into CleverRaven:master Feb 9, 2020
@jbytheway jbytheway deleted the python_script_shebang_cleanup branch February 10, 2020 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Python] Code made in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants