Best Python code snippet using slash
setuptools_build.py
Source:setuptools_build.py
1import sys2from typing import List, Optional, Sequence3# Shim to wrap setup.py invocation with setuptools4#5# We set sys.argv[0] to the path to the underlying setup.py file so6# setuptools / distutils don't take the path to the setup.py to be "-c" when7# invoking via the shim. This avoids e.g. the following manifest_maker8# warning: "warning: manifest_maker: standard file '-c' not found".9_SETUPTOOLS_SHIM = (10 "import io, os, sys, setuptools, tokenize; sys.argv[0] = {0!r}; __file__={0!r};"11 "f = getattr(tokenize, 'open', open)(__file__) "12 "if os.path.exists(__file__) "13 "else io.StringIO('from setuptools import setup; setup()');"14 "code = f.read().replace('\\r\\n', '\\n');"15 "f.close();"16 "exec(compile(code, __file__, 'exec'))"17)18def make_setuptools_shim_args(19 setup_py_path, # type: str20 global_options=None, # type: Sequence[str]21 no_user_config=False, # type: bool22 unbuffered_output=False, # type: bool23):24 # type: (...) -> List[str]25 """26 Get setuptools command arguments with shim wrapped setup file invocation.27 :param setup_py_path: The path to setup.py to be wrapped.28 :param global_options: Additional global options.29 :param no_user_config: If True, disables personal user configuration.30 :param unbuffered_output: If True, adds the unbuffered switch to the31 argument list.32 """33 args = [sys.executable]34 if unbuffered_output:35 args += ["-u"]36 args += ["-c", _SETUPTOOLS_SHIM.format(setup_py_path)]37 if global_options:38 args += global_options39 if no_user_config:40 args += ["--no-user-cfg"]41 return args42def make_setuptools_bdist_wheel_args(43 setup_py_path, # type: str44 global_options, # type: Sequence[str]45 build_options, # type: Sequence[str]46 destination_dir, # type: str47):48 # type: (...) -> List[str]49 # NOTE: Eventually, we'd want to also -S to the flags here, when we're50 # isolating. Currently, it breaks Python in virtualenvs, because it51 # relies on site.py to find parts of the standard library outside the52 # virtualenv.53 args = make_setuptools_shim_args(54 setup_py_path, global_options=global_options, unbuffered_output=True55 )56 args += ["bdist_wheel", "-d", destination_dir]57 args += build_options58 return args59def make_setuptools_clean_args(60 setup_py_path, # type: str61 global_options, # type: Sequence[str]62):63 # type: (...) -> List[str]64 args = make_setuptools_shim_args(65 setup_py_path, global_options=global_options, unbuffered_output=True66 )67 args += ["clean", "--all"]68 return args69def make_setuptools_develop_args(70 setup_py_path, # type: str71 global_options, # type: Sequence[str]72 install_options, # type: Sequence[str]73 no_user_config, # type: bool74 prefix, # type: Optional[str]75 home, # type: Optional[str]76 use_user_site, # type: bool77):78 # type: (...) -> List[str]79 assert not (use_user_site and prefix)80 args = make_setuptools_shim_args(81 setup_py_path,82 global_options=global_options,83 no_user_config=no_user_config,84 )85 args += ["develop", "--no-deps"]86 args += install_options87 if prefix:88 args += ["--prefix", prefix]89 if home is not None:90 args += ["--install-dir", home]91 if use_user_site:92 args += ["--user", "--prefix="]93 return args94def make_setuptools_egg_info_args(95 setup_py_path, # type: str96 egg_info_dir, # type: Optional[str]97 no_user_config, # type: bool98):99 # type: (...) -> List[str]100 args = make_setuptools_shim_args(setup_py_path, no_user_config=no_user_config)101 args += ["egg_info"]102 if egg_info_dir:103 args += ["--egg-base", egg_info_dir]104 return args105def make_setuptools_install_args(106 setup_py_path, # type: str107 global_options, # type: Sequence[str]108 install_options, # type: Sequence[str]109 record_filename, # type: str110 root, # type: Optional[str]111 prefix, # type: Optional[str]112 header_dir, # type: Optional[str]113 home, # type: Optional[str]114 use_user_site, # type: bool115 no_user_config, # type: bool116 pycompile, # type: bool117):118 # type: (...) -> List[str]119 assert not (use_user_site and prefix)120 assert not (use_user_site and root)121 args = make_setuptools_shim_args(122 setup_py_path,123 global_options=global_options,124 no_user_config=no_user_config,125 unbuffered_output=True,126 )127 args += ["install", "--record", record_filename]128 args += ["--single-version-externally-managed"]129 if root is not None:130 args += ["--root", root]131 if prefix is not None:132 args += ["--prefix", prefix]133 if home is not None:134 args += ["--home", home]135 if use_user_site:136 args += ["--user", "--prefix="]137 if pycompile:138 args += ["--compile"]139 else:140 args += ["--no-compile"]141 if header_dir:142 args += ["--install-headers", header_dir]143 args += install_options...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!