How to use walk_plugins_setup_py method in avocado

Best Python code snippet using avocado_python

setup.py

Source:setup.py Github

copy

Full Screen

...29def get_long_description():30 with open(os.path.join(BASE_PATH, "README.rst"), "rt", encoding="utf-8") as readme:31 readme_contents = readme.read()32 return readme_contents33def walk_plugins_setup_py(34 action, action_name=None, directory=os.path.join(BASE_PATH, "optional_plugins")35):36 if action_name is None:37 action_name = action[0].upper()38 for plugin in list(Path(directory).glob("*/setup.py")):39 parent_dir = plugin.parent40 print(f">> {action_name} {parent_dir}")41 run([sys.executable, "setup.py"] + action, cwd=parent_dir, check=True)42class Clean(clean):43 """Our custom command to get rid of junk files after build."""44 description = "Get rid of scratch, byte files and build stuff."45 def run(self):46 super().run()47 cleaning_list = [48 "PYPI_UPLOAD",49 "./build",50 "./dist",51 "./man/avocado.1",52 "./docs/build",53 ]54 cleaning_list += list(Path("/tmp/").glob(".avocado-*"))55 cleaning_list += list(Path("/var/tmp/").glob(".avocado-*"))56 cleaning_list += list(Path(".").rglob("*.egg-info"))57 cleaning_list += list(Path(".").rglob("*.pyc"))58 cleaning_list += list(Path(".").rglob("__pycache__"))59 cleaning_list += list(Path("./docs/source/api/").rglob("*.rst"))60 for e in cleaning_list:61 if not os.path.exists(e):62 continue63 if os.path.isfile(e):64 os.remove(e)65 if os.path.isdir(e):66 shutil.rmtree(e)67 self.clean_optional_plugins()68 @staticmethod69 def clean_optional_plugins():70 walk_plugins_setup_py(["clean", "--all"])71class Develop(setuptools.command.develop.develop):72 """Custom develop command."""73 user_options = setuptools.command.develop.develop.user_options + [74 ("external", None, "Install external plugins in development mode"),75 (76 "skip-optional-plugins",77 None,78 "Do not include in-tree optional plugins in development mode",79 ),80 ]81 boolean_options = setuptools.command.develop.develop.boolean_options + [82 "external",83 "skip-optional-plugins",84 ]85 def _walk_develop_plugins(self):86 if not self.skip_optional_plugins:87 walk_plugins_setup_py(88 action=["develop"] + self.action_options, action_name=self.action_name89 )90 @property91 def action_options(self):92 result = []93 if self.uninstall:94 result.append("--uninstall")95 if self.user:96 result.append("--user")97 return result98 @property99 def action_name(self):100 if self.uninstall:101 return "DEVELOP UNLINK"102 else:103 return "DEVELOP LINK"104 @property105 def external_plugins_path(self):106 try:107 d = os.getenv("AVOCADO_EXTERNAL_PLUGINS_PATH")108 if not os.path.exists(d):109 return None110 return os.path.abspath(d)111 except TypeError:112 return None113 def initialize_options(self):114 super().initialize_options()115 self.external = 0 # pylint: disable=W0201116 self.skip_optional_plugins = 0 # pylint: disable=W0201117 def handle_uninstall(self):118 """When uninstalling, we remove the plugins before Avocado."""119 self._walk_develop_plugins()120 super().run()121 def handle_install(self):122 """When installing, we install plugins after installing Avocado."""123 super().run()124 self._walk_develop_plugins()125 def handle_external(self):126 """Handles only external plugins.127 The current logic means that --external will not install Avocado.128 """129 d = self.external_plugins_path130 if d is None:131 msg = "The variable AVOCADO_EXTERNAL_PLUGINS_PATH isn't properly set"132 sys.exit(msg)133 walk_plugins_setup_py(134 action=["develop"] + self.action_options,135 action_name=self.action_name,136 directory=d,137 )138 def run(self):139 if self.external:140 self.handle_external()141 else:142 if not self.uninstall:143 self.handle_install()144 elif self.uninstall:145 self.handle_uninstall()146class SimpleCommand(Command):147 """Make Command implementation simpler."""...

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