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

PR: Don't use hard-coded path to Python in script shebang used to launch Spyder #22668

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

Flamefire
Copy link
Contributor

Don't use hard-coded path to python in shebang.

This allows spyder to work in other environments which have python installed in a different directory.

Affirmation

By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.

I certify the above statement is true and correct: Flamefire

This allows spyder to work in other environments which have python installed in a different directory.
@ccordoba12
Copy link
Member

Hey @Flamefire, thanks for your contribution! Could you describe in which cases this change would be helpful?

It's just that I find a bit strange that this hasn't been reported before by Linux package maintainers.

@Flamefire
Copy link
Contributor Author

Linux package maintainers.

There they install also Python into the used location, so that isn't an issue.

We are using this in HPC (High Performance Computing) where we install our own Python to control all dependencies and their versions. The python3 binary is in $PATH but not in /usr/bin. This is because we cannot easily change the system images of the nodes but install additional software in global paths.

So when there is only /usr/bin/python3 this does not change anything. When there is another python3 available in $PATH taking precedence then that will be used which allows users to choose which one to use by putting it first in $PATH.

Something concrete for end-users outside our use case: PyEnv. This can be used to install multiple python versions side-by-side and have a command to choose a version for the current shell or globally. This works by having a shim at $HOME/.pyenv/shims/python3 that dispatches to the chosen Python. That also works by putting the shim first in $PATH.
So that would also be enabled by this change.

From what I know it is good practice in general to use the #!/usr/bin/env <command>-style shebang instead of hard-coded paths to allow for such user-control. There might be exceptions of course.

@ccordoba12
Copy link
Member

Ok, thanks for the extra info and clarifications @Flamefire. Then I think this is a sensible change and we'll include it in 6.0.2, to be released in a week and a half.

Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

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

Thanks @Flamefire!

@ccordoba12 ccordoba12 changed the title Don't use hard-coded path to python in shebang PR: Don't use hard-coded path to Python in script shebang used to launch Spyder Oct 15, 2024
@ccordoba12 ccordoba12 merged commit a857397 into spyder-ide:master Oct 15, 2024
@ccordoba12
Copy link
Member

@meeseeksdev please backport to 6.x

meeseeksmachine pushed a commit to meeseeksmachine/spyder that referenced this pull request Oct 15, 2024
ccordoba12 pushed a commit that referenced this pull request Oct 15, 2024
…thon in script shebang used to launch Spyder) (#22676)
@Flamefire Flamefire deleted the patch-1 branch October 15, 2024 16:31
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.

2 participants