Inserting cli options into virtualenv.cli_run within a python file
Question:
I want to write a Python script that creates a new virtual environment with the following virtualenv CLI options:
--app-data APP_DATA
(a folder APP_DATA for the cache)
--seeder {app-data,pip}
If I give those two as strings in a list (see picture) I get:
TypeError: options must be of type VirtualEnvOptions
Answers:
When you call cli_run
as part of virtualenv, you don’t need to include the first argument, in this case "venv".
this should work:
from virtualenv import cli_run
cli_run(["--app-data APP_DATA", "--seeder {app-data,pip}"]);
According to virtualenv‘s documentation section "Programmatic API", this seems like the following should work:
from virtualenv import cli_run
cli_run(['path/to/venv', '--app-data', 'path/to/app_data', '--seeder', 'app-data'])
I want to write a Python script that creates a new virtual environment with the following virtualenv CLI options:
--app-data APP_DATA
(a folder APP_DATA for the cache)
--seeder {app-data,pip}
If I give those two as strings in a list (see picture) I get:
TypeError: options must be of type VirtualEnvOptions
When you call cli_run
as part of virtualenv, you don’t need to include the first argument, in this case "venv".
this should work:
from virtualenv import cli_run
cli_run(["--app-data APP_DATA", "--seeder {app-data,pip}"]);
According to virtualenv‘s documentation section "Programmatic API", this seems like the following should work:
from virtualenv import cli_run
cli_run(['path/to/venv', '--app-data', 'path/to/app_data', '--seeder', 'app-data'])