本文整理匯總了Python中venv.main方法的典型用法代碼示例。如果您正苦於以下問題:Python venv.main方法的具體用法?Python venv.main怎麽用?Python venv.main使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類venv
的用法示例。
在下文中一共展示了venv.main方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run
# 需要導入模塊: import venv [as 別名]
# 或者: from venv import main [as 別名]
def run(self):
venv_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'venv', 'nginx-config-builder')
print('Creating virtual environment in {path}'.format(path=venv_path))
if '3' in self.python or sys.version_info[0] >= 3:
import venv
venv.main(args=[venv_path])
else:
venv_cmd = ['virtualenv']
if self.python:
venv_cmd.extend(['-p', self.python])
venv_cmd.append(venv_path)
subprocess.check_call(venv_cmd)
print('Linking `activate` to top level of project.\n')
print('To activate, simply run `source activate`.')
try:
os.symlink(
os.path.join(venv_path, 'bin', 'activate'),
os.path.join(os.path.dirname(os.path.abspath(__file__)), 'activate')
)
except OSError:
# symlink already exists
pass
示例2: run_tests
# 需要導入模塊: import venv [as 別名]
# 或者: from venv import main [as 別名]
def run_tests(self):
import tox
errno = -1
try:
tox.session.main()
except SystemExit as e:
errno = e.code
sys.exit(errno)
示例3: run
# 需要導入模塊: import venv [as 別名]
# 或者: from venv import main [as 別名]
def run(self):
venv_path = Path(__file__).absolute().parent / 'venv' / 'asciietch'
print(f'Creating virtual environment in {venv_path}')
venv.main(args=[str(venv_path)])
print(
'Linking `activate` to top level of project.\n'
'To activate, simply run `source activate`.'
)
activate = Path(venv_path, 'bin', 'activate')
activate_link = Path(__file__).absolute().parent / 'activate'
try:
activate_link.symlink_to(activate)
except FileExistsError:
...
示例4: run
# 需要導入模塊: import venv [as 別名]
# 或者: from venv import main [as 別名]
def run(self):
venv_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'venv', 'shiv')
print('Creating virtual environment in {}'.format(venv_path))
venv.main(args=[venv_path])
print(
'Linking `activate` to top level of project.\n'
'To activate, simply run `source activate`.'
)
try:
os.symlink(
Path(venv_path, 'bin', 'activate'),
Path(Path(__file__).absolute().parent, 'activate'),
)
except FileExistsError:
pass