diff --git a/migrate/versioning/util/importpath.py b/migrate/versioning/util/importpath.py index 5ab7128..529be89 100644 --- a/migrate/versioning/util/importpath.py +++ b/migrate/versioning/util/importpath.py @@ -1,18 +1,30 @@ import os import sys -from six.moves import reload_module as reload +PY33 = sys.version_info >= (3, 3) + +if PY33: + from importlib import machinery +else: + from six.moves import reload_module as reload + def import_path(fullpath): """ Import a file with full path specification. Allows one to import from anywhere, something __import__ does not do. """ - # http://zephyrfalcon.org/weblog/arch_d7_2002_08_31.html - path, filename = os.path.split(fullpath) - filename, ext = os.path.splitext(filename) - sys.path.append(path) - module = __import__(filename) - reload(module) # Might be out of date during tests - del sys.path[-1] - return module - + if PY33: + name = os.path.splitext(os.path.basename(fullpath))[0] + return machinery.SourceFileLoader( + name, fullpath).load_module(name) + else: + # http://zephyrfalcon.org/weblog/arch_d7_2002_08_31.html + path, filename = os.path.split(fullpath) + filename, ext = os.path.splitext(filename) + sys.path.append(path) + try: + module = __import__(filename) + reload(module) # Might be out of date during tests + return module + finally: + del sys.path[-1] diff --git a/requirements.txt b/requirements.txt index d475532..e4da828 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -pbr>=0.11,<2.0 +pbr>=1.3,<2.0 # never put a cap on this, *ever*, sqla versions are handled via # tox, and if SQLA is capped it will only make it so we aren't testing diff --git a/setup.py b/setup.py index c0a24ea..f8fcdec 100644 --- a/setup.py +++ b/setup.py @@ -16,6 +16,14 @@ import setuptools +# In python < 2.7.4, a lazy loading of package `pbr` will break +# setuptools if some other modules registered functions in `atexit`. +# solution from: http://bugs.python.org/issue15881#msg170215 +try: + import multiprocessing # noqa +except ImportError: + pass + setuptools.setup( - setup_requires=['pbr'], + setup_requires=['pbr>=1.3'], pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt index cd5cb69..b4bba70 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -8,7 +8,7 @@ coverage>=3.6 discover feedparser fixtures>=0.3.14 -mock>=1.0 +mock>=1.2 mox>=0.5.3 psycopg2 python-subunit>=0.0.18