Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.

Unified shebang (#!), so all python utils repsect virtual envs#138

Merged
jsha merged 2 commits intoEFForg:masterfrom
charlesthomas:master
Aug 15, 2014
Merged

Unified shebang (#!), so all python utils repsect virtual envs#138
jsha merged 2 commits intoEFForg:masterfrom
charlesthomas:master

Conversation

@charlesthomas
Copy link
Copy Markdown
Contributor

No description provided.

@jpds-zz
Copy link
Copy Markdown
Contributor

jpds-zz commented Feb 1, 2014

Note that this kind of shebang'ing is not recommended:

@charlesthomas
Copy link
Copy Markdown
Contributor Author

FWIW, there were already other python files using "env python" style.

@diracdeltas
Copy link
Copy Markdown
Contributor

Marking as wontfix for now.

@kirelagin
Copy link
Copy Markdown
Contributor

This Fedora feature proposal is about python executables shipped by Fedora. The author wants to ensure that they are executed by their Fedora-default version of Python, not the one installed by user. That might make sense for their Fedora-executables to rely on Fedora-default python, but this is definitely not what you want for your scripts if you want them to be usable everywhere. Also this proposal is somewhat inconsistent. What matters is the version of Python, not the exact path. So he should have proposed to replace /usr/bin/env python with /usr/bin/env python<version>, right? This proposal dates back to 2011 and is still 0% complete.

Ubuntu “bug” is all the same. This might make sense for distro-provided executables or maybe packagers, but this totally shouldn't worry you, developers.

And especially this makes no sense for build scripts.

@kirelagin
Copy link
Copy Markdown
Contributor

Also note that Python upstream uses /usr/bin/env python in tutorials.

@charlesthomas
Copy link
Copy Markdown
Contributor Author

The intention for this was to allow the python utils to be run from inside a virtual env, so the exact path is what matters.

As it stands now, if you run the python utils from inside a virtual env, depending on how you call the utils, some will run with the virtual env python install & libraries, and some will use the system python.

If you've installed the required libraries into system python, or you're in a virtual env and call them with python whatever.py, or you're using a util that doesn't require additional libraries, then everything will work as expected. But if you ./whatever.py outside a virtual env and it needs extra libraries which are only installed in the virtual env, then whatever.py won't work.

@jsha
Copy link
Copy Markdown
Member

jsha commented Aug 14, 2014

Based on the comments and a brief skim of the Fedora link, it sounds like this change is a good one. One question: Our scripts depend on a minimum Python version of 2.7. Is there a way to express that using the /usr/bin/env shebang?

@jsha jsha removed the wontfix label Aug 14, 2014
@charlesthomas
Copy link
Copy Markdown
Contributor Author

@jsha Yes, if you do #!/usr/bin/env python2.7, you'll get a 2.7 interpreter, if there is one on the system. It will also respect virtualenvs.

@jsha
Copy link
Copy Markdown
Member

jsha commented Aug 15, 2014

Great! If you make that change I'll merge this branch.

@charlesthomas
Copy link
Copy Markdown
Contributor Author

@jsha done!

jsha added a commit that referenced this pull request Aug 15, 2014
Unified shebang (#!), so all python utils repsect virtual envs
@jsha jsha merged commit b095f82 into EFForg:master Aug 15, 2014
@jsha
Copy link
Copy Markdown
Member

jsha commented Aug 15, 2014

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants