Skip to content

pypi_insiders ¤

PyPI Insiders package.

Self-hosted PyPI server with automatic updates for Insiders versions of projects.

Modules:

  • cli –

    Deprecated. Import from pypi_insiders._internal.cli instead.

  • defaults –

    Deprecated. Import from pypi_insiders._internal.defaults instead.

  • logger –

    Deprecated. Import from pypi_insiders._internal.logger instead.

  • repos –

    Deprecated. Import from pypi_insiders._internal.repos instead.

  • server –

    Deprecated. Import from pypi_insiders._internal.server instead.

  • update –

    Deprecated. Import from pypi_insiders._internal.update instead.

  • watcher –

    Deprecated. Import from pypi_insiders._internal.watcher instead.

Functions:

  • get_parser –

    Return the CLI argument parser.

  • main –

    Run the main program.

get_parser ¤

get_parser() -> ArgumentParser

Return the CLI argument parser.

Returns:

Source code in src/pypi_insiders/_internal/cli/__init__.py
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
def get_parser() -> argparse.ArgumentParser:
    """Return the CLI argument parser.

    Returns:
        An argparse parser.
    """
    description = "Self-hosted PyPI server with automatic updates for Insiders versions of projects."
    parser = argparse.ArgumentParser(add_help=False, description=description, prog=prog_name)
    parser_with_commands_help = "Show this help message and exit. Commands also accept the -h/--help option."
    parser_without_commands_help = "Show this help message and exit."
    options = parser.add_argument_group(title="Global options")
    parser.add_argument("-V", "--version", action="version", version=f"%(prog)s {debug._get_version()}")
    parser.add_argument("--debug-info", action=_DebugInfo, help="Print debug information.")
    options.add_argument("-h", "--help", action="help", help=parser_with_commands_help)

    repos = subparser(parser, "repos", "Manage insiders repositories.", parser_with_commands_help)
    repos_list = subparser(repos, "list", "List insiders repositories.", parser_without_commands_help)
    repos_add = subparser(repos, "add", "Add insiders repositories.", parser_without_commands_help)
    repos_remove = subparser(repos, "remove", "Remove insiders repositories.", parser_without_commands_help)

    update = subparser(parser, "update", "Update insiders packages.", parser_without_commands_help)

    server = subparser(parser, "server", "Manage local PyPI server.", parser_with_commands_help)
    server_start = subparser(server, "start", "Start local PyPI server in background.", parser_with_commands_help)
    server_status = subparser(server, "status", "See status of local PyPI server.", parser_with_commands_help)
    server_stop = subparser(server, "stop", "Stop local PyPI server.", parser_with_commands_help)
    server_run = subparser(server, "run", "Run local PyPI server in foreground.", parser_with_commands_help)
    server_logs = subparser(server, "logs", "Show local PyPI server logs.", parser_with_commands_help)

    watcher = subparser(parser, "watcher", "Manage repositories watcher.", parser_with_commands_help)
    watcher_start = subparser(
        watcher,
        "start",
        "Start repositories watcher in background.",
        parser_without_commands_help,
    )
    watcher_status = subparser(watcher, "status", "See status of repositories watcher.", parser_without_commands_help)
    watcher_stop = subparser(watcher, "stop", "Stop repositories watcher.", parser_without_commands_help)
    watcher_run = subparser(watcher, "run", "Run repositories watcher in foreground.", parser_without_commands_help)
    watcher_logs = subparser(watcher, "logs", "Show repositories watcher logs.", parser_without_commands_help)

    all_parsers = (
        parser,
        repos,
        repos_add,
        repos_list,
        repos_remove,
        update,
        server,
        server_start,
        server_stop,
        server_run,
        server_logs,
        watcher,
        watcher_start,
        watcher_status,
        watcher_stop,
        watcher_run,
        watcher_logs,
    )

    # add conf path option to all parsers
    for prsr in all_parsers:
        add_arg_conf_path(prsr)
        add_arg_log_level(prsr)
        add_arg_log_path(prsr)

    # add repositories option to repos add/remove
    add_arg_repositories_packages(repos_add)
    add_arg_repositories(repos_remove)
    add_arg_repo_dir(repos_remove)

    # add server options
    add_arg_dist_dir(server)
    add_arg_dist_dir(server_start)
    add_arg_dist_dir(server_run)
    add_arg_port(server)
    add_arg_port(server_start)
    add_arg_port(server_status)
    add_arg_port(server_stop)
    add_arg_port(server_run)

    # add update options
    add_arg_repo_dir(update)
    add_arg_index_url(update)
    add_arg_index_user(update)
    add_arg_index_password(update)
    add_arg_repositories(update, nargs="*")

    # add watcher options
    add_arg_repo_dir(watcher_start)
    add_arg_index_url(watcher_start)
    add_arg_index_user(watcher_start)
    add_arg_index_password(watcher_start)
    add_arg_sleep(watcher_start)
    add_arg_repo_dir(watcher_run)
    add_arg_index_url(watcher_run)
    add_arg_index_user(watcher_run)
    add_arg_index_password(watcher_run)
    add_arg_sleep(watcher_run)

    return parser

main ¤

main(args: list[str] | None = None) -> int

Run the main program.

This function is executed when you type pypi-insiders or python -m pypi_insiders.

Parameters:

  • args ¤

    (list[str] | None, default: None ) –

    Arguments passed from the command line.

Returns:

  • int –

    An exit code.

Source code in src/pypi_insiders/_internal/cli/__init__.py
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
def main(args: list[str] | None = None) -> int:
    """Run the main program.

    This function is executed when you type `pypi-insiders` or `python -m pypi_insiders`.

    Parameters:
        args: Arguments passed from the command line.

    Returns:
        An exit code.
    """
    parser = get_parser()
    opts = parser.parse_args(args=args)
    configure_logging(opts.log_level, opts.log_path, allow="pypiserver")
    if not opts.subcommand:
        parser.print_usage(file=sys.stderr)
        return 1
    return commands[opts.subcommand](opts)