-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
RFE: support running via #!env bashbang #2137
Comments
Hi @glensc! Thanks for using pipenv! Can you make a bigger use case for this? We really don't want to be adding much to the API right now. Adding that command for a small use case isn't plausible at this point in time. |
what you mean bigger usecase? that's the only usecase. without shebang, typical use would be python interpreter:
but even the script executes, it will fail if dependent libraries not installed. so it would be better to distribute scripts as:
|
@glensc I think I’d be curious what the implementation looks like. It sounds like s neat feature but at the end of the day how meaningful is it? It’s only useful if you’re already in an interactive shell, so not for automation. Otherwise you would need to always run as the same user on the same system with the same environment variables. |
I have the following pyhton base-environments on my machine: c:\python2\python.exe Furthermore I have a project ("myproject") with a pipenv-environment: When I run myproject with the following shebang line it will be run with the base python environment c:\python3\python.exe and not with the pipenv-environment within my homedirectory! Of course I can edit the shebang to But on another machine, the hash (sdhjkf309274) will not be the same! Therefore it would be nice to have sth. like #!/usr/bin/env pipenv run |
Err, unfortunately that is not how shebang works, and Pipenv can not magically work around POSIX restrictions. You might want to read the discussion here: https://stackoverflow.com/questions/4303128 (edit: this thread might be more succinct if you only want a simple explanation https://unix.stackexchange.com/questions/63979) We don’t object to supporting this use case, but shebang |
See my comment on #2238 for a workaround.
@techalchemy this would make it more comfortable to write ad-hoc scripts, for instance jenkins jobs: if you want the script definition to exist on the jenkins side, saved as a "Execute shell" step, then you'd be able to just use pipenv in the shebang (or through the workaround mentioned above). |
Would be super usable to support shebang:
but due the way hashbang is parsed by linux kernel and to be most portable for other OSes, this would only work if the
/usr/bin/env
argument is single word.so, i propose you install
pipenv-run
command as well, or modifypipenv
behavior so that is able to detect such invocation scenario and behave as ifpipenv run /path/to/program.py
was invoked.The text was updated successfully, but these errors were encountered: