https://pantsbuild.org/ logo
#pex
Title
# pex
k

kind-knife-49817

03/10/2021, 5:25 PM
Carrying on the initial conversation from #general of windows not liking a pex file as an executable. I think I found a solution for Windows and wanted to run it by some people before running with it. Using assoc and ftype we are able to run a pex file directly.
Copy code
assoc .pex=pexfile
ftype pexfile=<FULL_PATH_TO_PYTHON.EXE> %1 %*
But when I was running tests, it was still failing on the
subprocess.check_call()
and
subprocess.check_output()
calls that were trying to call the pex file directly. I found this stackoverflow question after digging into what those two calls do on the windows side of things. That made me think that in windows we will need to run
ShellExecute
instead of
CreateProcess
and reading through the subprocess documentation I found the shell arg, and that seemed to solve the issue for windows. https://github.com/jacobnlsn/pex/commit/601785a1f23992aa3c6afa5a2279ba2fd8fa830a In summary; After running the assoc and ftype commands and setting the shell arg true, we are able to successfully call the pex file in windows. What are your guys thoughts on this style of fix to move towards support for windows.
Seems to still have issues running a pex file with no extension.
h

hundreds-father-404

03/10/2021, 6:30 PM
Hi! I don't have a ton of Windows experience. Would the user set
assoc
and
ftype
in their windows command prompt in order to use Pex?
k

kind-knife-49817

03/10/2021, 6:57 PM
@hundreds-father-404 I am hopeful we could find a way around the user having to type those commands, but as it stands now, yes those are commands that would be typed into cmd prompt manually.
h

happy-kitchen-89482

03/11/2021, 4:43 AM
We don't have much Windows experience, so we'd probably defer to the judgement of those who do, and welcome the changes, as long as they don't cause regressions for POSIX users.