1313    for  pkg  in  ('tox-3.0.0.zip' , 'virtualenv-15.2.0.zip' ):
1414        sys .path .append (os .path .join (os .path .dirname (__file__ ),'_vendor' ,pkg ))
1515    import  tox .config  as  tox_config 
16-     
16+ 
17+ try :
18+     import  setuptools 
19+     from  setuptools ._vendor .packaging .version  import  Version 
20+     setuptools_version  =  Version (setuptools .__version__ )
21+ except  ImportError :
22+     setuptools_version  =  None 
23+ 
1724toxconf  =  tox_config .parseconfig ('tox' )
1825# we later filter out any _onlytox commands... 
1926toxconf_pre  =  configparser .ConfigParser ()
@@ -166,7 +173,12 @@ def echo(msg):
166173def  _get_setup_metadata ():
167174    meta  =  None 
168175    if  os .path .exists ("setup.cfg" ):
169-         from  setuptools .config  import  read_configuration 
176+         if  setuptools_version  is  None :
177+             raise  ImportError ('setuptools is not installed.' )
178+         if  setuptools_version  >=  Version ('61.0.0' ):
179+             from  setuptools .config .setupcfg  import  read_configuration 
180+         else :
181+             from  setuptools .config  import  read_configuration 
170182        setupcfg  =  read_configuration ("setup.cfg" )
171183        if  'options'  in  setupcfg :
172184            if  'install_requires'  in  setupcfg ['options' ]:
@@ -186,7 +198,12 @@ def _get_setup_metadata():
186198def  _get_setup_metadata2 (k ):
187199    meta  =  None 
188200    if  os .path .exists ("setup.cfg" ):
189-         from  setuptools .config  import  read_configuration 
201+         if  setuptools_version  is  None :
202+             raise  ImportError ('setuptools is not installed.' )
203+         if  setuptools_version  >=  Version ('61.0.0' ):
204+             from  setuptools .config .setupcfg  import  read_configuration 
205+         else :
206+             from  setuptools .config  import  read_configuration 
190207        setupcfg  =  read_configuration ("setup.cfg" )
191208        if  k  in  setupcfg ['metadata' ]:
192209            return  setupcfg ['metadata' ][k ]
@@ -254,7 +271,12 @@ def get_buildreqs():
254271# % sign for the git format (autover), but that breaking some version 
255272# of config reading.) Replace bit by bit and see what happens? 
256273def  read_pins (f ):
257-     from  setuptools .config  import  ConfigHandler 
274+     if  setuptools_version  is  None :
275+         raise  ImportError ('setuptools is not installed.' )
276+     if  setuptools_version  >=  Version ('61.0.0' ):
277+         from  setuptools .config .setupcfg  import  ConfigHandler 
278+     else :
279+         from  setuptools .config  import  ConfigHandler 
258280    # duplicates some earlier configparser stuff (which doesn't 
259281    # support py2; need to clean up) 
260282    try :
@@ -276,7 +298,12 @@ def read_pins(f):
276298    return  ConfigHandler ._parse_dict (pins_raw )
277299
278300def  read_conda_packages (f ,name ):
279-     from  setuptools .config  import  ConfigHandler 
301+     if  setuptools_version  is  None :
302+         raise  ImportError ('setuptools is not installed.' )
303+     if  setuptools_version  >=  Version ('61.0.0' ):
304+         from  setuptools .config .setupcfg  import  ConfigHandler 
305+     else :
306+         from  setuptools .config  import  ConfigHandler 
280307    # duplicates some earlier configparser stuff (which doesn't 
281308    # support py2; need to clean up) 
282309    try :
@@ -300,7 +327,12 @@ def read_conda_packages(f,name):
300327
301328
302329def  read_conda_namespace_map (f ):
303-     from  setuptools .config  import  ConfigHandler 
330+     if  setuptools_version  is  None :
331+         raise  ImportError ('setuptools is not installed.' )
332+     if  setuptools_version  >=  Version ('61.0.0' ):
333+         from  setuptools .config .setupcfg  import  ConfigHandler 
334+     else :
335+         from  setuptools .config  import  ConfigHandler 
304336    # duplicates some earlier configparser stuff (which doesn't 
305337    # support py2; need to clean up) 
306338    try :
0 commit comments