How to use get_envpython method in tox

Best Python code snippet using tox_python

plugin.py

Source:plugin.py Github

copy

Full Screen

...209 path = envconfig.envdir.join("bin", "python")210 if path.exists():211 return path212# Monkey patch TestenConfig get_envpython to fix tox behavior with tox-conda under windows213def get_envpython(self):214 """Override get_envpython to handle windows where the interpreter in at the env root dir."""215 original_envpython = self.__get_envpython()216 if original_envpython.exists():217 return original_envpython218 if tox.INFO.IS_WIN:219 return self.envdir.join("python")220TestenvConfig.__get_envpython = TestenvConfig.get_envpython221TestenvConfig.get_envpython = get_envpython222# Monkey patch TestenvConfig _venv_lookup to fix tox behavior with tox-conda under windows223def venv_lookup(self, name):224 """Override venv_lookup to also look at the env root dir under windows."""225 paths = [self.envconfig.envbindir]226 # In Conda environments on Windows, the Python executable is installed in227 # the top-level environment directory, as opposed to virtualenvs, where it228 # is installed in the Scripts directory. Tox assumes that looking in the229 # Scripts directory is sufficient, which is why this workaround is required....

Full Screen

Full Screen

hooks.py

Source:hooks.py Github

copy

Full Screen

...89 return config90class InterpreterMismatch(tox.exception.InterpreterNotFound):91 """Interpreter version in current env does not match requested version"""92def _python_activate_exists(venv):93 python = venv.envconfig.get_envpython()94 bindir = os.path.dirname(python)95 activate = os.path.join(bindir, "activate")96 return os.path.exists(python), os.path.exists(activate)97def is_current_env_link(venv):98 python, activate = _python_activate_exists(venv)99 return python and not activate100def is_proper_venv(venv):101 python, activate = _python_activate_exists(venv)102 return python and activate103def is_any_env(venv):104 python, activate = _python_activate_exists(venv)105 return python106def rm_venv(venv):107 link = venv.envconfig.get_envpython()108 shutil.rmtree(os.path.dirname(os.path.dirname(link)), ignore_errors=True)109def unsupported_raise(config, venv):110 if config.option.recreate:111 return112 if not _plugin_active(config.option) and is_current_env_link(venv):113 if hasattr(tox.hookspecs, "tox_cleanup"):114 raise tox.exception.ConfigError(115 "Looks like previous --current-env, --print-deps-to or --print-extras-to tox run didn't finish the cleanup. "116 "Run tox run with --recreate (-r) or manually remove the environment in .tox."117 )118 else:119 raise tox.exception.ConfigError(120 "Regular tox run after --current-env, --print-deps-to or --print-extras-to tox run "121 "is not supported without --recreate (-r)."122 )123 elif config.option.current_env and is_proper_venv(venv):124 raise tox.exception.ConfigError(125 "--current-env after regular tox run is not supported without --recreate (-r)."126 )127@tox.hookimpl128def tox_testenv_create(venv, action):129 """We create a fake virtualenv with just the symbolic link"""130 config = venv.envconfig.config131 create_fake_env = check_version = config.option.current_env132 if config.option.print_deps_to or config.option.print_extras_to:133 if is_any_env(venv):134 # We don't need anything135 return True136 else:137 # We need at least some kind of environment,138 # or tox fails without a python command139 # We fallback to --current-env behavior,140 # because it's cheaper, faster and won't install stuff141 create_fake_env = True142 if check_version:143 # With real --current-env, we check this, but not with --print-deps/extras-to only144 version_info = venv.envconfig.python_info.version_info145 if version_info is None:146 raise tox.exception.InterpreterNotFound(venv.envconfig.basepython)147 if version_info[:2] != sys.version_info[:2]:148 raise InterpreterMismatch(149 f"tox_current_env: interpreter versions do not match:\n"150 + f" in current env: {tuple(sys.version_info)}\n"151 + f" requested: {version_info}"152 )153 if create_fake_env:154 # Make sure the `python` command on path is sys.executable.155 # (We might have e.g. /usr/bin/python3, not `python`.)156 # Remove the rest of the virtualenv.157 link = venv.envconfig.get_envpython()158 target = sys.executable159 rm_venv(venv)160 os.makedirs(os.path.dirname(link))161 if sys.platform == "win32":162 # Avoid requiring admin rights on Windows163 subprocess.check_call(f'mklink /J "{link}" "{target}"', shell=True)164 else:165 os.symlink(target, link)166 # prevent tox from creating the venv167 return True168 if not is_proper_venv(venv):169 rm_venv(venv)170 return None # let tox handle the rest171@tox.hookimpl...

