griffe-runtime-objects 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ """griffe-runtime-objects package.
2
+
3
+ Make runtime objects available through `extra`.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ __all__: list[str] = []
@@ -0,0 +1,109 @@
1
+ """Debugging utilities."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import platform
7
+ import sys
8
+ from dataclasses import dataclass
9
+ from importlib import metadata
10
+
11
+
12
+ @dataclass
13
+ class Variable:
14
+ """Dataclass describing an environment variable."""
15
+
16
+ name: str
17
+ """Variable name."""
18
+ value: str
19
+ """Variable value."""
20
+
21
+
22
+ @dataclass
23
+ class Package:
24
+ """Dataclass describing a Python package."""
25
+
26
+ name: str
27
+ """Package name."""
28
+ version: str
29
+ """Package version."""
30
+
31
+
32
+ @dataclass
33
+ class Environment:
34
+ """Dataclass to store environment information."""
35
+
36
+ interpreter_name: str
37
+ """Python interpreter name."""
38
+ interpreter_version: str
39
+ """Python interpreter version."""
40
+ interpreter_path: str
41
+ """Path to Python executable."""
42
+ platform: str
43
+ """Operating System."""
44
+ packages: list[Package]
45
+ """Installed packages."""
46
+ variables: list[Variable]
47
+ """Environment variables."""
48
+
49
+
50
+ def _interpreter_name_version() -> tuple[str, str]:
51
+ if hasattr(sys, "implementation"):
52
+ impl = sys.implementation.version
53
+ version = f"{impl.major}.{impl.minor}.{impl.micro}"
54
+ kind = impl.releaselevel
55
+ if kind != "final":
56
+ version += kind[0] + str(impl.serial)
57
+ return sys.implementation.name, version
58
+ return "", "0.0.0"
59
+
60
+
61
+ def get_version(dist: str = "griffe-runtime-objects") -> str:
62
+ """Get version of the given distribution.
63
+
64
+ Parameters:
65
+ dist: A distribution name.
66
+
67
+ Returns:
68
+ A version number.
69
+ """
70
+ try:
71
+ return metadata.version(dist)
72
+ except metadata.PackageNotFoundError:
73
+ return "0.0.0"
74
+
75
+
76
+ def get_debug_info() -> Environment:
77
+ """Get debug/environment information.
78
+
79
+ Returns:
80
+ Environment information.
81
+ """
82
+ py_name, py_version = _interpreter_name_version()
83
+ packages = ["griffe-runtime-objects"]
84
+ variables = ["PYTHONPATH", *[var for var in os.environ if var.startswith("GRIFFE_RUNTIME_OBJECTS")]]
85
+ return Environment(
86
+ interpreter_name=py_name,
87
+ interpreter_version=py_version,
88
+ interpreter_path=sys.executable,
89
+ platform=platform.platform(),
90
+ variables=[Variable(var, val) for var in variables if (val := os.getenv(var))],
91
+ packages=[Package(pkg, get_version(pkg)) for pkg in packages],
92
+ )
93
+
94
+
95
+ def print_debug_info() -> None:
96
+ """Print debug/environment information."""
97
+ info = get_debug_info()
98
+ print(f"- __System__: {info.platform}")
99
+ print(f"- __Python__: {info.interpreter_name} {info.interpreter_version} ({info.interpreter_path})")
100
+ print("- __Environment variables__:")
101
+ for var in info.variables:
102
+ print(f" - `{var.name}`: `{var.value}`")
103
+ print("- __Installed packages__:")
104
+ for pkg in info.packages:
105
+ print(f" - `{pkg.name}` v{pkg.version}")
106
+
107
+
108
+ if __name__ == "__main__":
109
+ print_debug_info()
File without changes
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.1
2
+ Name: griffe-runtime-objects
3
+ Version: 0.1.0
4
+ Summary: Make runtime objects available through `extra`.
5
+ Author-Email: =?utf-8?q?Timoth=C3=A9e_Mazzucotelli?= <dev@pawamoy.fr>
6
+ License: ISC
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Programming Language :: Python
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Documentation
19
+ Classifier: Topic :: Software Development
20
+ Classifier: Topic :: Utilities
21
+ Classifier: Typing :: Typed
22
+ Project-URL: Homepage, https://mkdocstrings.github.io/griffe-runtime-objects
23
+ Project-URL: Documentation, https://mkdocstrings.github.io/griffe-runtime-objects
24
+ Project-URL: Changelog, https://mkdocstrings.github.io/griffe-runtime-objects/changelog
25
+ Project-URL: Repository, https://github.com/mkdocstrings/griffe-runtime-objects
26
+ Project-URL: Issues, https://github.com/mkdocstrings/griffe-runtime-objects/issues
27
+ Project-URL: Discussions, https://github.com/mkdocstrings/griffe-runtime-objects/discussions
28
+ Project-URL: Gitter, https://gitter.im/mkdocstrings/griffe-runtime-objects
29
+ Project-URL: Funding, https://github.com/sponsors/pawamoy
30
+ Requires-Python: >=3.8
31
+ Description-Content-Type: text/markdown
32
+
33
+ # griffe-runtime-objects
34
+
35
+ [![documentation](https://img.shields.io/badge/docs-mkdocs-708FCC.svg?style=flat)](https://mkdocstrings.github.io/griffe-runtime-objects/)
36
+ [![gitpod](https://img.shields.io/badge/gitpod-workspace-708FCC.svg?style=flat)](https://gitpod.io/#https://github.com/mkdocstrings/griffe-runtime-objects)
37
+ [![gitter](https://badges.gitter.im/join%20chat.svg)](https://app.gitter.im/#/room/#griffe-runtime-objects:gitter.im)
38
+
39
+ Make runtime objects available through `extra`.
40
+
41
+ ## Installation
42
+
43
+ This project is available to sponsors only, through my Insiders program.
44
+ See Insiders [explanation](https://mkdocstrings.github.io/griffe-runtime-objects/insiders/)
45
+ and [installation instructions](https://mkdocstrings.github.io/griffe-runtime-objects/insiders/installation/).
@@ -0,0 +1,7 @@
1
+ griffe_runtime_objects-0.1.0.dist-info/METADATA,sha256=GxdqemEdH5n4FYpmyS7JPKp_zSxaw-9p91t52U-YgvY,2362
2
+ griffe_runtime_objects-0.1.0.dist-info/WHEEL,sha256=rSwsxJWe3vzyR5HCwjWXQruDgschpei4h_giTm0dJVE,90
3
+ griffe_runtime_objects-0.1.0.dist-info/licenses/LICENSE,sha256=nke00CVElTmhjAOYXkupvTNauLNPzBTuASi3u9moZ1U,754
4
+ griffe_runtime_objects/__init__.py,sha256=iM8__IJyBOi2qxAEh9zaw8aFv__r4kipirHz2cDvQ2Q,149
5
+ griffe_runtime_objects/debug.py,sha256=4PLLW0mdNSvZs5fbVCcY68-k2dxJgNvtDqDJ5zhJtGQ,2867
6
+ griffe_runtime_objects/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ griffe_runtime_objects-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: pdm-backend (2.3.3)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2024, Timothée Mazzucotelli
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.