Repository: pypa/virtualenv

Issue:
Python 3.6 + virtualenv + -Wignore gives a traceback
Using virtualenv (15.0.3) seems to make an incomplete env on Python 3.6 (tested with dev snapshot from last night). Running 'venv/bin/python3.6 -Wignore' ends up with the following:

```
'import warnings' failed; traceback:
Traceback (most recent call last):
  File "/buildslave/ubuntu1604-python-3.6/Twisted/src/../build/py36-tests-posix/lib/python3.6/warnings.py", line 496, in <module>
    _processoptions(sys.warnoptions)
  File "/buildslave/ubuntu1604-python-3.6/Twisted/src/../build/py36-tests-posix/lib/python3.6/warnings.py", line 178, in _processoptions
    _setoption(arg)
  File "/buildslave/ubuntu1604-python-3.6/Twisted/src/../build/py36-tests-posix/lib/python3.6/warnings.py", line 184, in _setoption
    import re
  File "/buildslave/ubuntu1604-python-3.6/Twisted/src/../build/py36-tests-posix/lib/python3.6/re.py", line 122, in <module>
    import enum
ModuleNotFoundError: No module named 'enum'
Python 3.6.0b1+ (default, Oct  6 2016, 13:48:20)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
```

python3.6 outside of a virtualenv does not exhibit this behaviour, neither does 3.5 in/out of a virtualenv.



Discussion:
I'm guessing enum needs to be added to REQUIRED_MODULES on minver >= 6

That affect TravisCi in particular: https://github.com/travis-ci/travis-ci/issues/6613

which make testing one 3.6 sometime challenging. 

JFTR, I’m getting this error too but only **iff** warnings are activated:

```
/Users/hynek/Projects/argon2_cffi/.tox/py36/bin/python
Python 3.6.0b1 (default, Oct  6 2016, 13:50:01)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import enum
>>> import warnings
>>>
```

vs.

```
/Users/hynek/Projects/argon2_cffi/.tox/py36/bin/python -Wall
'import warnings' failed; traceback:
Traceback (most recent call last):
  File "/Users/hynek/Projects/argon2_cffi/.tox/py36/lib/python3.6/warnings.py", line 496, in <module>
    _processoptions(sys.warnoptions)
  File "/Users/hynek/Projects/argon2_cffi/.tox/py36/lib/python3.6/warnings.py", line 178, in _processoptions
    _setoption(arg)
  File "/Users/hynek/Projects/argon2_cffi/.tox/py36/lib/python3.6/warnings.py", line 184, in _setoption
    import re
  File "/Users/hynek/Projects/argon2_cffi/.tox/py36/lib/python3.6/re.py", line 122, in <module>
    import enum
ModuleNotFoundError: No module named 'enum'
Python 3.6.0b1 (default, Oct  6 2016, 13:50:01)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import enum
>>>
```

So this is clearly some bootstrapping problem.  I guess the warnings module gets imported before the site environment is ready?


Resolving patch:
diff --git a/virtualenv.py b/virtualenv.py
--- a/virtualenv.py
+++ b/virtualenv.py
@@ -155,6 +155,8 @@ def get_installed_pythons():
             '_collections_abc',
             '_bootlocale',
         ])
+    if minver >= 6:
+        REQUIRED_MODULES.extend(['enum'])
 
 if is_pypy:
     # these are needed to correctly display the exceptions that may happen


Test patch: