red_utils
is a monorepo package, with extra "bolt-on" functionality for packages I use frequently. The base install includes functionality for stdlib
packages like pathlib
and list
/dict
types. These packages do not require any external dependencies, and are always present in red_utils
installs.
This package also includes optional dependencies, defined in the [project.optional-dependencies]
section of the repository's pyproject.toml
. You can install specific packages for 3rd party tools, like httpx_utils
for the httpx
requests client, by adding them as optional dependencies during installs: pip install red-utils[httpx_utils]
.
The utilities are broken down into 2 modules:
std
: Utilities with no external dependencies, only the Pythonstdlib
.ext
: Utilities for dependencies likeloguru
andmsgpack
-
Note: It is generally a good practice to import
ext
modules as a whole, instead of importing functions/variables from the module. -
This is because some of the function names I chose may be common (like
get_ts()
in theext.time_utils
module). -
Example:
from red_utils.ext import time_utils now = time_utils.get_ts()
or, with
pendulum
:from red_utils.ext.time_utils import pendulum_utils now = pendulum_utils.get_ts()
-
Packages can import code from modules in the shared/
path. Modules in this path should not have any external dependencies, and should not try to import from any package in the packages/
directory (to avoid ImportError
s due to circular package imports).
This project uses dependencies groups, meaning it can be installed with pip install red-utils
for the base package, or with dependency groups like pip install red-utils[all]
(to install all packages with a corresponding red-util module), pip install red-utils[httpx]
(to install some helpful packages for HTTP requests, i.e. httpx
and diskcache
), and more. You can install multiple dependency groups with commans, like pip install red-utils[httpx,diskcache]
.
Note that the methods below will only install stdlib
packages, no support for 3rd party packages (see the Installation - with dependency groups section).
- pip
pip install red-utils
- pdm
pdm add red-utils
- uv
uv add red-utils
This package also includes optional dependencies, defined in the [project.optional-dependencies]
section of the repository's pyproject.toml
.
Some examples of installing specific dependency groups, adding utilities for specific 3rd party apps:
- Install
red-utils
with all optional dependency groups:- pip:
pip install red-utils[all]
- pdm:
pdm add red-utils[all]
- uv:
uv add red-utils[all]
- pip:
- Install
red-utils
with support for thehttpx
package:- pip:
pip install red-utils[httpx]
- pdm:
pdm add red-utils[httpx]
- uv:
uv add red-utils[httpx]
- pip:
- Install
red-utils
with support for thesqlalchemy
andloguru
packages:- pip:
pip install red-utils[sqlalchemy,loguru]
- pdm:
pdm add red-utils[sqlalchemy,loguru]
- uv:
uv add red-utils[sqlalchemy,loguru]
- pip:
Please see the developing docs for instructions on setting up a dev environment to work on red-utils
.