本文整理汇总了Python中virtualenv.create_environment方法的典型用法代码示例。如果您正苦于以下问题:Python virtualenv.create_environment方法的具体用法?Python virtualenv.create_environment怎么用?Python virtualenv.create_environment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类virtualenv
的用法示例。
在下文中一共展示了virtualenv.create_environment方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _handle_install
# 需要导入模块: import virtualenv [as 别名]
# 或者: from virtualenv import create_environment [as 别名]
def _handle_install(args, dependencies):
if args.install and dependencies:
if pip is None:
raise ImportError("Bootstrapping Pulsar dependencies requires pip library.")
pip.main(["install"] + dependencies)
# def _install_pulsar_in_virtualenv(venv):
# if virtualenv is None:
# raise ImportError("Bootstrapping Pulsar into a virtual environment, requires virtualenv.")
# if IS_WINDOWS:
# bin_dir = "Scripts"
# else:
# bin_dir = "bin"
# virtualenv.create_environment(venv)
# # TODO: Remove --pre on release.
# subprocess.call([os.path.join(venv, bin_dir, 'pip'), 'install', "--pre", "pulsar-app"])
示例2: _install_virtualenv
# 需要导入模块: import virtualenv [as 别名]
# 或者: from virtualenv import create_environment [as 别名]
def _install_virtualenv(path):
from hashlib import sha256
from .downloader import download
log.info('Downloading virtualenv from %r ...', VIRTUALENV_URL)
data = download(VIRTUALENV_URL).read()
assert sha256(data).hexdigest() == HASH, 'hash error... MITM?'
import tempfile
with tempfile.NamedTemporaryFile('wb', suffix=".zip", delete=False) as zf:
zf.write(data)
zf.flush()
sys.path.insert(0, zf.name)
import virtualenv
with FixInterpreter():
log.info('Creating environment using virtualenv...')
virtualenv.create_environment(path, site_packages=True)
log.info('Done!')
示例3: _setUp
# 需要导入模块: import virtualenv [as 别名]
# 或者: from virtualenv import create_environment [as 别名]
def _setUp(self):
path = self.useFixture(fixtures.TempDir()).path
virtualenv.create_environment(path, clear=True)
python = os.path.join(path, 'bin', 'python')
command = [python] + self.pip_cmd + ['-U']
if self.modules and len(self.modules) > 0:
command.extend(self.modules)
self.useFixture(base.CapturedSubprocess(
'mkvenv-' + self._reason, command))
self.addCleanup(delattr, self, 'path')
self.addCleanup(delattr, self, 'python')
self.path = path
self.python = python
return path, python
示例4: make_venv
# 需要导入模块: import virtualenv [as 别名]
# 或者: from virtualenv import create_environment [as 别名]
def make_venv(self, directory): # pragma: no cover
import virtualenv
from virtualenv import Logger
logger = Logger([(Logger.level_for_integer(2), sys.stdout)])
virtualenv.logger = logger
virtualenv.create_environment(directory,
site_packages=False,
clear=False,
unzip_setuptools=True)
示例5: venv
# 需要导入模块: import virtualenv [as 别名]
# 或者: from virtualenv import create_environment [as 别名]
def venv(tmpdir, isolate):
"""
Return a virtual environment which is unique to each test function
invocation created inside of a sub directory of the test function's
temporary directory.
"""
venv_location = os.path.join(str(tmpdir), "workspace", "venv")
venv = virtualenv.create_environment(venv_location)
os.environ["PIPAPI_PYTHON_LOCATION"] = os.path.join(venv_location, "bin", "python")
yield venv
del os.environ["PIPAPI_PYTHON_LOCATION"]
shutil.rmtree(venv_location)
示例6: test_execute_virtualenv_wrappers
# 需要导入模块: import virtualenv [as 别名]
# 或者: from virtualenv import create_environment [as 别名]
def test_execute_virtualenv_wrappers(tmpdir, monkeypatch):
import virtualenv
# monkey patch the current dir to make sure we convert the relative paths
# passed as arguments to absolute
monkeypatch.chdir(tmpdir)
virtualenv.create_environment(
"virtual envs/test", no_setuptools=True, no_pip=True, no_wheel=True
)
if sys.platform != "win32":
bin_dir = "virtual envs/test/bin"
else:
bin_dir = "virtual envs/test/Scripts"
create_wrappers._main(
[
"-t",
"virtualenv",
"--virtual-env-dir",
"virtual envs/test",
"--bin-dir",
bin_dir,
"--dest-dir",
"wrappers",
]
)
environ_from_activate = _environ_from_activate(
_activate_virtualenv_script(), tmpdir
)
# Remove some variables we don't care
if sys.platform != "win32":
environ_from_activate.pop("PS1", None)
environ_from_activate.pop("SHLVL")
else:
environ_from_activate.pop("_OLD_VIRTUAL_PATH")
environ_from_activate.pop("_OLD_VIRTUAL_PROMPT")
environ_from_activate.pop("PROMPT")
environ_from_activate["PATH"] = os.path.normcase(environ_from_activate["PATH"])
environ_from_activate["VIRTUAL_ENV"] = os.path.normcase(
environ_from_activate["VIRTUAL_ENV"]
)
environ_from_wrapper = _environ_from_wrapper()
if sys.platform != "win32":
environ_from_wrapper.pop("SHLVL")
else:
environ_from_wrapper.pop("PROMPT")
environ_from_wrapper["PATH"] = os.path.normcase(environ_from_wrapper["PATH"])
environ_from_wrapper["VIRTUAL_ENV"] = os.path.normcase(
environ_from_wrapper["VIRTUAL_ENV"]
)
assert environ_from_activate == environ_from_wrapper