'Use pex with poetry pyproject.toml

I'm trying to figure out how to do automated(ish) deployment for a python project with pex. I currently have the following process:

$ poetry run pip freeze > requirements.txt 
manually remove this-project line from requirements.txt
$ poetry run pex -r requirements.txt -o service.pex -e api:start --sources-directory=.
$ ./service.pex

The reason for the second step is that pex will try to find this-project online if I leave the line in. This I understand, but pip freeze does insert that line in requirements.txt. What I'm wondering is: can pex use pyproject.toml or poetry.lock directly? The current solution is kind of an annoying work around.

I've looked at 2019 tutorial and it doesn't work, since the current version of pex doesn't recognize --project as an option.

Any other suggestions would be greatly appreciated.



Solution 1:[1]

How about pex . -o service.pex -e api:start? Pex understands how to build any PEP-517 / PEP-518 pyproject.toml, which you've got if you're using Poetry.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 John Sirois