Skip to content
This repository
Browse code

Refine esky support in setup.py

* Add HAS_ESKY flag based on import tests rather than command line
  arguments.
* Add comments on reasoning for some setup kwargs
* Fix append bug for wmi dependency
* Revert part of e70d70a. Esky uses
  those kwargs regardless of the distribution stack used.
* Remove unused 'libraries' variable
  • Loading branch information...
commit b50cd76a2500712a934fa7189fb412006ba4c02e 1 parent 596e536
Aaron Tygart authored January 01, 2013

Showing 1 changed file with 22 additions and 14 deletions. Show diff stats Hide diff stats

  1. 36  setup.py
36  setup.py
@@ -31,6 +31,22 @@
31 31
 if with_setuptools is False:
32 32
     from distutils.core import setup
33 33
 
  34
+try:
  35
+    # Add the esky bdist target if the module is available
  36
+    # may require additional modules depending on platform
  37
+    from esky import bdist_esky
  38
+    # bbfreeze chosen for its tight integration with distutils
  39
+    import bbfreeze
  40
+    HAS_ESKY = True
  41
+except ImportError:
  42
+    # print function that supports the 'file' argument isn't available until
  43
+    # 2.6 http://docs.python.org/2.6/library/__future__.html
  44
+    # Using this method until 2.5 support is dropped.
  45
+    print >> sys.stderr, 'Cannot load esky build target'
  46
+    print >> sys.stderr, ('Please install the \'esky\' and the \'bbfreeze\' '
  47
+                          'modules to enable this functionality')
  48
+    HAS_ESKY = False
  49
+
34 50
 salt_version = os.path.join(os.path.abspath(
35 51
     os.path.dirname(__file__)), 'salt', 'version.py')
36 52
 
@@ -100,8 +116,6 @@ def run(self):
100 116
 else:
101 117
     etc_path = os.path.join(os.path.dirname(PREFIX), 'etc')
102 118
 
103  
-libraries = ['ws2_32'] if sys.platform == 'win32' else []
104  
-
105 119
 with open(salt_reqs) as f:
106 120
     lines = f.read().split('\n')
107 121
     requirements = [line for line in lines if line]
@@ -160,9 +174,10 @@ def run(self):
160 174
                                  ]),
161 175
                                ('share/man/man7', ['doc/man/salt.7']),
162 176
                                ],
  177
+                # Required for esky builds
163 178
                 'install_requires': requirements,
164 179
                 # The dynamic module loading in salt.modules makes this
165  
-                # package zip unsafe.
  180
+                # package zip unsafe. Required for esky builds
166 181
                 'zip_safe': False
167 182
                 }
168 183
 
@@ -193,19 +208,16 @@ def run(self):
193 208
         '_winreg',
194 209
         'wmi',
195 210
     ])
196  
-    setup_kwargs['install_requires'] += '\nwmi'
  211
+    setup_kwargs['install_requires'].append('wmi')
197 212
 elif sys.platform.startswith('linux'):
198 213
     freezer_includes.extend([
199 214
         'yum',
200 215
         'spwd',
201 216
     ])
202 217
 
203  
-if 'bdist_esky' in sys.argv:
204  
-    # Add the esky bdist target if the module is available
205  
-    # may require additional modules depending on platform
206  
-    from esky import bdist_esky
207  
-    # bbfreeze chosen for its tight integration with distutils
208  
-    import bbfreeze
  218
+if HAS_ESKY:
  219
+    # if the user has the esky / bbfreeze libraries installed, add the
  220
+    # appropriate kwargs to setup
209 221
     options = setup_kwargs.get('options', {})
210 222
     options['bdist_esky'] = {
211 223
         "freezer_module": "bbfreeze",
@@ -236,10 +248,6 @@ def run(self):
236 248
                                'scripts/salt-call',
237 249
                                'scripts/salt-run',
238 250
                                'scripts/salt']
239  
-    # Distutils does not know what these are and throws warnings.
240  
-    # Stop the warning.
241  
-    setup_kwargs.pop('install_requires')
242  
-    setup_kwargs.pop('zip_safe')
243 251
 
244 252
 if __name__ == '__main__':
245 253
     setup(**setup_kwargs)

0 notes on commit b50cd76

Please sign in to comment.
Something went wrong with that request. Please try again.