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

Ensure executability for all Python with a __main__ #121

Merged
merged 1 commit into from
Jun 26, 2019

Conversation

jameysharp
Copy link
Contributor

Neither of the scripts I needed to run to reproduce the robotfindskitten results was executable, which strikes me as an easily-eliminated point of friction, so here's a patch to do so.

The way I did it had the side effect of making the interpreter lines identical across all of the scripts. (Some of the existing scripts included an extra, but harmless, space.)

For each Python script with a __main__ block, I ran each of these three steps:

  • delete existing interpreter if any: sed -i '2,$b; /^#!/d'
  • insert interpreter: sed -i '1i#!/usr/bin/env python3'
  • set executable permission bit: chmod a+x

To apply those steps to the right files, I prefixed each command with:

git grep -lFw __main__ '*.py' ':^:**/__main__.py' | xargs

Neither of the scripts I needed to run to reproduce the robotfindskitten
results was executable, which strikes me as an easily-eliminated point
of friction, so here's a patch to do so.

The way I did it had the side effect of making the interpreter lines
identical across all of the scripts. (Some of the existing scripts
included an extra, but harmless, space.)

For each Python script with a __main__ block, I ran each of these three
steps:

- delete existing interpreter if any: `sed -i '2,$b; /^#!/d'`
- insert interpreter: `sed -i '1i#!/usr/bin/env python3'`
- set executable permission bit: `chmod a+x`

To apply those steps to the right files, I prefixed each command with:

git grep -lFw __main__ '*.py' ':^:**/__main__.py' | xargs
Copy link
Contributor

@TheDan64 TheDan64 left a comment

Choose a reason for hiding this comment

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

Great idea - thanks for the PR!

@TheDan64 TheDan64 merged commit 48a5612 into immunant:master Jun 26, 2019
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.

2 participants