[setup.py] py3 compat
authorArthur Lutz <arthur.lutz@logilab.fr>
Tue, 17 Jan 2017 11:54:19 +0100
changeset 367 d269f913a0a6
parent 366 a03b280a3981
child 368 f807b073b7d3
[setup.py] py3 compat
setup.py
--- a/setup.py	Fri Jan 06 11:03:33 2017 +0100
+++ b/setup.py	Tue Jan 17 11:54:19 2017 +0100
@@ -25,8 +25,12 @@
 import os
 import sys
 import shutil
-from os.path import exists, join, dirname
-
+try:
+    from os.path import exists, join, walk, dirname
+except ImportError: #PY3
+    from os.path import exists, join, dirname
+    from os import walk
+    
 try:
     if os.environ.get('NO_SETUPTOOLS'):
         raise ImportError()  # do as there is no setuptools
@@ -39,7 +43,10 @@
     USE_SETUPTOOLS = False
 from distutils.command import install_data
 
-
+if exists('README'):
+    long_description = open('README').read()
+else:
+    long_description = ''
 # load metadata from the __pkginfo__.py file so there is no risk of conflict
 # see https://packaging.python.org/en/latest/single_source_version.html
 base_dir = dirname(__file__)
@@ -127,7 +134,21 @@
                 os.remove(dest)
             if verbose:
                 sys.stderr.write('%s -> %s\n' % (src, dest))
-            shutil.copy2(src, dest)
+            if os.path.isdir(src):
+                if not exists(dest):
+                    os.mkdir(dest)
+            else:
+                if exists(dest):
+                    os.remove(dest)
+                shutil.copy2(src, dest)
+    try:
+        os.mkdir(to_dir)
+    except OSError as ex:
+        # file exists ?
+        import errno
+        if ex.errno != errno.EEXIST:
+            raise
+    walk(from_dir, make_mirror, None)
 
 
 class MyInstallLib(install_lib.install_lib):