pyct: Python Common Tasks
pyct (Python Common Tasks) is a utility package from the HoloViz ecosystem designed to simplify common tasks for Python projects, such as copying examples, fetching data, and reporting environment details. It also provides utilities for package building, primarily as a convenience for project maintainers. The current version is 0.6.0. It maintains an active development pace with regular releases addressing Python compatibility, introducing new utilities, and deprecating older patterns.
Warnings
- breaking pyct version 0.6.0 dropped support for Python versions older than 3.8. Earlier versions (0.5.0) also dropped support for Python 2.7 and 3.7.
- deprecated The `pyct.get_setup_version` function is deprecated and will be removed in a future version. The 'Param' dependency, which it relies on, will also be removed at the same time.
- breaking In pyct 0.4.4, the function `pyct.cmd.add_pv_commands()` was renamed to `add_commands()`, and its interface was modified.
Install
-
pip install pyct -
pip install pyct[cmd]
Imports
- pyct
import pyct
- cmd
from pyct import cmd
- build
from pyct import build
- add_pv_commands
from pyct.cmd import add_commands
Quickstart
import pyct
import sys
import io
# Redirect stdout to capture output for programmatic example
old_stdout = sys.stdout
redirected_output = io.StringIO()
sys.stdout = redirected_output
try:
# Use pyct.report to print version information about specified packages
pyct.report(packages=['pyct', 'numpy', 'param'])
output = redirected_output.getvalue()
print("--- pyct.report output ---")
print(output.strip())
print("--------------------------")
finally:
sys.stdout = old_stdout # Restore stdout
print("You can also run 'pyct report' from the command line.")