99from email .parser import FeedParser
1010
1111
12+ from .compat import lambda_abi
1213from .compat import pip_import_string
1314from .compat import pip_no_compile_c_env_vars
1415from .compat import pip_no_compile_c_shim
@@ -58,36 +59,10 @@ class PackageDownloadError(PackagerError):
5859 pass
5960
6061
61- class UnsupportedPythonVersion (PackagerError ):
62- """Generic networking error during a package download."""
63- def __init__ (self , version ):
64- super (UnsupportedPythonVersion , self ).__init__ (
65- "'%s' version of python is not supported" % version
66- )
67-
68-
69- def get_lambda_abi (runtime ):
70- supported = {
71- "python2.7" : "cp27mu" ,
72- "python3.6" : "cp36m" ,
73- "python3.7" : "cp37m"
74- }
75-
76- if runtime not in supported :
77- raise UnsupportedPythonVersion (runtime )
78-
79- return supported [runtime ]
80-
81-
8262class PythonPipDependencyBuilder (object ):
83- def __init__ (self , runtime , osutils = None , dependency_builder = None ):
63+ def __init__ (self , osutils = None , dependency_builder = None ):
8464 """Initialize a PythonPipDependencyBuilder.
8565
86- :type runtime: str
87- :param runtime: Python version to build dependencies for. This can
88- either be python2.7, python3.6 or python3.7. These are currently the
89- only supported values.
90-
9166 :type osutils: :class:`lambda_builders.utils.OSUtils`
9267 :param osutils: A class used for all interactions with the
9368 outside OS.
@@ -101,11 +76,11 @@ def __init__(self, runtime, osutils=None, dependency_builder=None):
10176 self .osutils = OSUtils ()
10277
10378 if dependency_builder is None :
104- dependency_builder = DependencyBuilder (self .osutils , runtime )
79+ dependency_builder = DependencyBuilder (self .osutils )
10580 self ._dependency_builder = dependency_builder
10681
10782 def build_dependencies (self , artifacts_dir_path , scratch_dir_path ,
108- requirements_path , ui = None , config = None ):
83+ requirements_path , runtime , ui = None , config = None ):
10984 """Builds a python project's dependencies into an artifact directory.
11085
11186 :type artifacts_dir_path: str
@@ -118,6 +93,11 @@ def build_dependencies(self, artifacts_dir_path, scratch_dir_path,
11893 :param requirements_path: Path to a requirements.txt file to inspect
11994 for a list of dependencies.
12095
96+ :type runtime: str
97+ :param runtime: Python version to build dependencies for. This can
98+ either be python2.7 or python3.6. These are currently the only
99+ supported values.
100+
121101 :type ui: :class:`lambda_builders.utils.UI` or None
122102 :param ui: A class that traps all progress information such as status
123103 and errors. If injected by the caller, it can be used to monitor
@@ -161,16 +141,13 @@ class DependencyBuilder(object):
161141 'sqlalchemy'
162142 }
163143
164- def __init__ (self , osutils , runtime , pip_runner = None ):
144+ def __init__ (self , osutils , pip_runner = None ):
165145 """Initialize a DependencyBuilder.
166146
167147 :type osutils: :class:`lambda_builders.utils.OSUtils`
168148 :param osutils: A class used for all interactions with the
169149 outside OS.
170150
171- :type runtime: str
172- :param runtime: AWS Lambda Python runtime to build for
173-
174151 :type pip_runner: :class:`PipRunner`
175152 :param pip_runner: This class is responsible for executing our pip
176153 on our behalf.
@@ -179,7 +156,6 @@ def __init__(self, osutils, runtime, pip_runner=None):
179156 if pip_runner is None :
180157 pip_runner = PipRunner (SubprocessPip (osutils ))
181158 self ._pip = pip_runner
182- self .runtime = runtime
183159
184160 def build_site_packages (self , requirements_filepath ,
185161 target_directory ,
@@ -336,9 +312,8 @@ def _download_all_dependencies(self, requirements_filename, directory):
336312 def _download_binary_wheels (self , packages , directory ):
337313 # Try to get binary wheels for each package that isn't compatible.
338314 LOG .debug ("Downloading missing wheels: %s" , packages )
339- lambda_abi = get_lambda_abi (self .runtime )
340315 self ._pip .download_manylinux_wheels (
341- [pkg .identifier for pkg in packages ], directory , lambda_abi )
316+ [pkg .identifier for pkg in packages ], directory )
342317
343318 def _build_sdists (self , sdists , directory , compile_c = True ):
344319 LOG .debug ("Build missing wheels from sdists "
@@ -366,9 +341,6 @@ def _is_compatible_wheel_filename(self, filename):
366341 # Verify platform is compatible
367342 if platform not in self ._MANYLINUX_COMPATIBLE_PLATFORM :
368343 return False
369-
370- lambda_runtime_abi = get_lambda_abi (self .runtime )
371-
372344 # Verify that the ABI is compatible with lambda. Either none or the
373345 # correct type for the python version cp27mu for py27 and cp36m for
374346 # py36.
@@ -379,7 +351,7 @@ def _is_compatible_wheel_filename(self, filename):
379351 # Deploying python 3 function which means we need cp36m abi
380352 # We can also accept abi3 which is the CPython 3 Stable ABI and
381353 # will work on any version of python 3.
382- return abi == lambda_runtime_abi or abi == 'abi3'
354+ return abi == 'cp36m' or abi == 'abi3'
383355 elif prefix_version == 'cp2' :
384356 # Deploying to python 2 function which means we need cp27mu abi
385357 return abi == 'cp27mu'
@@ -643,7 +615,7 @@ def download_all_dependencies(self, requirements_filename, directory):
643615 # complain at deployment time.
644616 self .build_wheel (wheel_package_path , directory )
645617
646- def download_manylinux_wheels (self , packages , directory , lambda_abi ):
618+ def download_manylinux_wheels (self , packages , directory ):
647619 """Download wheel files for manylinux for all the given packages."""
648620 # If any one of these dependencies fails pip will bail out. Since we
649621 # are only interested in all the ones we can download, we need to feed
0 commit comments