33import json
44import logging
55import os
6- import sys
76import time
87from imp import load_source
98from shutil import copy , copyfile
@@ -111,12 +110,6 @@ def invoke(src, alt_event=None, verbose=False):
111110 path_to_event_file = os .path .join (src , 'event.json' )
112111 event = read (path_to_event_file , loader = json .loads )
113112
114- #Tweak to allow module to import local modules
115- try :
116- sys .path .index (src )
117- except :
118- sys .path .append (src )
119-
120113 handler = cfg .get ('handler' )
121114 # Inspect the handler string (<module>.<function name>) and translate it
122115 # into a function we can execute.
@@ -149,10 +142,8 @@ def init(src, minimal=False):
149142 for filename in os .listdir (templates_path ):
150143 if (minimal and filename == 'event.json' ) or filename .endswith ('.pyc' ):
151144 continue
152- dest_path = os .path .join (templates_path , filename )
153-
154- if not os .path .isdir (dest_path ):
155- copy (dest_path , src )
145+ destination = os .path .join (templates_path , filename )
146+ copy (destination , src )
156147
157148
158149def build (src , requirements = False , local_package = None ):
@@ -185,13 +176,6 @@ def build(src, requirements=False, local_package=None):
185176 requirements = requirements ,
186177 local_package = local_package )
187178
188- # Hack for Zope.
189- if "zope" in os .listdir (path_to_temp ):
190- print ("Zope packages detected; fixing Zope package paths to make them importable." )
191- # Touch.
192- with open (os .path .join (path_to_temp , "zope/__init__.py" ), "wb" ):
193- pass
194-
195179 # Gracefully handle whether ".zip" was included in the filename or not.
196180 output_filename = ('{0}.zip' .format (output_filename )
197181 if not output_filename .endswith ('.zip' )
@@ -204,7 +188,6 @@ def build(src, requirements=False, local_package=None):
204188 continue
205189 if filename == 'config.yaml' :
206190 continue
207- print ("Bundling: %r" % filename )
208191 files .append (os .path .join (src , filename ))
209192
210193 # "cd" into `temp_path` directory.
@@ -272,7 +255,7 @@ def _filter_blacklist(package):
272255 package = package .replace ('-e ' , '' )
273256
274257 print ('Installing {package}' .format (package = package ))
275- pip .main (['install' , package , '-t' , path , '--ignore-installed' ])
258+ pip .main (['install' , package , '-t' , path ])
276259
277260
278261def pip_install_to_target (path , requirements = False , local_package = None ):
@@ -300,15 +283,17 @@ def pip_install_to_target(path, requirements=False, local_package=None):
300283 print ('Gathering requirement packages' )
301284 data = read ("requirements.txt" )
302285 packages .extend (data .splitlines ())
286+ elif os .path .exists (requirements ):
287+ print ('Gathering requirement from %s' % requirements )
288+ data = read (requirements )
289+ packages .extend (data .splitlines ())
303290
304291 if not packages :
305292 print ('No dependency packages installed!' )
306293
307294 if local_package is not None :
308- if not isinstance (local_package , (list , tuple ) ):
309- local_package = [local_package ]
310- for l_package in local_package :
311- packages .append (l_package )
295+ # TODO: actually sdist is probably bettter here...
296+ packages .append (local_package )
312297 _install_packages (path , packages )
313298
314299
0 commit comments