-
-
Save jgarte/2fa506cad843cce0544964882d80f58c to your computer and use it in GitHub Desktop.
Revisions
-
simeonf revised this gist
Aug 20, 2015 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,8 @@ Ok - first to make our script! Call it foo.py: req = requests.get("https://raw.githubusercontent.com/pantsbuild/pex/master/README.rst") print req.text.split("\n")[0] It's a `requests` *hello world* program. To package it we need a minimal `setup.py` for distributing a script. Put it in the same directory: from distutils.core import setup setup(name='foo', -
simeonf revised this gist
Aug 20, 2015 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ So you want to create a pex that packages your script and its dependencies? Ok - first to make our script! Call it foo.py: @@ -8,7 +8,7 @@ Ok - first to make our script! Call it foo.py: req = requests.get("https://raw.githubusercontent.com/pantsbuild/pex/master/README.rst") print req.text.split("\n")[0] It's a `requests` *hello world* program. To package it we need a minimal setup.py for distributing a script: from distutils.core import setup setup(name='foo', @@ -20,7 +20,7 @@ Now that our script is packageable we can use `pex` to build an executable out o $ pex . requests -c foo.py -o foo.pex -f dist Briefly - `requests` and `.` are our dependencies. `-c foo.py` tells pex what to run. And `-o foo.pex` creates the output file. You should get a `foo.pex` file in the same directory. Run it to see the script execute: -
simeonf revised this gist
Aug 20, 2015 . 1 changed file with 4 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -16,17 +16,12 @@ To package it we need a minimal setup.py for distributing a script: scripts=['foo.py'], ) Now that our script is packageable we can use `pex` to build an executable out of it: $ pex . requests -c foo.py -o foo.pex -f dist Briefly - `requests` and `.` are our dependencies. `-c foo.py` tells us what to run. `-o foo.pex` creates the output file. You should get a `foo.pex` file in the same directory. Run it to see the script execute: -
simeonf revised this gist
Aug 20, 2015 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -36,6 +36,4 @@ You should get a `foo.pex` file in the same directory. Run it to see the script And you can unzip the pex to see the contents including the packaged dependencies: $ unzip -t foo.pex ... much output not shown... -
simeonf revised this gist
Aug 20, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -25,7 +25,7 @@ and dependency into an executable: $ pex requests foo -c foo.py -o foo.pex -f dist Briefly - `requests` and `foo` are our dependencies. `-c foo.py` tells us what to run. `-o foo.pex` creates the output file and `-f dist` tells pex it can look in the `dist` directory to satisfy dependencies. You should get a `foo.pex` file in the same directory. Run it to see the script execute: -
simeonf revised this gist
Aug 20, 2015 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -10,32 +10,32 @@ Ok - first to make our script! Call it foo.py: To package it we need a minimal setup.py for distributing a script: from distutils.core import setup setup(name='foo', version='1.0', scripts=['foo.py'], ) Build an sdist with $ python setup.py sdist This puts a tarball for our package in the `./dist` folder. Use `pex` to package our script and dependency into an executable: $ pex requests foo -c foo.py -o foo.pex -f dist Briefly - `requests` and `foo` are our dependencies. `-ck foo.py` tells us what to run. `-o foo.pex` creates the output file and `-f dist` tells pex it can look in the `dist` directory to satisfy dependencies. You should get a `foo.pex` file in the same directory. Run it to see the script execute: $ ./foo.pex PEX And you can unzip the pex to see the contents including the packaged dependencies: $ unzip -t foo.pex $ -
simeonf revised this gist
Aug 20, 2015 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,11 +2,11 @@ So you want to create a pex from a single python file with dependencies? Ok - first to make our script! Call it foo.py: import requests if __name__ == '__main__': req = requests.get("https://raw.githubusercontent.com/pantsbuild/pex/master/README.rst") print req.text.split("\n")[0] To package it we need a minimal setup.py for distributing a script: -
simeonf renamed this gist
Aug 20, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
simeonf created this gist
Aug 20, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ So you want to create a pex from a single python file with dependencies? Ok - first to make our script! Call it foo.py: import requests if __name__ == '__main__': req = requests.get("https://raw.githubusercontent.com/pantsbuild/pex/master/README.rst") print req.text.split("\n")[0] To package it we need a minimal setup.py for distributing a script: from distutils.core import setup setup(name='foo', version='1.0', scripts=['foo.py'], ) Build an sdist with $ python setup.py sdist This puts a tarball for our package in the `./dist` folder. Use `pex` to package our script and dependency into an executable: $ pex requests foo -c foo.py -o foo.pex -f dist Briefly - `requests` and `foo` are our dependencies. `-ck foo.py` tells us what to run. `-o foo.pex` creates the output file and `-f dist` tells pex it can look in the `dist` directory to satisfy dependencies. You should get a `foo.pex` file in the same directory. Run it to see the script execute: $ ./foo.pex PEX And you can unzip the pex to see the contents including the packaged dependencies: $ unzip -t foo.pex $