OK. I can answer my own question after some trial.
pex -r requirement.txt -M <my_main_script> -P <folder> -P <folder> ... -e <my_main_script> -o <pex>
given I have a project like
gateway.py
brokers/
__init__.py
file1.py
file2.py
To package the above, do
pex -r requirement.txt -M gateway -P brokers -e gateway -o g.pex
Then run ./g.pex will run the program.
The final thing I need to do is my program need a configuration file, say gateway.yml . But I could not found how to put the yml file (or any resource file) into the pex.