1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-30 18:24:35 +01:00

Improved platform information in info plugin

This commit is contained in:
squidfunk 2023-01-02 10:55:24 +01:00
parent fc6a368d6b
commit 01b25dddcb
2 changed files with 28 additions and 30 deletions

View File

@ -18,6 +18,7 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE. # IN THE SOFTWARE.
import json
import logging import logging
import os import os
import platform import platform
@ -111,27 +112,25 @@ class InfoPlugin(BasePlugin[InfoPluginConfig]):
path = os.path.relpath(file.abs_src_path, os.path.curdir) path = os.path.relpath(file.abs_src_path, os.path.curdir)
f.write(path, os.path.join(archive_name, path)) f.write(path, os.path.join(archive_name, path))
# Add dependency tree as returned by pipdeptree # Add information on packages
f.writestr( f.writestr(
os.path.join(archive_name, ".dependencies.json"), os.path.join(archive_name, ".packages.json"),
render_json_tree(PackageDAG.from_pkgs( render_json_tree(PackageDAG.from_pkgs(
get_installed_distributions(local_only = True) get_installed_distributions(local_only = True)
), 2) ), 2)
) )
# Add version information # Add information in platform
mkdocs = get_distribution("mkdocs")
f.writestr( f.writestr(
os.path.join(archive_name, ".versions.log"), os.path.join(archive_name, ".platform.json"),
"\n".join([ json.dumps(
f"-----------------------------------", {
f" Material for MkDocs: {version}", "system": platform.platform(),
f" MkDocs: {mkdocs.version}", "python": platform.python_version()
f"-----------------------------------", },
f" Platform: {platform.system()}", default = str,
f" Python: {platform.python_version()}", indent = 2
f"-----------------------------------" )
])
) )
# Retrieve list of processed files # Retrieve list of processed files
@ -182,7 +181,7 @@ class InfoPlugin(BasePlugin[InfoPluginConfig]):
print(Style.NORMAL) print(Style.NORMAL)
print(f" Please update from {have} to {need}.") print(f" Please update from {have} to {need}.")
print(Style.RESET_ALL) print(Style.RESET_ALL)
print(f" pip install \"mkdocs-material=={need}\"") print(f" pip install --upgrade --force-reinstall mkdocs-material")
print(Style.NORMAL) print(Style.NORMAL)
# Exit, unless explicitly told not to # Exit, unless explicitly told not to

View File

@ -18,6 +18,7 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE. # IN THE SOFTWARE.
import json
import logging import logging
import os import os
import platform import platform
@ -111,27 +112,25 @@ class InfoPlugin(BasePlugin[InfoPluginConfig]):
path = os.path.relpath(file.abs_src_path, os.path.curdir) path = os.path.relpath(file.abs_src_path, os.path.curdir)
f.write(path, os.path.join(archive_name, path)) f.write(path, os.path.join(archive_name, path))
# Add dependency tree as returned by pipdeptree # Add information on packages
f.writestr( f.writestr(
os.path.join(archive_name, ".dependencies.json"), os.path.join(archive_name, ".packages.json"),
render_json_tree(PackageDAG.from_pkgs( render_json_tree(PackageDAG.from_pkgs(
get_installed_distributions(local_only = True) get_installed_distributions(local_only = True)
), 2) ), 2)
) )
# Add version information # Add information in platform
mkdocs = get_distribution("mkdocs")
f.writestr( f.writestr(
os.path.join(archive_name, ".versions.log"), os.path.join(archive_name, ".platform.json"),
"\n".join([ json.dumps(
f"-----------------------------------", {
f" Material for MkDocs: {version}", "system": platform.platform(),
f" MkDocs: {mkdocs.version}", "python": platform.python_version()
f"-----------------------------------", },
f" Platform: {platform.system()}", default = str,
f" Python: {platform.python_version()}", indent = 2
f"-----------------------------------" )
])
) )
# Retrieve list of processed files # Retrieve list of processed files
@ -182,7 +181,7 @@ class InfoPlugin(BasePlugin[InfoPluginConfig]):
print(Style.NORMAL) print(Style.NORMAL)
print(f" Please update from {have} to {need}.") print(f" Please update from {have} to {need}.")
print(Style.RESET_ALL) print(Style.RESET_ALL)
print(f" pip install \"mkdocs-material=={need}\"") print(f" pip install --upgrade --force-reinstall mkdocs-material")
print(Style.NORMAL) print(Style.NORMAL)
# Exit, unless explicitly told not to # Exit, unless explicitly told not to