From 35f5d211346dc8a2eef21f20034e7dce30403660 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Tue, 25 Aug 2020 09:01:46 +0300 Subject: [PATCH 1/2] fix: OSX python from XCode command line tools --- package.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/package.py b/package.py index 0e6f603f..5f5ca1a1 100644 --- a/package.py +++ b/package.py @@ -850,8 +850,18 @@ def install_pip_requirements(query, requirements_file): shutil.copyfile(requirements_file, target_file) python_exec = runtime - if WINDOWS and not docker: - python_exec = 'python.exe' + subproc_env = None + + if not docker: + if WINDOWS: + python_exec = 'python.exe' + elif OSX: + # Workaround for OSX when XCode command line tools' + # python becomes the main system python interpreter + os_path = '{}:/Library/Developer/CommandLineTools' \ + '/usr/bin'.format(os.environ['PATH']) + subproc_env = os.environ.copy() + subproc_env['PATH'] = os_path # Install dependencies into the temporary directory. with cd(temp_dir): @@ -886,7 +896,7 @@ def install_pip_requirements(query, requirements_file): else: cmd_log.info(shlex_join(pip_command)) log_handler and log_handler.flush() - check_call(pip_command) + check_call(pip_command, env=subproc_env) os.remove(target_file) yield temp_dir From 1c4dd8ef01b0705ca93cf15707a0f91a1ae63a7d Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Tue, 25 Aug 2020 09:11:08 +0300 Subject: [PATCH 2/2] Added exception to explain python interpreter version requirements --- package.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/package.py b/package.py index 5f5ca1a1..2e19db7e 100644 --- a/package.py +++ b/package.py @@ -896,7 +896,14 @@ def install_pip_requirements(query, requirements_file): else: cmd_log.info(shlex_join(pip_command)) log_handler and log_handler.flush() - check_call(pip_command, env=subproc_env) + try: + check_call(pip_command, env=subproc_env) + except FileNotFoundError as e: + raise RuntimeError( + "Python interpreter version equal " + "to defined lambda runtime ({}) should be " + "available in system PATH".format(runtime) + ) from e os.remove(target_file) yield temp_dir