Been trying to wrap `pants` invocations in pythons...
# general
w
Been trying to wrap
pants
invocations in pythons
subprocess
. So far it had worked ok, but using
Copy code
[python-repos]
indexes = [
    '<https://aws>:%(env.CODE_ARTIFACT_TOKEN)s@<our-python-repo>/simple
]
and adding the appropriate platform to the
pex_binary
causes
Copy code
subprocess.run(f'./pants package {dockerfile} --dynamic-ui=False', shell=True, text=True, env=os.environ)
to hang. Running
./pants package <the-dockerfile>
works, so it's something specific to
subprocess
I have confirmed that not using the
python-repos
section causes everything to work ok, and also that using the
python-repos
section outside of
subprocess
works ok.
Disabling
pantsd
seem to help, am I hitting some resource contention?
b
Are you running your script through Pants itself? By default Pants doesnt support dsaemonized concurrent runs, and the subsequent runs "wait their turn"
w
No, the script that fires off the subprocess is the aws cdk
b
Ah, worth a shot 🙂
w
Maybe I have an XY problem.. Is there a way to programmatically get a hold of the docker image ID:s after a
./pants package
run? Right now I use
image_sha = result.split('Docker image ID:')[1].strip()
from the subprocess run.
b
I think parsing the output should be sufficient.
w
Right, the approach works minus that for some reason python subprocess cant seem to download via custom index in python-repos, its just epolling until the end of time 😢
b
I'll leave those more experienced in that specific slice of Pants to answer. I couldn't tell you what's going on there 😞