summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaweł Tomulik <ptomulik@meil.pw.edu.pl>2018-11-07 00:55:58 (GMT)
committerPaweł Tomulik <ptomulik@meil.pw.edu.pl>2018-11-10 09:24:35 (GMT)
commit0414380dec2104dedc163e7489f445621ef0e5f6 (patch)
tree1f5aabd6aea8053152d975e97c72a90716faf8a6
parent08863caeef77c0a579f774bd831e289124dd65e0 (diff)
downloadSCons-0414380dec2104dedc163e7489f445621ef0e5f6.zip
SCons-0414380dec2104dedc163e7489f445621ef0e5f6.tar.gz
SCons-0414380dec2104dedc163e7489f445621ef0e5f6.tar.bz2
corrections after bdbaddog's code review
-rw-r--r--doc/user/misc.xml2
-rw-r--r--src/engine/SCons/Platform/posix.py4
-rw-r--r--src/engine/SCons/Platform/virtualenv.py (renamed from src/engine/SCons/Platform/VE.py)22
-rw-r--r--src/engine/SCons/Platform/virtualenvTests.py (renamed from src/engine/SCons/Platform/VETests.py)86
-rw-r--r--src/engine/SCons/Platform/win32.py4
-rw-r--r--src/engine/SCons/Script/Main.py8
-rw-r--r--src/engine/SCons/Script/SConsOptions.py4
-rw-r--r--src/engine/SCons/Script/__init__.py4
-rw-r--r--src/engine/SCons/Util.py26
-rw-r--r--src/engine/SCons/UtilTests.py58
-rw-r--r--test/virtualenv/activated/option/enable-virtualenv.py14
-rw-r--r--test/virtualenv/activated/option/ignore-virtualenv.py12
-rw-r--r--test/virtualenv/activated/virtualenv_activated_python.py12
-rw-r--r--test/virtualenv/activated/virtualenv_detect_virtualenv.py8
-rw-r--r--test/virtualenv/always/virtualenv_global_function.py4
-rw-r--r--test/virtualenv/regularenv/virtualenv_detect_regularenv.py8
-rw-r--r--test/virtualenv/unactivated/virtualenv_unactivated_python.py12
17 files changed, 150 insertions, 138 deletions
diff --git a/doc/user/misc.xml b/doc/user/misc.xml
index a5092d0..a595e59 100644
--- a/doc/user/misc.xml
+++ b/doc/user/misc.xml
@@ -654,7 +654,7 @@ env.Command('directory_build_info',
</para>
<para>
- This issue may be overcame by using <literal>--enable-virtualenv</literal>
+ This issue may be overcome by using <literal>--enable-virtualenv</literal>
option. The option automatically imports virtualenv-related environment
variables to all created construction environment <literal>env['ENV']</literal>,
and modifies SCons PATH appropriately to prefer virtualenv's executables.
diff --git a/src/engine/SCons/Platform/posix.py b/src/engine/SCons/Platform/posix.py
index fb57521..ad4e859 100644
--- a/src/engine/SCons/Platform/posix.py
+++ b/src/engine/SCons/Platform/posix.py
@@ -41,8 +41,8 @@ import select
import SCons.Util
from SCons.Platform import TempFileMunge
-from SCons.Platform.VE import ImportVirtualenv
-from SCons.Platform.VE import ignore_virtualenv, enable_virtualenv
+from SCons.Platform.virtualenv import ImportVirtualenv
+from SCons.Platform.virtualenv import ignore_virtualenv, enable_virtualenv
exitvalmap = {
2 : 127,
diff --git a/src/engine/SCons/Platform/VE.py b/src/engine/SCons/Platform/virtualenv.py
index f7aa80c..03fb486 100644
--- a/src/engine/SCons/Platform/VE.py
+++ b/src/engine/SCons/Platform/virtualenv.py
@@ -1,4 +1,4 @@
-"""SCons.Platform.VE
+"""SCons.Platform.virtualenv
Support for virtualenv.
"""
@@ -33,31 +33,15 @@ import sys
import SCons.Util
-def _get_bool_envvar(name, default=False):
- try:
- var = os.environ[name]
- except KeyError:
- return default
- try:
- return bool(int(var))
- except ValueError:
- if str(var).lower() in ('true', 'yes', 'y', 'on'):
- return True
- elif str(var).lower() in ('false', 'no', 'n', 'off'):
- return False
- else:
- return default
-
-
virtualenv_enabled_by_default = False
def _enable_virtualenv_default():
- return _get_bool_envvar('SCONS_ENABLE_VIRTUALENV', virtualenv_enabled_by_default)
+ return SCons.Util.get_bool_envvar('SCONS_ENABLE_VIRTUALENV', virtualenv_enabled_by_default)
def _ignore_virtualenv_default():
- return _get_bool_envvar('SCONS_IGNORE_VIRTUALENV', False)
+ return SCons.Util.get_bool_envvar('SCONS_IGNORE_VIRTUALENV', False)
enable_virtualenv = _enable_virtualenv_default()
diff --git a/src/engine/SCons/Platform/VETests.py b/src/engine/SCons/Platform/virtualenvTests.py
index 8fd94af..02b37ab 100644
--- a/src/engine/SCons/Platform/VETests.py
+++ b/src/engine/SCons/Platform/virtualenvTests.py
@@ -30,7 +30,7 @@ import unittest
import os
import sys
-import SCons.Platform.VE
+import SCons.Platform.virtualenv
import SCons.Util
class Environment(collections.UserDict):
@@ -110,26 +110,6 @@ class SysPrefixes(object):
sys.prefix = s['prefix']
del self._stored
-class OsEnviron(object):
- """Used to temporarily mock os.environ"""
- def __init__(self, environ):
- self._environ = environ
-
- def start(self):
- self._stored = os.environ
- os.environ = self._environ
-
- def stop(self):
- os.environ = self._stored
- del self._stored
-
- def __enter__(self):
- self.start()
- return os.environ
-
- def __exit__(self, *args):
- self.stop()
-
def _p(p):
"""Converts path string **p** from posix format to os-specific format."""
drive = []
@@ -138,42 +118,6 @@ def _p(p):
pieces = p.split('/')
return os.path.sep.join(drive + pieces)
-class _get_bool_envvar_TestCase(unittest.TestCase):
- def test_missing(self):
- with OsEnviron(dict()):
- var = SCons.Platform.VE._get_bool_envvar('FOO')
- assert var is False, "var should be False, not %s" % repr(var)
- with OsEnviron({'FOO': '1'}):
- var = SCons.Platform.VE._get_bool_envvar('BAR')
- assert var is False, "var should be False, not %s" % repr(var)
-
- def test_true(self):
- for foo in [ 'TRUE', 'True', 'true',
- 'YES', 'Yes', 'yes',
- 'Y', 'y',
- 'ON', 'On', 'on',
- '1', '20', '-1']:
- with OsEnviron({'FOO': foo}):
- var = SCons.Platform.VE._get_bool_envvar('FOO')
- assert var is True, 'var should be True, not %s' % repr(var)
-
- def test_false(self):
- for foo in [ 'FALSE', 'False', 'false',
- 'NO', 'No', 'no',
- 'N', 'n',
- 'OFF', 'Off', 'off',
- '0']:
- with OsEnviron({'FOO': foo}):
- var = SCons.Platform.VE._get_bool_envvar('FOO', True)
- assert var is False, 'var should be True, not %s' % repr(var)
-
- def test_default(self):
- with OsEnviron({'FOO': 'other'}):
- var = SCons.Platform.VE._get_bool_envvar('FOO', True)
- assert var is True, 'var should be True, not %s' % repr(var)
- var = SCons.Platform.VE._get_bool_envvar('FOO', False)
- assert var is False, 'var should be False, not %s' % repr(var)
-
class _is_path_in_TestCase(unittest.TestCase):
def test_false(self):
@@ -184,7 +128,7 @@ class _is_path_in_TestCase(unittest.TestCase):
(_p('/foo/bar'), _p('/foo/bar/geez')),
(_p('/'), _p('/foo')),
(_p('foo'), _p('foo/bar')) ]:
- assert SCons.Platform.VE._is_path_in(*args) is False, "_is_path_in(%r, %r) should be False" % args
+ assert SCons.Platform.virtualenv._is_path_in(*args) is False, "_is_path_in(%r, %r) should be False" % args
def test__true(self):
for args in [ (_p('/foo'), _p('/')),
@@ -193,7 +137,7 @@ class _is_path_in_TestCase(unittest.TestCase):
(_p('/foo//bar//geez'), _p('/foo/bar')),
(_p('/foo/bar/geez'), _p('/foo//bar')),
(_p('/foo/bar/geez'), _p('//foo//bar')) ]:
- assert SCons.Platform.VE._is_path_in(*args) is True, "_is_path_in(%r, %r) should be True" % args
+ assert SCons.Platform.virtualenv._is_path_in(*args) is True, "_is_path_in(%r, %r) should be True" % args
class IsInVirtualenvTestCase(unittest.TestCase):
def test_false(self):
@@ -203,7 +147,7 @@ class IsInVirtualenvTestCase(unittest.TestCase):
_p('/foo'),
_p('/prefix'),
_p('/prefix/foo') ]:
- assert SCons.Platform.VE.IsInVirtualenv(p) is False, "IsInVirtualenv(%r) should be False" % p
+ assert SCons.Platform.virtualenv.IsInVirtualenv(p) is False, "IsInVirtualenv(%r) should be False" % p
# "with virtualenv"
with SysPrefixes(_p('/virtualenv/prefix'), real_prefix=_p('/real/prefix')):
@@ -213,7 +157,7 @@ class IsInVirtualenvTestCase(unittest.TestCase):
_p('/virtualenv/prefix/bar/..'),
_p('/virtualenv/prefix/bar/../../bleah'),
_p('/virtualenv/bleah') ]:
- assert SCons.Platform.VE.IsInVirtualenv(p) is False, "IsInVirtualenv(%r) should be False" % p
+ assert SCons.Platform.virtualenv.IsInVirtualenv(p) is False, "IsInVirtualenv(%r) should be False" % p
# "with venv"
with SysPrefixes(_p('/virtualenv/prefix'), base_prefix=_p('/base/prefix')):
@@ -223,20 +167,20 @@ class IsInVirtualenvTestCase(unittest.TestCase):
_p('/virtualenv/prefix/bar/..'),
_p('/virtualenv/prefix/bar/../../bleah'),
_p('/virtualenv/bleah') ]:
- assert SCons.Platform.VE.IsInVirtualenv(p) is False, "IsInVirtualenv(%r) should be False" % p
+ assert SCons.Platform.virtualenv.IsInVirtualenv(p) is False, "IsInVirtualenv(%r) should be False" % p
def test_true(self):
# "with virtualenv"
with SysPrefixes(_p('/virtualenv/prefix'), real_prefix=_p('/real/prefix')):
for p in [ _p('/virtualenv/prefix/foo'),
_p('/virtualenv/prefix/foo/bar') ]:
- assert SCons.Platform.VE.IsInVirtualenv(p) is True, "IsInVirtualenv(%r) should be True" % p
+ assert SCons.Platform.virtualenv.IsInVirtualenv(p) is True, "IsInVirtualenv(%r) should be True" % p
# "with venv"
with SysPrefixes(_p('/virtualenv/prefix'), base_prefix=_p('/base/prefix')):
for p in [ _p('/virtualenv/prefix/foo'),
_p('/virtualenv/prefix/foo/bar') ]:
- assert SCons.Platform.VE.IsInVirtualenv(p) is True, "IsInVirtualenv(%r) should be True" % p
+ assert SCons.Platform.virtualenv.IsInVirtualenv(p) is True, "IsInVirtualenv(%r) should be True" % p
class _inject_venv_pathTestCase(unittest.TestCase):
def path_list(self):
@@ -252,13 +196,13 @@ class _inject_venv_pathTestCase(unittest.TestCase):
env = Environment()
path_string = os.path.pathsep.join(self.path_list())
with SysPrefixes(_p('/virtualenv/prefix'), real_prefix=_p('/real/prefix')):
- SCons.Platform.VE._inject_venv_path(env, path_string)
+ SCons.Platform.virtualenv._inject_venv_path(env, path_string)
assert env['ENV']['PATH'] == _p('/virtualenv/prefix/bin'), env['ENV']['PATH']
def test_with_path_list(self):
env = Environment()
with SysPrefixes(_p('/virtualenv/prefix'), real_prefix=_p('/real/prefix')):
- SCons.Platform.VE._inject_venv_path(env, self.path_list())
+ SCons.Platform.virtualenv._inject_venv_path(env, self.path_list())
assert env['ENV']['PATH'] == _p('/virtualenv/prefix/bin'), env['ENV']['PATH']
class VirtualenvTestCase(unittest.TestCase):
@@ -267,10 +211,10 @@ class VirtualenvTestCase(unittest.TestCase):
return "Virtualenv() should be None, not %s" % repr(given)
with SysPrefixes(_p('/prefix')):
- ve = SCons.Platform.VE.Virtualenv()
+ ve = SCons.Platform.virtualenv.Virtualenv()
assert ve is None , _msg(ve)
with SysPrefixes(_p('/base/prefix'), base_prefix=_p('/base/prefix')):
- ve = SCons.Platform.VE.Virtualenv()
+ ve = SCons.Platform.virtualenv.Virtualenv()
assert ve is None, _msg(ve)
def test_not_none(self):
@@ -278,13 +222,13 @@ class VirtualenvTestCase(unittest.TestCase):
return "Virtualenv() should == %r, not %s" % (_p(expected), repr(given))
with SysPrefixes(_p('/virtualenv/prefix'), real_prefix=_p('/real/prefix')):
- ve = SCons.Platform.VE.Virtualenv()
+ ve = SCons.Platform.virtualenv.Virtualenv()
assert ve == _p('/virtualenv/prefix'), _msg('/virtualenv/prefix', ve)
with SysPrefixes(_p('/same/prefix'), real_prefix=_p('/same/prefix')):
- ve = SCons.Platform.VE.Virtualenv()
+ ve = SCons.Platform.virtualenv.Virtualenv()
assert ve == _p('/same/prefix'), _msg('/same/prefix', ve)
with SysPrefixes(_p('/virtualenv/prefix'), base_prefix=_p('/base/prefix')):
- ve = SCons.Platform.VE.Virtualenv()
+ ve = SCons.Platform.virtualenv.Virtualenv()
assert ve == _p('/virtualenv/prefix'), _msg('/virtualenv/prefix', ve)
diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py
index 0cd8399..3b76208 100644
--- a/src/engine/SCons/Platform/win32.py
+++ b/src/engine/SCons/Platform/win32.py
@@ -39,8 +39,8 @@ import tempfile
from SCons.Platform.posix import exitvalmap
from SCons.Platform import TempFileMunge
-from SCons.Platform.VE import ImportVirtualenv
-from SCons.Platform.VE import ignore_virtualenv, enable_virtualenv
+from SCons.Platform.virtualenv import ImportVirtualenv
+from SCons.Platform.virtualenv import ignore_virtualenv, enable_virtualenv
import SCons.Util
try:
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py
index daa6be8..2c59808 100644
--- a/src/engine/SCons/Script/Main.py
+++ b/src/engine/SCons/Script/Main.py
@@ -59,7 +59,7 @@ import SCons.Job
import SCons.Node
import SCons.Node.FS
import SCons.Platform
-import SCons.Platform.VE
+import SCons.Platform.virtualenv
import SCons.SConf
import SCons.Script
import SCons.Taskmaster
@@ -864,12 +864,12 @@ def _main(parser):
for warning_type, message in delayed_warnings:
SCons.Warnings.warn(warning_type, message)
- if not SCons.Platform.VE.virtualenv_enabled_by_default:
+ if not SCons.Platform.virtualenv.virtualenv_enabled_by_default:
if options.enable_virtualenv:
- SCons.Platform.VE.enable_virtualenv = True
+ SCons.Platform.virtualenv.enable_virtualenv = True
if options.ignore_virtualenv:
- SCons.Platform.VE.ignore_virtualenv = True
+ SCons.Platform.virtualenv.ignore_virtualenv = True
if options.diskcheck:
SCons.Node.FS.set_diskcheck(options.diskcheck)
diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py
index a18c6b9..37dd644 100644
--- a/src/engine/SCons/Script/SConsOptions.py
+++ b/src/engine/SCons/Script/SConsOptions.py
@@ -38,7 +38,7 @@ except ImportError:
_ = gettext
import SCons.Node.FS
-import SCons.Platform.VE
+import SCons.Platform.virtualenv
import SCons.Warnings
OptionValueError = optparse.OptionValueError
@@ -707,7 +707,7 @@ def Parser(version):
action="callback", callback=opt_duplicate,
help=opt_duplicate_help)
- if not SCons.Platform.VE.virtualenv_enabled_by_default:
+ if not SCons.Platform.virtualenv.virtualenv_enabled_by_default:
op.add_option('--enable-virtualenv',
dest="enable_virtualenv",
action="store_true",
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py
index ee3a191..d602507 100644
--- a/src/engine/SCons/Script/__init__.py
+++ b/src/engine/SCons/Script/__init__.py
@@ -82,7 +82,7 @@ import SCons.Builder
import SCons.Environment
import SCons.Node.FS
import SCons.Platform
-import SCons.Platform.VE
+import SCons.Platform.virtualenv
import SCons.Scanner
import SCons.SConf
import SCons.Subst
@@ -150,7 +150,7 @@ Environment = SCons.Environment.Environment
#OptParser = SCons.SConsOptions.OptParser
FindPathDirs = SCons.Scanner.FindPathDirs
Platform = SCons.Platform.Platform
-Virtualenv = SCons.Platform.VE.Virtualenv
+Virtualenv = SCons.Platform.virtualenv.Virtualenv
Return = _SConscript.Return
Scanner = SCons.Scanner.Base
Tool = SCons.Tool.Tool
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index 6643b72..4588955 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -1597,6 +1597,32 @@ def cmp(a, b):
return (a > b) - (a < b)
+def get_bool_envvar(name, default=False):
+ """
+ Get a value of OS environment variable converting it to boolean.
+
+ - FOO=1, FOO=123, FOO=true, FOO=yes, FOO=y, FOO=on are examples of ``True``
+ values.
+ - FOO=0, FOO=false, FOO=no, FOO=n, FOO=off are examples of ``False``
+ values.
+
+ If a variable can't be converted to a boolean, default value is returned
+ (``False`` by default)
+ """
+ try:
+ var = os.environ[name]
+ except KeyError:
+ return default
+ try:
+ return bool(int(var))
+ except ValueError:
+ if str(var).lower() in ('true', 'yes', 'y', 'on'):
+ return True
+ elif str(var).lower() in ('false', 'no', 'n', 'off'):
+ return False
+ else:
+ return default
+
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py
index 209c60f..6067c98 100644
--- a/src/engine/SCons/UtilTests.py
+++ b/src/engine/SCons/UtilTests.py
@@ -884,6 +884,64 @@ class flattenTestCase(unittest.TestCase):
self.assertEqual(sorted(result),[1,2,3])
+class OsEnviron(object):
+ """Used to temporarily mock os.environ"""
+ def __init__(self, environ):
+ self._environ = environ
+
+ def start(self):
+ self._stored = os.environ
+ os.environ = self._environ
+
+ def stop(self):
+ os.environ = self._stored
+ del self._stored
+
+ def __enter__(self):
+ self.start()
+ return os.environ
+
+ def __exit__(self, *args):
+ self.stop()
+
+
+class get_bool_envvarTestCase(unittest.TestCase):
+ def test_missing(self):
+ with OsEnviron(dict()):
+ var = get_bool_envvar('FOO')
+ assert var is False, "var should be False, not %s" % repr(var)
+ with OsEnviron({'FOO': '1'}):
+ var = get_bool_envvar('BAR')
+ assert var is False, "var should be False, not %s" % repr(var)
+
+ def test_true(self):
+ for foo in [ 'TRUE', 'True', 'true',
+ 'YES', 'Yes', 'yes',
+ 'Y', 'y',
+ 'ON', 'On', 'on',
+ '1', '20', '-1']:
+ with OsEnviron({'FOO': foo}):
+ var = get_bool_envvar('FOO')
+ assert var is True, 'var should be True, not %s' % repr(var)
+
+ def test_false(self):
+ for foo in [ 'FALSE', 'False', 'false',
+ 'NO', 'No', 'no',
+ 'N', 'n',
+ 'OFF', 'Off', 'off',
+ '0']:
+ with OsEnviron({'FOO': foo}):
+ var = get_bool_envvar('FOO', True)
+ assert var is False, 'var should be True, not %s' % repr(var)
+
+ def test_default(self):
+ with OsEnviron({'FOO': 'other'}):
+ var = get_bool_envvar('FOO', True)
+ assert var is True, 'var should be True, not %s' % repr(var)
+ var = get_bool_envvar('FOO', False)
+ assert var is False, 'var should be False, not %s' % repr(var)
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/test/virtualenv/activated/option/enable-virtualenv.py b/test/virtualenv/activated/option/enable-virtualenv.py
index dc3fa76..a5ceecc 100644
--- a/test/virtualenv/activated/option/enable-virtualenv.py
+++ b/test/virtualenv/activated/option/enable-virtualenv.py
@@ -29,25 +29,25 @@ Ensure that the --enable-virtualenv flag works.
"""
import TestSCons
-import SCons.Platform.VE
+import SCons.Platform.virtualenv
import sys
import os
import re
test = TestSCons.TestSCons()
-if SCons.Platform.VE.virtualenv_enabled_by_default:
+if SCons.Platform.virtualenv.virtualenv_enabled_by_default:
test.skip_test("Virtualenv support enabled by default, the option --enable-virtualenv is unavailable, skipping\n")
-if not SCons.Platform.VE.Virtualenv():
+if not SCons.Platform.virtualenv.Virtualenv():
test.skip_test("No virtualenv detected, skipping\n")
-if not SCons.Platform.VE.select_paths_in_venv(os.getenv('PATH','')):
+if not SCons.Platform.virtualenv.select_paths_in_venv(os.getenv('PATH','')):
test.skip_test("Virtualenv detected but looks like unactivated, skipping\n")
test.write('SConstruct', """
import sys
-import SCons.Platform.VE
+import SCons.Platform.virtualenv
env = DefaultEnvironment(tools=[])
print("sys.executable: %r" % sys.executable)
print("env.WhereIs('python'): %r" % env.WhereIs('python'))
@@ -77,9 +77,9 @@ can't determine env.WhereIs('python') from stdout:
python = eval(m.group('py'))
-test.fail_test(not SCons.Platform.VE.IsInVirtualenv(interpreter),
+test.fail_test(not SCons.Platform.virtualenv.IsInVirtualenv(interpreter),
message="sys.executable points outside of virtualenv")
-test.fail_test(not SCons.Platform.VE.IsInVirtualenv(python),
+test.fail_test(not SCons.Platform.virtualenv.IsInVirtualenv(python),
message="env.WhereIs('python') points to virtualenv")
test.pass_test()
diff --git a/test/virtualenv/activated/option/ignore-virtualenv.py b/test/virtualenv/activated/option/ignore-virtualenv.py
index 05b462d..ac6f945 100644
--- a/test/virtualenv/activated/option/ignore-virtualenv.py
+++ b/test/virtualenv/activated/option/ignore-virtualenv.py
@@ -29,22 +29,22 @@ Ensure that the --ignore-virtualenv flag works.
"""
import TestSCons
-import SCons.Platform.VE
+import SCons.Platform.virtualenv
import sys
import os
import re
test = TestSCons.TestSCons()
-if not SCons.Platform.VE.Virtualenv():
+if not SCons.Platform.virtualenv.Virtualenv():
test.skip_test("No virtualenv detected, skipping\n")
-if not SCons.Platform.VE.select_paths_in_venv(os.getenv('PATH','')):
+if not SCons.Platform.virtualenv.select_paths_in_venv(os.getenv('PATH','')):
test.skip_test("Virtualenv detected but looks like unactivated, skipping\n")
test.write('SConstruct', """
import sys
-import SCons.Platform.VE
+import SCons.Platform.virtualenv
env = DefaultEnvironment(tools=[])
print("sys.executable: %s" % repr(sys.executable))
print("env.WhereIs('python'): %s" % repr(env.WhereIs('python')))
@@ -76,9 +76,9 @@ can't determine env.WhereIs('python') from stdout:
python = eval(m.group('py'))
-test.fail_test(not SCons.Platform.VE.IsInVirtualenv(interpreter),
+test.fail_test(not SCons.Platform.virtualenv.IsInVirtualenv(interpreter),
message="sys.executable points outside of virtualenv")
-test.fail_test(SCons.Platform.VE.IsInVirtualenv(python),
+test.fail_test(SCons.Platform.virtualenv.IsInVirtualenv(python),
message="env.WhereIs('python') points to virtualenv")
test.pass_test()
diff --git a/test/virtualenv/activated/virtualenv_activated_python.py b/test/virtualenv/activated/virtualenv_activated_python.py
index 3f591d6..c673ae1 100644
--- a/test/virtualenv/activated/virtualenv_activated_python.py
+++ b/test/virtualenv/activated/virtualenv_activated_python.py
@@ -32,17 +32,17 @@ environment or in unactivated virtualenv.
"""
import TestSCons
-import SCons.Platform.VE
+import SCons.Platform.virtualenv
import sys
import os
import re
test = TestSCons.TestSCons()
-if not SCons.Platform.VE.Virtualenv():
+if not SCons.Platform.virtualenv.Virtualenv():
test.skip_test("No virtualenv detected, skipping\n")
-if not SCons.Platform.VE.select_paths_in_venv(os.getenv('PATH')):
+if not SCons.Platform.virtualenv.select_paths_in_venv(os.getenv('PATH')):
test.skip_test("Virtualenv detected but looks like unactivated, skipping\n")
@@ -53,7 +53,7 @@ print("sys.executable: %s" % repr(sys.executable))
print("env.WhereIs('python'): %s" % repr(env.WhereIs('python')))
""")
-if SCons.Platform.VE.virtualenv_enabled_by_default:
+if SCons.Platform.virtualenv.virtualenv_enabled_by_default:
test.run(['-Q'])
else:
test.run(['-Q', '--enable-virtualenv'])
@@ -82,9 +82,9 @@ can't determine env.WhereIs('python') from stdout:
python = eval(m.group('py'))
# runing in activated virtualenv (after "activate") - PATH includes virtualenv's bin directory
-test.fail_test(not SCons.Platform.VE.IsInVirtualenv(interpreter),
+test.fail_test(not SCons.Platform.virtualenv.IsInVirtualenv(interpreter),
message="sys.executable points outside of virtualenv")
-test.fail_test(not SCons.Platform.VE.IsInVirtualenv(python),
+test.fail_test(not SCons.Platform.virtualenv.IsInVirtualenv(python),
message="env.WhereIs('python') points outside of virtualenv")
test.pass_test()
diff --git a/test/virtualenv/activated/virtualenv_detect_virtualenv.py b/test/virtualenv/activated/virtualenv_detect_virtualenv.py
index 0eba385..2c00793 100644
--- a/test/virtualenv/activated/virtualenv_detect_virtualenv.py
+++ b/test/virtualenv/activated/virtualenv_detect_virtualenv.py
@@ -25,16 +25,16 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
"""
-Check if SCons.Platform.VE.Virtualenv() works in SConscripts.
+Check if SCons.Platform.virtualenv.Virtualenv() works in SConscripts.
"""
import TestSCons
-import SCons.Platform.VE
+import SCons.Platform.virtualenv
import sys
test = TestSCons.TestSCons()
-ve = SCons.Platform.VE.Virtualenv()
+ve = SCons.Platform.virtualenv.Virtualenv()
if not ve:
test.skip_test("Virtualenv is not active, skipping\n")
@@ -42,7 +42,7 @@ test.write('SConstruct', """
print("virtualenv: %r" % Virtualenv())
""")
-if SCons.Platform.VE.virtualenv_enabled_by_default:
+if SCons.Platform.virtualenv.virtualenv_enabled_by_default:
test.run(['-Q'])
else:
test.run(['-Q', '--enable-virtualenv'])
diff --git a/test/virtualenv/always/virtualenv_global_function.py b/test/virtualenv/always/virtualenv_global_function.py
index 18f93f8..8f2c291 100644
--- a/test/virtualenv/always/virtualenv_global_function.py
+++ b/test/virtualenv/always/virtualenv_global_function.py
@@ -31,7 +31,7 @@ contains the virtualenv's bin path).
"""
import TestSCons
-import SCons.Platform.VE
+import SCons.Platform.virtualenv
import re
test = TestSCons.TestSCons()
@@ -53,7 +53,7 @@ can't determine Virtualenv() result from stdout:
""" % s)
scons_ve = m.group('ve')
-our_ve = "%r" % SCons.Platform.VE.Virtualenv()
+our_ve = "%r" % SCons.Platform.virtualenv.Virtualenv()
# runing in activated virtualenv (after "activate") - PATH includes virtualenv's bin directory
test.fail_test(scons_ve != our_ve,
diff --git a/test/virtualenv/regularenv/virtualenv_detect_regularenv.py b/test/virtualenv/regularenv/virtualenv_detect_regularenv.py
index e5dbc61..57a0d4f 100644
--- a/test/virtualenv/regularenv/virtualenv_detect_regularenv.py
+++ b/test/virtualenv/regularenv/virtualenv_detect_regularenv.py
@@ -25,23 +25,23 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
"""
-Check if SCons.Platform.VE.Virtualenv() works in SConscript.
+Check if SCons.Platform.virtualenv.Virtualenv() works in SConscript.
"""
import TestSCons
-import SCons.Platform.VE
+import SCons.Platform.virtualenv
import sys
test = TestSCons.TestSCons()
-if SCons.Platform.VE.Virtualenv():
+if SCons.Platform.virtualenv.Virtualenv():
test.skip_test("Virtualenv is active, skipping\n")
test.write('SConstruct', """
print("virtualenv: %r" % Virtualenv())
""")
-if SCons.Platform.VE.virtualenv_enabled_by_default:
+if SCons.Platform.virtualenv.virtualenv_enabled_by_default:
test.run(['-Q'])
else:
test.run(['-Q', '--enable-virtualenv'])
diff --git a/test/virtualenv/unactivated/virtualenv_unactivated_python.py b/test/virtualenv/unactivated/virtualenv_unactivated_python.py
index a087318..a4dc240 100644
--- a/test/virtualenv/unactivated/virtualenv_unactivated_python.py
+++ b/test/virtualenv/unactivated/virtualenv_unactivated_python.py
@@ -32,17 +32,17 @@ a regular environment or in an activated virtualenv.
"""
import TestSCons
-import SCons.Platform.VE
+import SCons.Platform.virtualenv
import sys
import os
import re
test = TestSCons.TestSCons()
-if not SCons.Platform.VE.Virtualenv():
+if not SCons.Platform.virtualenv.Virtualenv():
test.skip_test("No virtualenv detected, skipping\n")
-if SCons.Platform.VE.select_paths_in_venv(os.getenv('PATH')):
+if SCons.Platform.virtualenv.select_paths_in_venv(os.getenv('PATH')):
test.skip_test("Virtualenv detected and it looks like activated, skipping\n")
test.write('SConstruct', """
@@ -52,7 +52,7 @@ print("sys.executable: %s" % repr(sys.executable))
print("env.WhereIs('python'): %s" % repr(env.WhereIs('python')))
""")
-if SCons.Platform.VE.virtualenv_enabled_by_default:
+if SCons.Platform.virtualenv.virtualenv_enabled_by_default:
test.run(['-Q'])
else:
test.run(['-Q', '--enable-virtualenv'])
@@ -81,9 +81,9 @@ can't determine env.WhereIs('python') from stdout:
python = eval(m.group('py'))
# running without activating virtualenv (by just /path/to/virtualenv/bin/python runtest.py ...).
-test.fail_test(not SCons.Platform.VE.IsInVirtualenv(interpreter),
+test.fail_test(not SCons.Platform.virtualenv.IsInVirtualenv(interpreter),
message="sys.executable points outside of virtualenv")
-test.fail_test(SCons.Platform.VE.IsInVirtualenv(python),
+test.fail_test(SCons.Platform.virtualenv.IsInVirtualenv(python),
message="env.WhereIs('python') points to virtualenv")
test.pass_test()