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

Add shebang to distro.py #313

Merged
merged 1 commit into from
Nov 25, 2021
Merged

Add shebang to distro.py #313

merged 1 commit into from
Nov 25, 2021

Conversation

jdufresne
Copy link
Member

@jdufresne jdufresne commented Oct 16, 2021

This allows executing the file as a standalone script.

Previously, without the shebang, trying to execute results in the
following:

$ ./distro.py
./distro.py: line 28: platform.linux_distribution: command not found
./distro.py: line 28: platform.dist: command not found
./distro.py: line 28: Python: command not found
./distro.py: command substitution: line 29: syntax error near unexpected token `newline'
./distro.py: command substitution: line 29: `<https://bugs.python.org/issue1322>'
...

Now:

$ ./distro.py
Name: Fedora 34 (Workstation Edition)
Version: 34
Codename:

@HorlogeSkynet
Copy link
Member

What about adding a shebang instead @jdufresne ?

@jdufresne
Copy link
Member Author

Adding the shebang and executable bit is already handled by the setuptools entrypoint:

distro/setup.cfg

Lines 35 to 37 in 6ae385b

[options.entry_points]
console_scripts =
distro = distro:main

Do you see some other use case not already solved by this?

@sethmlarson
Copy link
Contributor

This PR makes a lot of sense if #315 is merged. Maybe we can take a decision on this change based on the result of #315?

@HorlogeSkynet
Copy link
Member

@jdufresne

Do you see some other use case not already solved by this?

I guess I was thinking about a wget/chmod +x usage, if distro.py is expected to work as a standalone script/program 🤷

This allows executing the file as a standalone script.

Previously, without the shebang, trying to execute results in the
following:

    $ ./distro.py
    ./distro.py: line 28: platform.linux_distribution: command not found
    ./distro.py: line 28: platform.dist: command not found
    ./distro.py: line 28: Python: command not found
    ./distro.py: command substitution: line 29: syntax error near unexpected token `newline'
    ./distro.py: command substitution: line 29: `<https://bugs.python.org/issue1322>'
    ...

Now:

    $ ./distro.py
    Name: Fedora 34 (Workstation Edition)
    Version: 34
    Codename:
@jdufresne jdufresne changed the title Remove executable bit from distro.py Add shebang to distro.py Oct 16, 2021
@jdufresne
Copy link
Member Author

Thanks @HorlogeSkynet and @sethmlarson. I've taken the suggested approach in the latest revision.

@jdufresne jdufresne merged commit 8032f16 into python-distro:master Nov 25, 2021
@jdufresne jdufresne deleted the x branch November 25, 2021 04:30
@HorlogeSkynet HorlogeSkynet added this to the 1.7.0 milestone Feb 13, 2022
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.

4 participants