Skip to content

redjax/red-utils

 
 

Repository files navigation

red-utils

GitHub Created At GitHub last commit GitHub commits this year GitHub Latest Release PyPI - Version GitHub commits since latest release PyPI - Downloads GitHub Actions Workflow Status GitHub repo size GitHub code size in bytes

⚠️Important⚠️: This is my first Python package. I'm experimenting with CI/CD and Pypi. This library is most likely not useful to anyone else, may be broken at times, may undergo refactors with little to no notice/documentation, and all that other awful stuff that comes with being an amateur developer doing this in their free time 🙃

Table of Contents

Description

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 Python stdlib.
  • ext: Utilities for dependencies like loguru and msgpack
    • 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 the ext.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 ImportErrors due to circular package imports).

Installation

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

Installation - with dependency groups

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]
  • Install red-utils with support for the httpx package:
    • pip: pip install red-utils[httpx]
    • pdm: pdm add red-utils[httpx]
    • uv: uv add red-utils[httpx]
  • Install red-utils with support for the sqlalchemy and loguru packages:
    • pip: pip install red-utils[sqlalchemy,loguru]
    • pdm: pdm add red-utils[sqlalchemy,loguru]
    • uv: uv add red-utils[sqlalchemy,loguru]

Developing red-utils

Please see the developing docs for instructions on setting up a dev environment to work on red-utils.

About

My personal collection of Python utilities (modules, functions, etc)

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages