-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
============ | ||
Utils | ||
============ | ||
.. currentmodule:: polars | ||
|
||
.. autosummary:: | ||
:toctree: api/ | ||
|
||
show_versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from __future__ import annotations | ||
|
||
import importlib | ||
import platform | ||
import sys | ||
|
||
try: | ||
from polars.polars import get_idx_type as _get_idx_type | ||
from polars.polars import version | ||
|
||
_DOCUMENTING = False | ||
except ImportError: | ||
_DOCUMENTING = True | ||
|
||
|
||
def show_versions() -> None: | ||
""" | ||
Print out version of Polars and dependencies to stdout. | ||
Examples | ||
-------- | ||
>>> pl.show_versions() # doctest: +SKIP | ||
---Version info--- | ||
Polars: 0.14.0 | ||
Index type: UInt32 | ||
Platform: Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.31 | ||
Python: 3.10.5 (main, Jul 8 2022, 14:32:56) [GCC 10.2.1 20210110] | ||
---Optional dependencies--- | ||
pyarrow: 8.0.0 | ||
pandas: 1.4.3 | ||
numpy: 1.23.0 | ||
fsspec: <not installed> | ||
connectorx: <not installed> | ||
xlsx2csv: <not installed> | ||
""" | ||
print("---Version info---") | ||
print(f"Polars: {version()}") | ||
print(f"Index type: {_get_idx_type().__name__}") | ||
print(f"Platform: {platform.platform()}") | ||
print(f"Python: {sys.version}") | ||
|
||
print("---Optional dependencies---") | ||
deps = _get_dependency_info() | ||
for name, v in deps.items(): | ||
print(f"{name}: {v}") | ||
|
||
|
||
def _get_dependency_info() -> dict[str, str]: | ||
# see the list of dependencies in pyproject.toml | ||
opt_deps = ["pyarrow", "pandas", "numpy", "fsspec", "connectorx", "xlsx2csv"] | ||
return {name: _get_dep_version(name) for name in opt_deps} | ||
|
||
|
||
def _get_dep_version(dep_name: str) -> str: | ||
try: | ||
module = importlib.import_module(dep_name) | ||
except ImportError: | ||
return "<not installed>" | ||
|
||
# all our dependencies as of 2022-08-11 implement __version__ | ||
return getattr(module, "__version__", "<version not detected>") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import polars as pl | ||
|
||
|
||
def test_show_versions(capsys) -> None: # type: ignore[no-untyped-def] | ||
pl.show_versions() | ||
|
||
out, _ = capsys.readouterr() | ||
assert "Python" in out | ||
assert "Polars" in out | ||
assert "Optional dependencies" in out |