Skip to content

running other console script from my code #1371

Answered by jsirois
ws1088 asked this question in Q&A
Discussion options

You must be logged in to vote

You will only be able to do this with a --venv mode pex and the append or prepend option.

For example, using --venv prepend which prepends all console scripts found in the PEX to the PATH:

$ cat src/exe.py 
import subprocess


def main():
  subprocess.check_call(["pytest", "--version"])
  subprocess.check_call(["which", "pytest"])

$ pex pytest --venv prepend -o my.pex -D src -e exe:main
$ ./my.pex 
pytest 6.2.4
/home/jsirois/.pex/venvs/efadb32f637132f9dc2de837e85c42205c95e130/2d1d404c3de23b1810386195be7410700b1feb14/bin/pytest

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@jsirois
Comment options

Answer selected by ws1088
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants