Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docs/build/**/* linguist-generated=true
uv.lock linguist-generated=true
39 changes: 16 additions & 23 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,30 @@ name: lint

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]
workflow_call:

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.7","3.8","3.9","3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build wheel
python -m pip install .[dev]
- name: Typecheck with Mypy
run: |
python -m mypy src/
- name: Check code formatting
run: |
python -m black --check -l 120 src/ tests/
- name: Check import sorting
run: |
python -m isort --check-only 120 src/ tests/
- uses: actions/checkout@v3
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Typecheck
run: |
make check-types
- name: Check code formatting
run: |
make check-code
32 changes: 17 additions & 15 deletions .github/workflows/publish_compiled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,40 @@ name: publish-compiled-wheels
on:
push:
tags:
- '*.*.*'
- "*.*.*"
workflow_dispatch:
branches: [ main, master, support/1.0, support/1.1, support/2.0 ]
branches: [main, master, support/1.0, support/1.1, support/2.0]

jobs:
mac-and-windows-and-linux-publish:
runs-on: ${{ matrix.builds.os }}
strategy:
fail-fast: false
matrix:
builds: [
{os: "macOS-latest", python_requires: ">=3.7.0"},
{os: "windows-latest", python_requires: ">=3.7.0"},
{os: "ubuntu-latest", python_requires: ">=3.7.0,<3.11.0"}
]
builds:
[
{ os: "macOS-latest", python_requires: ">=3.8.0" },
{ os: "windows-latest", python_requires: ">=3.8.0" },
{ os: "ubuntu-latest", python_requires: ">=3.8.0,<3.14.0" },
]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: actions/checkout@v3
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install deps
run: python -m pip install cibuildwheel==2.9.0 twine==4.0.1
run: uv pip install cibuildwheel==2.9.0
- name: Build compiled wheels
env:
CIBW_PROJECT_REQUIRES_PYTHON: ${{ matrix.builds.python_requires }}
CIBW_BUILD: "cp3*"
PYTHON_MYPY_COMPILE: "true"
run: python -m cibuildwheel --output-dir wheelhouse
run: uv run python -m cibuildwheel --output-dir wheelhouse
- name: Publish compiled wheels
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload --skip-existing wheelhouse/*
uv publish wheelhouse/*
30 changes: 13 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,27 @@ name: test

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]
workflow_call:

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.7","3.8","3.9","3.10","3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build wheel
python -m pip install .[dev,types,build]
- name: Run the unittests
run: |
python -m unittest discover --start-directory tests --verbose --locals
- uses: actions/checkout@v3
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Run the unittests
run: |
make qt
128 changes: 33 additions & 95 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,129 +1,67 @@
# Select Python 3.9 or 3.10 (or error out)
ifneq (, $(shell command -v python3.9))
PYTHON=python3.9
else ifneq (, $(shell command -v python3.10))
PYTHON=python3.10
else ifneq (, $(shell command -v python3.11))
PYTHON=python3.11
else ifneq (, $(shell command -v python3.12))
PYTHON=python3.12
else ifneq (, $(shell command -v python3.13))
PYTHON=python3.13
else
$(error "No Python version 3.9, 3.10, 3.11, 3.12, or 3.13 found on: $(PATH)")
endif

ENV_DIR=.env_$(PYTHON)

define linebreak


endef

ifeq ($(OS),Windows_NT)
IN_ENV=. $(ENV_DIR)/Scripts/activate &&
else
IN_ENV=. $(ENV_DIR)/bin/activate &&
endif

# A few top-level variables
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MAKEFILE_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))

PIP_WHL=dependencies/pip-22.2.2-py3-none-any.whl
PIP_CMD=$(PYTHON) $(PIP_WHL)/pip

.PHONY: all
all: test format-code docs artifacts

env: $(ENV_DIR)

.PHONY: qt
qt:
$(IN_ENV) python -m unittest discover --start-directory tests --verbose -b
uv run --group=dev python -m unittest discover --start-directory tests --verbose -b

.PHONY: test
test: build check-code mypy qt
test: check-code check-types qt

.PHONY: artifacts
artifacts: build-reqs sdist wheel

$(ENV_DIR):
$(PYTHON) -m venv $(ENV_DIR)

.PHONY: build-reqs
build-reqs: env
$(IN_ENV) $(PIP_CMD) install build

.PHONY: build
build: env
$(IN_ENV) $(PIP_CMD) install -e .[dev,docs]
artifacts: sdist wheel

.PHONY: sdist
sdist: build-reqs
$(IN_ENV) $(PYTHON) -m build --sdist
sdist:
uv build --sdist

.PHONY: wheel
wheel: build-reqs
$(IN_ENV) $(PYTHON) -m build --wheel
wheel:
uv build --wheel

.PHONY: check-types
check-types:
uv run --group=dev mypy src/

.PHONY: format-code
format-code:
$(IN_ENV) black src/ tests/ docs/source/conf.py
$(IN_ENV) isort src/ tests/ docs/source/conf.py
@uv run ruff check --fix-only src/ tests/ docs/source/conf.py
@uv run ruff format src/ tests/ docs/source/conf.py

.PHONY: check-code
check-code:
$(IN_ENV) black --check src/ tests/ docs/source/conf.py
$(IN_ENV) isort --check-only src/ tests/ docs/source/conf.py
@uv run ruff check src/ tests/ docs/source/conf.py

.PHONY: docs
docs: build-reqs
$(IN_ENV) $(MAKE) -C docs html
docs:
uv run --group=docs $(MAKE) -C docs html
# $(IN_ENV) $(MAKE) -C docs html

.PHONY: publish
publish:
$(IN_ENV) twine upload dist/*

# Static Analysis

.PHONY: mypy
mypy:
$(IN_ENV) mypy src/
publish: artifacts
uv publish dist/*

.PHONY: freeze
freeze: env
- $(IN_ENV) pip freeze
freeze:
- uv pip freeze --color=auto

.PHONY: shell
shell: env
- $(IN_ENV) $(PYTHON)
shell:
- uv run python

.PHONY: clean
clean:
- @rm -rf BUILD
- @rm -rf BUILDROOT
- @rm -rf RPMS
- @rm -rf SRPMS
- @rm -rf SOURCES
- @rm -rf docs/build
- @rm -rf src/*.egg-info
- @rm -rf build
- @rm -rf dist
- @rm -f .coverage
- @rm -f test_results.xml
- @rm -f coverage.xml
- @rm -f tests/coverage.xml
- @rm -f pep8.out
- @find . -name '*.orig' -delete
- @find . -name '*.DS_Store' -delete
- @find . -name '*.pyc' -delete
- @find . -name '*.pyd' -delete
- @find . -name '*.pyo' -delete
- @find . -name '*__pycache__*' -delete

.PHONY: env-clean
env-clean: clean
- @git clean -dfX >> /dev/null 2>&1
- @rm -rf .env*
- @git clean -dfX
- @rm -rf $(ENV_DIR)
- @rm -rf .tox
- @rm -rf .venv*

.PHONY: git-clean
git-clean: clean
- @git fsck
- @git reflog expire --expire=now --all
- @git repack -ad
- @git prune
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
[![Documentation Status](https://readthedocs.org/projects/log-color/badge/?version=latest)](https://log-color.readthedocs.io/en/latest/?badge=latest)
[![Downloads](https://img.shields.io/pypi/dm/log-color)](https://pypistats.org/packages/log-color)
![Test](https://github.com/induane/logcolor/actions/workflows/test.yml/badge.svg) ![Lint](https://github.com/induane/logcolor/actions/workflows/lint.yml/badge.svg)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)


When making command line interfaces, it's often useful to colorize the output to emphasize salient pieces of
information or otherwise enhance the user experience. Unfortunately it's quite cumbersome to add colorized outputs to
Expand Down Expand Up @@ -37,3 +36,29 @@ $ pip install log_color

## http://no-color.org/
LogColor honors the ``NO_COLOR`` environment variable.

## Developer Setup

This project uses [uv](https://docs.astral.sh/uv/ "UV Documentation") for dependency management, command running, etc... install it:

```bash
$ curl -LsSf https://astral.sh/uv/install.sh | sh
```

### Makefile

If you're on Linux or OSX, there is a ``Makefile`` with a number of helpful targets:

* ``make check-types`` Run ``mypy`` static code analysis tools
* ``make format-code`` Runs the [ruff](https://beta.ruff.rs/docs/) code formatter
* ``make check-code`` Validates no code formatting errors or import sorting errors (check only, makes no changes)
* ``make wheel`` Build Python ``.whl`` file for distribution
* ``make test`` Run the unittests
* ``make docs`` Build the documentation
* ``make freeze`` List all packages (and their version number) installed in the virtual environment
* ``make shell`` Launch an interactive Python shell in the virtual environment context
* ``make clean`` Remove any files that aren't part of the repo (build artifacts, test reports, etc...)
* ``make git-clean`` Runs the git ``fsck`` tool, prunes the reflog, etc...

**TIP:** *If you want to force a target to be re-evaluated (i.e. ``make env``) run make with the ``-B`` flag to force
it to evaluate.*
Binary file removed dependencies/pip-22.2.2-py3-none-any.whl
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Standard
import datetime
from __future__ import annotations

import sphinx_rtd_theme
import datetime

# ----------------------------------------------------------------------------
# General Settings
Expand Down
Loading