2016-11-07 105 views
2

我試圖用pex打包本地模塊,而且我似乎無法管理。使用pex打包本地模塊

我創建了一個簡單的項目:

→ python --version 
Python 2.7.10 
→ pex --version 
pex 1.1.15 
→ tree . 
. 
├── bla 
│   ├── __init__.py 
│   └── main.py 
└── setup.py 

bla/__init__.py

import main 

bla/main.py

if __name__ == '__main__': 
    print 'yo' 

這對我來說似乎是可能是最簡單的項目。

→ pex -v . -o v.pex --disable-cache 
Traceback (most recent call last): 
    File "/Users/Charly/repos/load_tester/venv/bin/pex", line 11, in <module> 
    sys.exit(main()) 
File "/Users/Charly/repos/load_tester/venv/lib/python2.7/site-packages/pex/bin/pex.py", line 540, in main 
    pex_builder = build_pex(reqs, options, resolver_options_builder) 
File "/Users/Charly/repos/load_tester/venv/lib/python2.7/site-packages/pex/bin/pex.py", line 475, in build_pex 
    resolvables = [Resolvable.get(arg, resolver_option_builder) for arg in args] 
    File "/Users/Charly/repos/load_tester/venv/lib/python2.7/site-packages/pex/resolvable.py", line 61, in get 
    raise cls.InvalidRequirement('Unknown requirement type: %s' % resolvable_string) 
pex.resolvable.InvalidRequirement: Unknown requirement type: . 

還試圖做python setup.py bdist_pex但是這個失敗,以及它無法找到該命令。

這真的好像我誤解了一些基本的東西,但我無法弄清楚什麼。

回答

1

單程做的是:

  1. 創建創建使用python setup.py sdist
  2. 然後運行與-f DIST_DIR開關

    例如pex命令源分佈(壓縮包,zip文件,等)。 pex $(pip freeze) -o aflaskapp.pex -e 'aflaskapp.app' -f dist -v