From c3f6333298c86e5681af282c7210eb1047a991dd Mon Sep 17 00:00:00 2001
From: schettino72 <schettino72@gmail.com>
Date: Sat, 30 Aug 2014 10:51:26 +0800
Subject: [PATCH] install sigledispatch only when required.

---
 mergedict.py | 7 +++++--
 setup.py     | 7 ++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/mergedict.py b/mergedict.py
index 5dcd994..ad80a16 100644
--- a/mergedict.py
+++ b/mergedict.py
@@ -26,8 +26,11 @@
 
 import sys
 import inspect
-from singledispatch import singledispatch
-
+try:
+    from functools import singledispatch
+# singledispatch was added on python 3.4
+except ImportError: # pragma: no cover
+    from singledispatch import singledispatch
 
 class MergeDict(dict):
     """Base class for a dict that implements a merge() method.
diff --git a/setup.py b/setup.py
index b37319e..1966b9a 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
 
+import sys
 import os
 import codecs
 from setuptools import setup
@@ -11,6 +12,10 @@
     long_description = ld_file.read()
 
 
+install_requires = []
+if sys.version_info[0] < 3 or sys.version_info[1] < 4:
+    install_requires.append('singledispatch')
+
 setup (
     name = 'mergedict',
     version = '0.2.0',
@@ -23,7 +28,7 @@
     platforms = ['any'],
     license = 'MIT',
     py_modules = ['mergedict'],
-    install_requires = ['singledispatch'],
+    install_requires = install_requires,
     classifiers = [
         'Development Status :: 4 - Beta',
         'Intended Audience :: Developers',
