From a2bc37a9e0b5559b1452ab9ca349b84ecbedddf2 Mon Sep 17 00:00:00 2001 From: Michael Kriese <michael.kriese@visualon.de> Date: Tue, 21 Jul 2020 14:05:46 +0200 Subject: [PATCH] fix(pip_setup): fix python deprecation message (#6788) --- data/extract.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/data/extract.py b/data/extract.py index a40ee5c125..eca591cf16 100644 --- a/data/extract.py +++ b/data/extract.py @@ -1,9 +1,21 @@ -from __future__ import print_function import sys -import imp import json +import os import distutils.core +if sys.version_info[:2] >= (3, 3): + from importlib.machinery import SourceFileLoader + def load_source(name, path): + if not os.path.exists(path): + return {} + return vars(SourceFileLoader('mod', path).load_module()) +else: + import imp + def load_source(name, path): + if not os.path.exists(path): + return {} + return vars(imp.load_source('mod', path)) + try: import setuptools except ImportError: @@ -21,7 +33,7 @@ except ImportError: @mock.patch.object(distutils.core, 'setup') def invoke(mock1, mock2): # This is setup.py which calls setuptools.setup - imp.load_source('_target_setup_', sys.argv[-1]) + load_source('_target_setup_', sys.argv[-1]) # called arguments are in `mock_setup.call_args` call_args = mock1.call_args or mock2.call_args args, kwargs = call_args -- GitLab