@@ -218,6 +218,8 @@ def __setup(venv_dir, requirements=None, force_reinstall=False, no_cache=True, v
218218 if isinstance (requirements , str ):
219219 with open (requirements ) as f :
220220 requirements = [l .strip () for l in f ]
221+ if requirements is None :
222+ requirements = []
221223 if isinstance (requirements , (tuple , list , set )):
222224 args = []
223225 if force_reinstall :
@@ -227,10 +229,12 @@ def __setup(venv_dir, requirements=None, force_reinstall=False, no_cache=True, v
227229 if verbose :
228230 args .append ("-v" )
229231 kwargs = {'prefix' : venv_dir }
232+ if not __is_installed ("setuptools" ):
233+ requirements = ["setuptools" ] + [r for r in requirements if r != "setuptools" ]
230234 for req in requirements :
231235 pkg = __install (req , * args , ** kwargs )
232236 for tl in pkg .top_level :
233- if hasattr (virtualenv , tl ):
237+ if hasattr (virtualenv , tl ) and req != "setuptools" :
234238 raise TopLevelAlreadyExists ("{} ({})" .format (tl , pkg .name ))
235239 m = import_module (tl )
236240 setattr (virtualenv , tl , m )
@@ -250,7 +254,7 @@ def __teardown(venv_dir=None):
250254virtualenv .teardown = __teardown
251255
252256
253- class PipPackage ( object ) :
257+ class PipPackage :
254258 """
255259 This class is used to represent a Pip package and its attribute.
256260 """
@@ -290,7 +294,7 @@ def __init__(self, name, error=True):
290294virtualenv .PipPackage = PipPackage
291295
292296
293- class VirtualEnv ( object ) :
297+ class VirtualEnv :
294298 """
295299 This context manager simplifies the use of a virtual environment.
296300
0 commit comments