Report if a newer version of circup is available
This commit is contained in:
parent
f0d51771e2
commit
bfecb7593f
3 changed files with 29 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ import findimports
|
|||
import pkg_resources
|
||||
import requests
|
||||
from semver import VersionInfo
|
||||
import update_checker
|
||||
|
||||
|
||||
# Useful constants.
|
||||
|
|
@ -811,6 +812,24 @@ def get_circuitpython_version(device_path):
|
|||
return (circuit_python, board_id)
|
||||
|
||||
|
||||
def get_circup_version():
|
||||
"""Return the version of circup that is running. If not available, return None.
|
||||
|
||||
:return: Current version of circup, or None.
|
||||
"""
|
||||
try:
|
||||
from importlib import metadata # pylint: disable=import-outside-toplevel
|
||||
except ImportError:
|
||||
try:
|
||||
import importlib_metadata as metadata # pylint: disable=import-outside-toplevel
|
||||
except ImportError:
|
||||
return None
|
||||
try:
|
||||
return metadata.version("circup")
|
||||
except metadata.PackageNotFoundError:
|
||||
return None
|
||||
|
||||
|
||||
def get_dependencies(*requested_libraries, mod_names, to_install=()):
|
||||
"""
|
||||
Return a list of other CircuitPython libraries
|
||||
|
|
@ -1128,6 +1147,13 @@ def main(ctx, verbose, path): # pragma: no cover
|
|||
logger.addHandler(verbose_handler)
|
||||
click.echo("Logging to {}\n".format(LOGFILE))
|
||||
logger.info("### Started Circup ###")
|
||||
|
||||
# If a newer version of circup is available, print a message.
|
||||
logger.info("Checking for a newer version of circup")
|
||||
version = get_circup_version()
|
||||
if version:
|
||||
update_checker.update_check("circup", version)
|
||||
|
||||
# stop early if the command is boardless
|
||||
if ctx.invoked_subcommand in BOARDLESS_COMMANDS:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ sphinxcontrib-serializinghtml==1.1.3
|
|||
toml==0.10.0
|
||||
tqdm==4.35.0
|
||||
twine==1.13.0
|
||||
update-checker==0.18.0
|
||||
urllib3==1.26.5
|
||||
wcwidth==0.1.7
|
||||
webencodings==0.5.1
|
||||
|
|
|
|||
2
setup.py
2
setup.py
|
|
@ -28,6 +28,8 @@ install_requires = [
|
|||
"appdirs>=1.4.3",
|
||||
"requests>=2.22.0",
|
||||
"findimports>=2.1.0",
|
||||
# importlib_metadata is only available for 3.7, and is not needed for 3.8 and up.
|
||||
"importlib_metadata; python_version == '3.7'",
|
||||
]
|
||||
|
||||
extras_require = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue