Environment activation on the shebang line?
See original GitHub issueI was inspired to ask about specifying the project dir as a command line arg (https://github.com/pypa/pipenv/issues/2237) while thinking about invoking tools in their own venvs. At some point I realized that I could use a venv’s python
to invoke a tool and it would just work without having to activate anything in my shell. I assume this is entirely by design.
With pipenv managing venv paths, it might be compelling to be able to invoke a tool via pipenv, where pipenv would determine the venv from the tool’s path and not the current working directory. Perhaps pipenv could be the tool runner on the shebang line, something like this:
#!/usr/bin/env pipenv run
import mystuff
import sys
def main(args):
# And so forth.
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
Is this compelling? Or am I missing a different best practice for organizing tools with their own venvs? Or do people just prefer to not do this and use global site-packages for everything they intend to run on their own machines? (And if I’m dev’ing my own tools, I would do actual releases into my everyday-carry environment, and use venvs just for development?)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:19 (3 by maintainers)
Top GitHub Comments
This should do it (works for me):
#!/usr/bin/env pipenv run python
This is an issue, but not one Pipenv wishes to get into. Pipenv is a tool to manage environments, not to help package and redistribute your application. You should use other tools for that purpose.