How to use get_build_requires method in tox

Best Python code snippet using tox_python

nodejsporter

Source:nodejsporter Github

copy

Full Screen

...123 For empty description, use summary instead.124 """125 desc = self.__json["description"].splitlines()126 return self.__json["description"]127 def get_build_requires(self):128 req_list = []129 rds = []130 for v in self.__json:131 if v == "dependencies":132 rds = self.__json["dependencies"]133 if rds is not None:134 for rp in rds:135 br = refine_requires(rp)136 if (br == ""):137 continue138 name = str.lstrip(br).split(" ")139 req_list.append(name[0])140 return req_list141 def store_json(self, spath):142 """143 save json file144 """145 fname = json_file_template.format(pkg_name=self.__pkg_name)146 json_file = os.path.join(spath, fname)147 # if file exist, do nothing148 if path.exists(json_file) and path.isfile(json_file):149 with open(json_file, 'r') as f:150 resp = json.load(f)151 else:152 with open(json_file, 'w') as f:153 json.dump(self.__json, f)154def transform_module_name(n):155 """156 return module name with version restriction.157 Any string with '.' or '/' is considered file, and will be ignored158 Modules start will be changed to nodejs- for consistency.159 """160 # remove ()161 ns = re.split("[()]", n)162 ver_constrain = []163 ns[0] = ns[0].strip()164 # ns[0] = "nodejs-" + ns[0]165 if ns[0].find("/") != -1 or ns[0].find(".") != -1:166 return ""167 return ns[0]168def refine_requires(req):169 """170 return only requires without ';' (thus no extra)171 """172 ra = req.split(";", 1)173 return transform_module_name(ra[0])174def download_source(porter, tgtpath):175 """176 download source file from url, and save it to target path177 """178 if os.path.exists(tgtpath) == False:179 print("download path %s does not exist\n", tgtpath)180 return False181 s_url = porter.get_source_url()182 return subprocess.call(["wget", s_url, "-P", tgtpath])183def prepare_rpm_build_env(root):184 """185 prepare environment for rpmbuild186 """187 if os.path.exists(root) is False:188 print("Root path %s does not exist\n" & buildroot)189 return ""190 buildroot = os.path.join(root, "rpmbuild")191 if (os.path.exists(buildroot) == False):192 os.mkdir(buildroot)193 for sdir in ['SPECS', 'BUILD', 'SOURCES', 'SRPMS', 'RPMS', 'BUILDROOT']:194 bpath = os.path.join(buildroot, sdir)195 if os.path.exists(bpath) is False:196 os.mkdir(bpath)197 return buildroot198def try_pip_install_package(pkg):199 """200 install packages listed in build requires201 """202 # try pip installation203 pip_name = pkg.split("-")204 if len(pip_name) == 2:205 ret = subprocess.call(["pip3", "install", "--user", pip_name[1]])206 else:207 ret = subprocess.call(["pip3", "install", "--user", pip_name[0]])208 if ret != 0:209 print("%s can not be installed correctly, Fix it later, go ahead to do building..." % pip_name)210 return True211def package_installed(pkg):212 print(pkg)213 ret = subprocess.call(["rpm", "-qi", pkg])214 if ret == 0:215 return True216 return False217def dependencies_ready(req_list):218 """219 TODO: do not need to do dependency check here, do it in pyporter_run220 """221 return ""222def build_package(specfile):223 """224 build rpm package with rpmbuild225 """226 ret = subprocess.call(["rpmbuild", "-ba", specfile])227 return ret228def build_install_rpm(porter, rootpath):229 ret = build_rpm(porter, rootpath)230 if (ret != ""):231 return ret232 arch = "noarch"233 if (porter.is_build_noarch()):234 arch = "noarch"235 else:236 arch = platform.machine()237 pkgname = os.path.join(rootpath, "rpmbuild", "RPMS", arch, porter.get_pkg_name() + "*")238 ret = subprocess.call(["rpm", "-ivh", pkgname])239 if ret != 0:240 return "Install failed\n"241 return ""242def build_rpm(porter, rootpath):243 """244 full process to build rpm245 """246 buildroot = prepare_rpm_build_env(rootpath)247 if buildroot == "":248 return False249 specfile = os.path.join(buildroot, "SPECS", porter.get_spec_name() + ".spec")250 req_list = build_spec(porter, specfile)251 ret = dependencies_ready(req_list)252 if ret != "":253 print("%s can not be installed automatically, Please handle it" % ret)254 return ret255 download_source(porter, os.path.join(buildroot, "SOURCES"))256 build_package(specfile)257 return ""258def build_spec(porter, output):259 """260 print out the spec file261 """262 if os.path.isdir(output):263 output = os.path.join(output, porter.get_spec_name() + ".spec")264 tmp = sys.stdout265 if output != "":266 sys.stdout = open(output, 'w+')267 print("%{?nodejs_find_provides_and_requires}")268 print("")269 print("%global packagename {name}".format(name=porter.get_module_name()))270 print("")271 print(name_tag_template.format(pkg_name=porter.get_spec_name()))272 print(version_tag_template.format(pkg_ver=porter.get_version()))273 print(release_tag_template)274 print(summary_tag_template.format(pkg_sum=porter.get_summary()))275 print(license_tag_template.format(pkg_lic=porter.get_license()))276 print(home_tag_template.format(pkg_home=porter.get_home()))277 print(source_tag_template.format(pkg_source=porter.get_source_url()))278 print("")279 print("")280 print("ExclusiveArch: %{nodejs_arches} noarch")281 porter.get_buildarch()282 print("")283 porter.get_requires()284 print("")285 print("%description")286 print(porter.get_description())287 print("")288 print("")289 build_req_list = porter.get_build_requires()290 print("%prep")291 print("%autosetup -n package")292 print("# setup the tests")293 print("")294 print("%build")295 print("# nothing to do!")296 print("")297 print("%install")298 print("if [ -f license ]; then")299 print(" mv license LICENSE")300 print("fi")301 print("if [ -f License ]; then")302 print(" mv License LICENSE")303 print("fi")304 print("if [ -d bin ]; then")305 print("\tmkdir -p %{buildroot}%{_bindir}") 306 print("\tcp -ar bin/* %{buildroot}%{_bindir}")307 print("fi")308 print("mkdir -p %{buildroot}%{nodejs_sitelib}/%{packagename}")309 print("cp -ra * %{buildroot}%{nodejs_sitelib}/%{packagename}")310 print("pushd %{buildroot}")311 print("touch filelist.lst")312 print("find . -type f -printf \"/%h/%f\\n\" >> filelist.lst")313 print("sed -i '$d' filelist.lst")314 print("popd")315 print("mv %{buildroot}/filelist.lst .")316 print("%nodejs_symlink_deps")317 print("%check")318 print("%nodejs_symlink_deps --check")319 print("")320 print("%files -f filelist.lst")321 print("%changelog")322 date_str = datetime.date.today().strftime("%a %b %d %Y")323 print("* {today} Nodejs_Bot <Nodejs_Bot@openeuler.org>".format(today=date_str))324 print("- Package Spec generated")325 sys.stdout = tmp326 return build_req_list327def do_args(root):328 parser = argparse.ArgumentParser()329 parser.add_argument("-s", "--spec", help="Create spec file", action="store_true")330 parser.add_argument("-R", "--requires", help="Get required nodejs modules", action="store_true")331 parser.add_argument("-b", "--build", help="Build rpm package", action="store_true")332 parser.add_argument("-B", "--buildinstall", help="Build&Install rpm package", action="store_true")333 parser.add_argument("-r", "--rootpath", help="Build rpm package in root path", type=str, default=dft_root_path)334 parser.add_argument("-d", "--download", help="Download source file indicated path", action="store_true")335 parser.add_argument("-p", "--path", help="indicated path to store files", type=str, default=os.getcwd())336 parser.add_argument("-j", "--json", help="Get Package JSON info", action="store_true")337 parser.add_argument("-o", "--output", help="Output to file", type=str, default="")338 parser.add_argument("pkg", type=str, help="The Nodejs Module Name")339 parser.add_argument("special_version", nargs='?', const=1, type=str, default="latest", help="version")340 return parser341def porter_creator(pkg, pkg_version):342 return PyPorter(pkg, pkg_version)343if __name__ == "__main__":344 dft_root_path = os.path.join(str(Path.home()))345 parser = do_args(dft_root_path)346 args = parser.parse_args()347 porter = porter_creator(args.pkg, args.special_version)348 if (args.requires):349 req_list = porter.get_build_requires()350 if not req_list:351 print("No building requires")352 else:353 for req in req_list:354 print(req)355 elif (args.spec):356 build_spec(porter, args.output)357 elif (args.build):358 ret = build_rpm(porter, args.rootpath)359 if ret != "":360 print("build failed : BuildRequire : %s\n" % ret)361 sys.exit(1)362 elif (args.buildinstall):363 ret = build_install_rpm(porter, args.rootpath)...

Full Screen

Full Screen

builder.py

Source:builder.py Github

copy

Full Screen

...10def get_backend_name(default='default'):11 return os.environ.get(12 'MPI4PY_BUILD_BACKEND', default13 ).lower().replace('_', '-')14def get_build_requires():15 name = get_backend_name()16 use_skbuild = name in ('scikit-build', 'skbuild')17 requires = []18 requires.append(CYTHON)19 if use_skbuild:20 requires.append(SKBUILD)21 requires.append(CMAKE)22 requires.append(NINJA)23 return requires24@contextlib.contextmanager25def set_build_backend(name='default'):26 name_saved = os.environ.get('MPI4PY_BUILD_BACKEND')27 try:28 os.environ['MPI4PY_BUILD_BACKEND'] = name29 yield _st_bm30 finally:31 if name_saved is None:32 del os.environ['MPI4PY_BUILD_BACKEND']33 else:34 os.environ['MPI4PY_BUILD_BACKEND'] = name_saved35def get_requires_for_build_sdist(config_settings=None):36 with set_build_backend() as backend:37 requires = backend.get_requires_for_build_sdist(config_settings)38 return requires39def get_requires_for_build_wheel(config_settings=None):40 with set_build_backend() as backend:41 requires = backend.get_requires_for_build_wheel(config_settings)42 requires += get_build_requires()43 return requires44def get_requires_for_build_editable(config_settings=None):45 with set_build_backend() as backend:46 requires = backend.get_requires_for_build_editable(config_settings)47 requires += get_build_requires()48 return requires49def prepare_metadata_for_build_wheel(50 metadata_directory,51 config_settings=None,52):53 with set_build_backend() as backend:54 return backend.prepare_metadata_for_build_wheel(55 metadata_directory,56 config_settings,57 )58def prepare_metadata_for_build_editable(59 metadata_directory,60 config_settings=None,61):...

Full Screen

Full Screen

entrypoint.py

Source:entrypoint.py Github

copy

Full Screen

...23 result = subprocess.run([self._exe, *args], **kwargs)24 if not allow_errors:25 result.check_returncode()26 return result27def get_build_requires(data: Dict):28 return data.get("build-system", {}).get("requires", [])29def build_sdist(python):30 # XXX: Replace with `pip build` if/when available (see pypa/pip#6041)31 if os.path.exists("pyproject.toml"):32 data = load("pyproject.toml")33 build_requires = get_build_requires(data)34 if build_requires:35 python.pip("install", *build_requires)36 python.run("setup.py", "sdist")37python_locations = {38 "cp27": "cp27-cp27m",39 "cp34": "cp34-cp34m",40 "cp35": "cp35-cp35m",41 "cp36": "cp36-cp36m",42 "cp37": "cp37-cp37m",43 "cp38": "cp38-cp38m",44}45def set_output(name, value):46 print(f"::set-output name={name}::{value}")47def main(args: List[str]) -> int:...

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