Last active
September 7, 2017 14:11
-
-
Save 0atman/713f7a60a64d3dfc7d1216c58dcbbbb1 to your computer and use it in GitHub Desktop.
A simple wrapper around `pex`. For self-contained python scripts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
requirements=$1 | |
script=$2 | |
exec pex $requirements -- $script |
This wrapper around pex is needed because of the way shebangs pass everything after the cmd (ie flask flask_restful
) as a single string, rather than splitting them into arguments, as you might expect.
[source]
pex smartly caches your requirements, so the second time you run the script, there's no delay, and pinning is supported by pex (requests==2.18.4
)
A general-purpose solution to this is https://github.com/jordansissel/shebang
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install to
/usr/bin/pexed
.An example script using pexed: