Skip to content

Allow pkg_install() to print destdir by default #889

@jacky8hyf

Description

@jacky8hyf

If destdir is a relative path, and/or if destdir is provided in the BUILD file, then sometimes the user does not know where the files are installed to. For a better UI, I would like to see this:

$ bazel run //package:my_install
Files are installed to /path/to/installed/dir!

There are a few difficulties / issues that has not been settled.

  1. The default log level is warning. However, the log Files are installed to /path/to/installed/dir! appears to be best categorized as an INFO log.
  2. If the user specified destdir in the command line, we might not want to print anything for brevity.

Hence, I propose the following changes:

  • The default log level for install.py.tpl should be INFO. All existing logs (CHDIR, CHOWN, etc.) are moved to logging.debug() level. Then make the log level adjust with the following:

        if args.quiet:
          logging.getLogger().setLevel(logging.WARNING)
      elif loudness == 0:
          logging.getLogger().setLevel(logging.INFO)
      elif loudness == 1:
          logging.getLogger().setLevel(logging.DEBUG)
    

    That is:

    • if -q only print warning/error (there are none of these logs now)
    • by default print info
    • if -v print debug level logs
      With these two changes, the current command-line API is preserved (-v prints the logs)
  • If destdir is relative, OR if --destdir is not specified in the command line, then print Files are installed to /path/to/installed/dir! at the INFO level. This covers the following cases:

    • If the user did not provide --destdir in the command line, we fall back to the value in BUILD file, so we print the value to tell the user where the file goes.
    • If the user did provide a --diestdir but it is relative, we also print the value because the user might not know that it is below BUILD_WORKSPACE_DIRECTORY.

Please let me know if these changes are acceptable. If so I'll make a pull request for this. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that we are not working on but will review quarterlyfeature-request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions