Python importlib_metadata.version() Examples

The following are 4 code examples of importlib_metadata.version(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module importlib_metadata , or try the search function .
Example #1
Source File: user_agent.py    From sagemaker-python-sdk with Apache License 2.0 6 votes vote down vote up
def determine_prefix():
    """Placeholder docstring"""
    prefix = "AWS-SageMaker-Python-SDK/{} Python/{} {}/{} Boto3/{} Botocore/{}".format(
        SDK_VERSION, PYTHON_VERSION, OS_NAME, OS_VERSION, boto3.__version__, botocore.__version__
    )

    try:
        with open("/etc/opt/ml/sagemaker-notebook-instance-version.txt") as sagemaker_nbi_file:
            prefix = "AWS-SageMaker-Notebook-Instance/{} {}".format(
                sagemaker_nbi_file.read().strip(), prefix
            )
    except IOError:
        # This file isn't expected to always exist, and we DO want to silently ignore failures.
        pass

    return prefix 
Example #2
Source File: __main__.py    From nox with Apache License 2.0 5 votes vote down vote up
def main() -> None:
    args = _options.options.parse_args()

    if args.help:
        _options.options.print_help()
        return

    if args.version:
        print(metadata.version("nox"), file=sys.stderr)
        return

    setup_logging(
        color=args.color, verbose=args.verbose, add_timestamp=args.add_timestamp
    )

    # Execute the appropriate tasks.
    exit_code = workflow.execute(
        global_config=args,
        workflow=(
            tasks.load_nox_module,
            tasks.merge_noxfile_options,
            tasks.discover_manifest,
            tasks.filter_manifest,
            tasks.honor_list_request,
            tasks.verify_manifest_nonempty,
            tasks.run_manifest,
            tasks.print_summary,
            tasks.create_report,
            tasks.final_reduce,
        ),
    )

    # Done; exit.
    sys.exit(exit_code) 
Example #3
Source File: test_main.py    From nox with Apache License 2.0 5 votes vote down vote up
def test_main_version(capsys, monkeypatch):
    monkeypatch.setattr(sys, "argv", [sys.executable, "--version"])

    with contexter.ExitStack() as stack:
        execute = stack.enter_context(mock.patch("nox.workflow.execute"))
        exit_mock = stack.enter_context(mock.patch("sys.exit"))
        nox.__main__.main()
        _, err = capsys.readouterr()
        assert VERSION in err
        exit_mock.assert_not_called()
        execute.assert_not_called() 
Example #4
Source File: client.py    From irc with MIT License 5 votes vote down vote up
def version(self, server=""):
        """Send a VERSION command."""
        self.send_items('VERSION', server)