From 8d50f5116b9fdf53cede21f7e5b15dcd15f7e5dd Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 7 Feb 2019 16:42:18 +0300 Subject: [PATCH] Build(setup.py): Use `importlib` instead of deprecated `imp` for Python 3.4+ --- setup.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d2a518d..3dce134 100755 --- a/setup.py +++ b/setup.py @@ -1,8 +1,24 @@ #!/usr/bin/env python -from imp import load_source from os.path import abspath, dirname, join from setuptools import setup +import sys + +if sys.version_info[:2] == (2, 7): + from imp import load_source + +elif sys.version_info >= (3, 4): + from importlib.machinery import SourceFileLoader + import types + + def load_source(fullname, path): + loader = SourceFileLoader(fullname, path) + loaded = types.ModuleType(loader.name) + loader.exec_module(loaded) + return loaded + +else: + raise ImportError("ppu requires Python 2.7 or 3.4+") versionpath = join(abspath(dirname(__file__)), "ppu", "__version__.py") ppu_version = load_source("ppu_version", versionpath) -- 2.39.5