cool-easter-32542
08/28/2023, 9:49 AM.
├── BUILD
├── main.py
├── pants.toml
└── test_main.py
# pants.toml
[GLOBAL]
pants_version = '2.10.0'
backend_packages = ['pants.backend.python']
# BUILD
python_requirement(name='python_requirement', requirements=['cowsay'])
python_sources(name='python_sources')
python_tests(name='python_tests')
# main.py
import subprocess
import cowsay
def cowsay_hello_using_subprocess():
subprocess.run(['cowsay', 'hello'])
def cowsay_hello_using_module():
cowsay.cow('hello')
# test_main.py
import main
def test_cowsay_hello_using_subprocess():
main.cowsay_hello_using_subprocess()
def test_cowsay_hello_using_module():
main.cowsay_hello_using_module()
Running the ./pants test :python_tests results 1 failed, 1 passed. The test_cowsay_hello_using_subprocess test fails:
FileNotFoundError: [Errno 2] No such file or directory: 'cowsay'
Actually, a similar issue occurred if we define pex_binary for the source code. But, thanks to #12651, using execution_mode='venv' solves the issue there.
In my opinion, there should be a similar solution for the intermediate pex files created for other goals and targets. Am I thinking right?
Pants version: 2.10.0
OS: Ubuntu 20.04.3 LTS
pantsbuild/pantscool-easter-32542
08/28/2023, 9:49 AM