13
13
for pkg in ('tox-3.0.0.zip' , 'virtualenv-15.2.0.zip' ):
14
14
sys .path .append (os .path .join (os .path .dirname (__file__ ),'_vendor' ,pkg ))
15
15
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
+
17
24
toxconf = tox_config .parseconfig ('tox' )
18
25
# we later filter out any _onlytox commands...
19
26
toxconf_pre = configparser .ConfigParser ()
@@ -166,7 +173,12 @@ def echo(msg):
166
173
def _get_setup_metadata ():
167
174
meta = None
168
175
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
170
182
setupcfg = read_configuration ("setup.cfg" )
171
183
if 'options' in setupcfg :
172
184
if 'install_requires' in setupcfg ['options' ]:
@@ -186,7 +198,12 @@ def _get_setup_metadata():
186
198
def _get_setup_metadata2 (k ):
187
199
meta = None
188
200
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
190
207
setupcfg = read_configuration ("setup.cfg" )
191
208
if k in setupcfg ['metadata' ]:
192
209
return setupcfg ['metadata' ][k ]
@@ -254,7 +271,12 @@ def get_buildreqs():
254
271
# % sign for the git format (autover), but that breaking some version
255
272
# of config reading.) Replace bit by bit and see what happens?
256
273
def 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
258
280
# duplicates some earlier configparser stuff (which doesn't
259
281
# support py2; need to clean up)
260
282
try :
@@ -276,7 +298,12 @@ def read_pins(f):
276
298
return ConfigHandler ._parse_dict (pins_raw )
277
299
278
300
def 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
280
307
# duplicates some earlier configparser stuff (which doesn't
281
308
# support py2; need to clean up)
282
309
try :
@@ -300,7 +327,12 @@ def read_conda_packages(f,name):
300
327
301
328
302
329
def 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
304
336
# duplicates some earlier configparser stuff (which doesn't
305
337
# support py2; need to clean up)
306
338
try :
0 commit comments