Full Screen

Full Screen

build.py

Source:build.py Github

copy

Full Screen

...31 if buildos == 'mac':32 return os.path.join(envdir,'bin','pip') 33 else:34 return os.path.join(envdir,'Scripts','pip.exe')35def get_envpython(buildos):36 if buildos == 'mac':37 return os.path.join(envdir,'bin','python')38 else:39 return os.path.join(envdir,'Scripts','python.exe')40def get_lineup_optimizer_py(buildos):41 if buildos == 'mac':42 return os.path.join(envdir,'lib','python2.7','site-packages','pydfs_lineup_optimizer','lineup_optimizer.py')43 else:44 return os.path.join(envdir,'lib','site-packages','pydfs_lineup_optimizer','lineup_optimizer.py')45def setup_pyenv(buildos):46 subprocess.check_call('virtualenv -p {} {}'.format(localpython, envdir).split())47 if buildos == 'mac':48 subprocess.check_call('{} install Cython==0.26.1'.format(envpip).split())49 subprocess.check_call('{} install pyobjc==4.1'.format(envpip).split())50 else:51 subprocess.check_call('{} install --upgrade pip wheel setuptools'.format(envpip).split())52 subprocess.check_call('{} install docutils==0.14'.format(envpip).split())53 subprocess.check_call('{} install Pygments==2.2.0'.format(envpip).split())54 subprocess.check_call('{} install pypiwin32==219'.format(envpip).split())55 subprocess.check_call('{} install kivy.deps.sdl2==0.1.17'.format(envpip).split())56 subprocess.check_call('{} install kivy.deps.glew==0.1.9'.format(envpip).split())57 subprocess.check_call('{} install kivy.deps.gstreamer==0.1.12'.format(envpip).split())58 subprocess.check_call('{} install kivy==1.10.0'.format(envpip).split())59 subprocess.check_call('{} install pyinstaller==3.3.1'.format(envpip).split())60 subprocess.check_call('{} install pydfs-lineup-optimizer==1.1.2'.format(envpip).split())61localpython = get_localpython(buildos)62srcpath = os.path.join(abspath, 'src') #cwd/src63lineupmainpy = os.path.join(srcpath ,'lineupmain.py')64builddir = get_builddir(buildos) #cwd/[mac/win]build65envdir = os.path.join(builddir, 'virtualenv-pydfs') #cwd/[mac/win]build/virtualenv-pydfs66envpip = get_envpip(buildos)67envpython = get_envpython(buildos)68pkgdir = os.path.join(builddir, 'package') #cwd/[mac/win]build/package69appname = 'lineupOptGuiPkg'70specfile = os.path.join(pkgdir,'{}.spec'.format(appname))71lineup_optimizer_py = get_lineup_optimizer_py(buildos)72def get_build_cmd(buildos):73 if buildos == 'mac':74 return '{} -m PyInstaller -y --clean --windowed --name {} --exclude-module _tkinter --exclude-module Tkinter --exclude-module enchant --exclude-module twisted {}'.format(envpython, appname, lineupmainpy)75 else:76 return '{} -m PyInstaller --name {} {}'.format(envpython, appname, lineupmainpy)77def fix_spec_file(buildos):78 if buildos == 'mac':79 collect_line = 'COLLECT(exe,Tree(\'{}\'),'.format(srcpath)80 else:81 # Insert import for windows...

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 tox 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