Packaging Requirements _and_ Local Modules with PEX

I am trying to create a distribution .pex file to distribute my python (Flask) application with PEX .

If I have the following setting:

. |_ requirements.txt |_ app.py |_ module1 |_ module2 

How can I pack this with pex?

I can set my requirements and run app.py with this:

 pex -r requirements.txt -- app.py 

But how can I also include my local modules in the pex distribution?

I tried:

 pex -r requirements.txt -m module1 module2 -- app.py 

and:

 pex module1 module2 -r requirements.txt -- app.py 

But get the error:

Failed to meet all requirements for module 1

If I completely leave my local modules:

  pex -r requirements.txt -- ./app.py 

I can not satisfy the requirements for (something in my request.txt field)

Did I miss something obvious here? Is this the wrong use case for PEX?

+5
source share
1 answer

I had the same problems. The only working pex example I could find is pex. From https://github.com/pantsbuild/pex/blob/master/tox.ini I came to the conclusion that the requirements should be listed on the command line in addition to your module.

This incarnation worked for me:

pex $ (cat requirements.txt). -e myapp.main: main -o dist / myapp.pex

-1
source

All Articles