File tree Expand file tree Collapse file tree 2 files changed +25
-6
lines changed
Expand file tree Collapse file tree 2 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -110,13 +110,28 @@ function pythonhome_of(pyprogramname::AbstractString)
110110end
111111
112112"""
113- python_cmd(args::Cmd = ``) :: Cmd
113+ python_cmd(args::Cmd = ``; venv ) :: Cmd
114114
115115Create an appropriate `Cmd` for running Python program with command
116116line arguments `args`.
117+
118+ # Keyword Arguments
119+ - `venv::String`: The path of a virtualenv to be used instead of the
120+ default environment with which PyCall isconfigured.
117121"""
118- function python_cmd (args:: Cmd = ` ` )
119- cmd = ` $pyprogramname $args `
122+ function python_cmd (args:: Cmd = ` ` ; venv:: Union{Nothing, String} = nothing )
123+ if venv == nothing
124+ py = pyprogramname
125+ else
126+ # See:
127+ # https://github.com/python/cpython/blob/3.7/Lib/venv/__init__.py#L116
128+ if Compat. Sys. iswindows ()
129+ py = joinpath (venv, " Scripts" , " python.exe" )
130+ else
131+ py = joinpath (venv, " bin" , " python" )
132+ end
133+ end
134+ cmd = ` $py $args `
120135
121136 # For Windows:
122137 env = copy (ENV )
Original file line number Diff line number Diff line change 3636 mktempdir () do path
3737 # Create a new virtualenv
3838 run (PyCall. python_cmd (` -m venv $path ` ))
39- newpython = joinpath (path, " bin" , " python" )
40- if Compat. Sys. iswindows ()
41- newpython *= " .exe"
39+ newpython = PyCall. python_cmd (venv= path). exec[1 ]
40+ if ! isfile (newpython)
41+ @info """
42+ Python executable $newpython does not exists.
43+ This directory contains only the following files:
44+ $(join (readdir (dirname (newpython)), ' \n ' ))
45+ """
4246 end
4347 @test isfile (newpython)
4448
You can’t perform that action at this time.
0 commit comments