How to use require_gcc method in autotest

Best Python code snippet using autotest_python

pyenv-install.py

Source:pyenv-install.py Github

copy

Full Screen

1# coding: utf-82from __future__ import unicode_literals, division, absolute_import, print_function3import os4import subprocess5import sys6run_args = [7 {8 'name': 'version',9 'kwarg': 'version',10 },11]12def _write_env(env, key, value):13 sys.stdout.write("%s: %s\n" % (key, value))14 sys.stdout.flush()15 if sys.version_info < (3,):16 env[key.encode('utf-8')] = value.encode('utf-8')17 else:18 env[key] = value19def run(version=None):20 """21 Installs a version of Python on Mac using pyenv22 :return:23 A bool - if Python was installed successfully24 """25 if sys.platform == 'win32':26 raise ValueError('pyenv-install is not designed for Windows')27 if version not in set(['2.6', '3.3']):28 raise ValueError('Invalid version: %r' % version)29 python_path = os.path.expanduser('~/.pyenv/versions/%s/bin' % version)30 if os.path.exists(os.path.join(python_path, 'python')):31 print(python_path)32 return True33 stdout = ""34 stderr = ""35 proc = subprocess.Popen(36 'command -v pyenv',37 shell=True,38 stdout=subprocess.PIPE,39 stderr=subprocess.PIPE40 )41 proc.communicate()42 if proc.returncode != 0:43 proc = subprocess.Popen(44 ['brew', 'install', 'pyenv'],45 stdout=subprocess.PIPE,46 stderr=subprocess.PIPE47 )48 so, se = proc.communicate()49 stdout += so.decode('utf-8')50 stderr += se.decode('utf-8')51 if proc.returncode != 0:52 print(stdout)53 print(stderr, file=sys.stderr)54 return False55 pyenv_script = './%s' % version56 try:57 with open(pyenv_script, 'wb') as f:58 if version == '2.6':59 contents = '#require_gcc\n' \60 'install_package "openssl-1.0.2k" "https://www.openssl.org/source/old/1.0.2/openssl-1.0.2k.tar.gz' \61 '#6b3977c61f2aedf0f96367dcfb5c6e578cf37e7b8d913b4ecb6643c3cb88d8c0" mac_openssl\n' \62 'install_package "readline-8.0" "https://ftpmirror.gnu.org/readline/readline-8.0.tar.gz' \63 '#e339f51971478d369f8a053a330a190781acb9864cf4c541060f12078948e461" mac_readline' \64 ' --if has_broken_mac_readline\n' \65 'install_package "Python-2.6.9" "https://www.python.org/ftp/python/2.6.9/Python-2.6.9.tgz' \66 '#7277b1285d8a82f374ef6ebaac85b003266f7939b3f2a24a3af52f9523ac94db" standard verify_py26'67 elif version == '3.3':68 contents = '#require_gcc\n' \69 'install_package "openssl-1.0.2k" "https://www.openssl.org/source/old/1.0.2/openssl-1.0.2k.tar.gz' \70 '#6b3977c61f2aedf0f96367dcfb5c6e578cf37e7b8d913b4ecb6643c3cb88d8c0" mac_openssl\n' \71 'install_package "readline-8.0" "https://ftpmirror.gnu.org/readline/readline-8.0.tar.gz' \72 '#e339f51971478d369f8a053a330a190781acb9864cf4c541060f12078948e461" mac_readline' \73 ' --if has_broken_mac_readline\n' \74 'install_package "Python-3.3.7" "https://www.python.org/ftp/python/3.3.7/Python-3.3.7.tar.xz' \75 '#85f60c327501c36bc18c33370c14d472801e6af2f901dafbba056f61685429fe" standard verify_py33'76 f.write(contents.encode('utf-8'))77 args = ['pyenv', 'install', pyenv_script]78 stdin = None79 stdin_contents = None80 env = os.environ.copy()81 if version == '2.6':82 _write_env(env, 'PYTHON_CONFIGURE_OPTS', '--enable-ipv6')83 stdin = subprocess.PIPE84 stdin_contents = '--- configure 2021-08-05 20:17:26.000000000 -0400\n' \85 '+++ configure 2021-08-05 20:21:30.000000000 -0400\n' \86 '@@ -10300,17 +10300,8 @@\n' \87 ' rm -f core conftest.err conftest.$ac_objext \\\n' \88 ' conftest$ac_exeext conftest.$ac_ext\n' \89 ' \n' \90 '-if test "$buggygetaddrinfo" = "yes"; then\n' \91 '-\tif test "$ipv6" = "yes"; then\n' \92 '-\t\techo \'Fatal: You must get working getaddrinfo() function.\'\n' \93 '-\t\techo \' or you can specify "--disable-ipv6"\'.\n' \94 '-\t\texit 1\n' \95 '-\tfi\n' \96 '-else\n' \97 '-\n' \98 ' $as_echo "#define HAVE_GETADDRINFO 1" >>confdefs.h\n' \99 ' \n' \100 '-fi\n' \101 ' for ac_func in getnameinfo\n' \102 ' do :\n' \103 ' ac_fn_c_check_func "$LINENO" "getnameinfo" "ac_cv_func_getnameinfo"'104 stdin_contents = stdin_contents.encode('ascii')105 args.append('--patch')106 proc = subprocess.Popen(107 args,108 stdout=subprocess.PIPE,109 stderr=subprocess.PIPE,110 stdin=stdin,111 env=env112 )113 so, se = proc.communicate(stdin_contents)114 stdout += so.decode('utf-8')115 stderr += se.decode('utf-8')116 if proc.returncode != 0:117 print(stdout)118 print(stderr, file=sys.stderr)119 return False120 finally:121 if os.path.exists(pyenv_script):122 os.unlink(pyenv_script)123 print(python_path)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful