Skip to content
Permalink
Browse files

working on it (#93)

* Major: Upgraded to virtualenv 16.4.3. The option --no-site-packages was deprecated and replaced with --system-site-packages. Which is now reflected in the API to create virtualenvs.
  • Loading branch information...
mortenvp committed Mar 20, 2019
1 parent 793fe8c commit 83940c939c3615ff6681bfc8d2daaaada88d25ac
@@ -6,7 +6,10 @@ of every change, see the Git log.

Latest
------
* Major: Romoved pip_local_download, pip_local_install, pip_install from the
* Major: Upgraded to virtualenv 16.4.3. The option --no-site-packages was
deprecated and replaced with --system-site-packages. Which is now reflected
in the API to create virtualenvs.
* Major: Removed pip_local_download, pip_local_install, pip_install from the
virtualenv implementation. Users might as well directly call run with the
appropiate command.
* Major: Prevent creation of virtualenv in build folder
@@ -58,8 +58,7 @@ def run(self, cmd, cwd=None):
cwd = self.cwd

ret = self.ctx.exec_command(
cmd, cwd=cwd, env=self.env, stdout=None, stderr=None
)
cmd, cwd=cwd, env=self.env, stdout=None, stderr=None)

if ret != 0:
self.ctx.fatal('Exec command "{}" failed!'.format(cmd))
@@ -82,7 +81,7 @@ def create(
env=None,
name=None,
overwrite=True,
no_site_packages=True,
system_site_packages=False,
download=True,
download_path=None,
):
@@ -102,8 +101,8 @@ def create(
:param overwrite: If an existing virtualenv with the same name already
exists we will overwrite it. To reuse the virtualenv pass
overwrite=False.
:param no_site_packages: If true the --no-site-packages will be passed
to virtualenv.
:param system_site_packages: If true give the virtual environment access
to the global site-packages.
"""

# The Python executable
@@ -170,8 +169,8 @@ def create(

cmd = [python, "-m", "virtualenv", name]

if no_site_packages:
cmd += ["--no-site-packages"]
if system_site_packages:
cmd += ["--system-site-packages"]

ctx.cmd_and_log(cmd, cwd=cwd, env=temp_env)

@@ -6,7 +6,7 @@
from .git import Git

URL = 'https://github.com/pypa/virtualenv.git'
VERSION = '15.1.0'
VERSION = '16.4.3'


class VirtualEnvDownload(object):
@@ -106,9 +106,9 @@ def recurse_dependencies(ctx):

@conf
def create_virtualenv(ctx, cwd=None, env=None, name=None, overwrite=True,
no_site_packages=True, download=True, download_path=None):
system_site_packages=False, download=True, download_path=None):

return virtualenv.VirtualEnv.create(
ctx=ctx, log=Logs, cwd=cwd, env=env, name=name,
overwrite=overwrite, no_site_packages=no_site_packages,
overwrite=overwrite, system_site_packages=system_site_packages,
download=download, download_path=download_path)
@@ -16,7 +16,7 @@ def test_create_virtualenv(testdirectory):
)

assert testdirectory.contains_dir("virtualenv-*")
assert download_path.contains_dir("15.1.0")
assert download_path.contains_dir("16.4.3")

testdirectory.run(
"python waf build --download_path {}".format(download_path.path())
@@ -44,7 +44,7 @@ def test_create_virtualenv_fail(testdirectory):
)

assert testdirectory.contains_dir("virtualenv-*")
assert download_path.contains_dir("15.1.0")
assert download_path.contains_dir("16.4.3")

with pytest.raises(RunResultError) as excinfo:
testdirectory.run(
@@ -17,5 +17,5 @@ def configure(conf):

def build(bld):
venv = bld.create_virtualenv(download_path=bld.options.download_path,
no_site_packages=True)
system_site_packages=True)
venv.run('python -m pip install pytest')
@@ -37,14 +37,14 @@ def test_virtualenv_name(testdirectory):
assert testdirectory.contains_dir(name)

venv = VirtualEnv.create(
log=log, cwd=cwd, env=env, name=name, ctx=ctx, no_site_packages=True,
download=False)
log=log, cwd=cwd, env=env, name=name, ctx=ctx,
system_site_packages=True, download=False)

assert fnmatch.fnmatch(venv.path, os.path.join(cwd, name))
assert not testdirectory.contains_dir(name)

ctx.cmd_and_log.assert_called_once_with(
[sys.executable, "-m", "virtualenv", name, "--no-site-packages"],
[sys.executable, "-m", "virtualenv", name, "--system-site-packages"],
cwd=cwd,
env=env)

@@ -58,7 +58,7 @@ def test_virtualenv_name(testdirectory):
stderr=None)


def test_virtualenv_no_site_packages(testdirectory):
def test_virtualenv_system_site_packages(testdirectory):

cwd = testdirectory.path()
env = dict(os.environ)
@@ -72,8 +72,8 @@ def test_virtualenv_no_site_packages(testdirectory):
assert testdirectory.contains_dir(name)

venv = VirtualEnv.create(
log=log, cwd=cwd, env=env, name=name, ctx=ctx, no_site_packages=False,
download=False)
log=log, cwd=cwd, env=env, name=name, ctx=ctx,
system_site_packages=False, download=False)

assert fnmatch.fnmatch(venv.path, os.path.join(cwd, name))
assert not testdirectory.contains_dir(name)
@@ -18,12 +18,12 @@ def test_virtualenv_download(testdirectory):

path = downloader.download()

assert(path == os.path.join(testdirectory.path(), '15.1.0'))
assert(path == os.path.join(testdirectory.path(), '16.4.3'))

git.clone.assert_has_calls([
mock.call(repository='https://github.com/pypa/virtualenv.git',
directory=path, cwd=testdirectory.path(), depth=1,
branch='15.1.0')])
branch='16.4.3')])


def test_virtualenv_download_exists(testdirectory):
@@ -32,7 +32,7 @@ def test_virtualenv_download_exists(testdirectory):
ctx = mock.Mock()
log = mock.Mock()

clone_dir = testdirectory.mkdir('15.1.0')
clone_dir = testdirectory.mkdir('16.4.3')

downloader = VirtualEnvDownload(
git=git, ctx=ctx, log=log, download_path=testdirectory.path())

0 comments on commit 83940c9

Please sign in to comment.
You can’t perform that action at this time.