MCPcopy
hub / github.com/raiden-network/raiden / main

Function main

tools/pip-compile-wrapper.py:295–351  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

293
294
295def main() -> None:
296 parser = ArgumentParser(prog=SCRIPT_NAME)
297 parser.add_argument("-v", "--verbose", action="store_true", default=False)
298 parser.add_argument("-n", "--dry-run", action="store_true", default=False)
299
300 commands = parser.add_subparsers(title="Sub-commands", required=True, dest="command")
301 commands.add_parser(
302 "compile",
303 help=(
304 "Compile source files. "
305 "Keep current versions unless changed requirements force newer versions."
306 ),
307 )
308
309 upgrade_parser = commands.add_parser(
310 "upgrade",
311 help=(
312 "Compile source files and upgrade package versions. "
313 "Optionally specify package names to upgrade only those."
314 ),
315 )
316 upgrade_parser.add_argument(
317 "--pre",
318 action="store_true",
319 default=False,
320 help="Use pre-release versions of packages if available.",
321 )
322 upgrade_parser.add_argument("packages", metavar="package", nargs="*")
323
324 parsed = parser.parse_args()
325 _ensure_pip_tools()
326
327 if parsed.command == "compile":
328 compile_source(verbose=parsed.verbose, dry_run=parsed.dry_run)
329 elif parsed.command == "upgrade":
330 packages = set(parsed.packages)
331 if not packages:
332 # This is a standalone script which is not using gevent
333 resp = input( # pylint: disable=gevent-input-forbidden
334 "Are you sure you want to upgrade ALL packages? [y/N] "
335 )
336 if resp.lower() != "y":
337 print("Aborting")
338 sys.exit(1)
339 compile_source(upgrade_all=True, verbose=parsed.verbose, dry_run=parsed.dry_run)
340 else:
341 if parsed.pre:
342 print(
343 "Warning: Using the '--pre' option can cause unintended upgrades to "
344 "prerelease versions of unrelated packages. This is due to constraints in the "
345 "underlying tools (pip-compile / pip) that don't currently allow constraining "
346 "pre-releases to only specific packages.\n"
347 "Please carefully inspect the generated output files!"
348 )
349 upgrade_source(
350 packages, verbose=parsed.verbose, dry_run=parsed.dry_run, pre=parsed.pre
351 )
352

Callers 1

Calls 3

_ensure_pip_toolsFunction · 0.85
compile_sourceFunction · 0.85
upgrade_sourceFunction · 0.85

Tested by

no test coverage detected