Commits

John Chilton  committed 6a2f3e8

Cleaning up package structure setup code in setup.py.

  • Participants
  • Parent commits d20219e

Comments (0)

Files changed (1)

 from os.path import join, isdir
 from shutil import copytree, copy, rmtree
 
+## Setup python package with needed module structure in lib directory.
 
-def setup_package_directory(directory):
-    target_dir = join('lib', directory)
-    try:
-        makedirs(target_dir)
-    except:
-        pass
+lib_dir="lib"
+
+def create_init_file(directory):
+    target_dir = join(lib_dir, directory)
     init_path = join(target_dir, '__init__.py')
     with file(init_path, 'a'):
         utime(init_path, None)
 
-rmtree("lib")
-package_dir=join("lib","mi_deployment")
-setup_package_directory("mi_deployment")
-for file_to_copy in ['data_fabfile.py', 'mi_fabfile.py', 'tools_fabfile.py', 'volume_manipulations_fab.py', 'util', 'tools']:
+rmtree(lib_dir)
+makedirs(join(lib_dir, "mi_deployment"))
+create_init_file("mi_deployment")
+package_files = ['data_fabfile.py', 
+                 'mi_fabfile.py', 
+                 'tools_fabfile.py', 
+                 'volume_manipulations_fab.py', 
+                 'util', 
+                 'tools']
+
+for file_to_copy in package_files:
     if isdir(file_to_copy):
         copy_func = copytree
     else:
         copy_func = copy
     copy_func(file_to_copy, join("lib", "mi_deployment", file_to_copy))
-setup_package_directory(join("mi_deployment", "tools"))
+
+create_init_file(join("mi_deployment", "tools"))
 
 
 setup(name="mi-deployment",