Skip to content

Commit

Permalink
Dev chores (#263)
Browse files Browse the repository at this point in the history
* Migrate to pyproject.toml; use ruff; remove copyright year

* tox -e lint

* Update pypi release workflow; dependabot gha

* Fix test
  • Loading branch information
sloria authored Jan 30, 2024
1 parent 049638e commit ff3c796
Show file tree
Hide file tree
Showing 25 changed files with 162 additions and 188 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ updates:
schedule:
interval: weekly
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
67 changes: 46 additions & 21 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: build
on:
push:
branches: ["main"]
tags: ["*"]
pull_request:

jobs:
tests:
name: ${{ matrix.name }}
Expand All @@ -13,39 +16,61 @@ jobs:
- { name: "3.8-ipython8", python: "3.8", tox: py38-ipython8 }
- { name: "3.12-ipython8", python: "3.12", tox: py12-ipython8 }
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/setup-python@v4.3.0
- uses: actions/checkout@v4.0.0
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- run: python -m pip install --upgrade pip
allow-prereleases: true
- run: python -m pip install tox
- run: python -m tox -e${{ matrix.tox }}
- run: python -m tox -e ${{ matrix.tox }}
build:
name: Build package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install pypa/build
run: python -m pip install build
- name: Build a binary wheel and a source tarball
run: python -m build
- name: Install twine
run: python -m pip install twine
- name: Check build
run: python -m twine check --strict dist/*
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
# this duplicates pre-commit.ci, so only run it on tags
# it guarantees that linting is passing prior to a release
lint-pre-release:
name: lint
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/setup-python@v4.3.0
- uses: actions/checkout@v4.0.0
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: python -m pip install --upgrade pip
- run: python -m pip install tox
- run: python -m tox -elint
release:
needs: [tests, lint-pre-release]
publish-to-pypi:
name: PyPI release
if: startsWith(github.ref, 'refs/tags')
if: startsWith(github.ref, 'refs/tags/')
needs: [build, tests, lint-pre-release]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/doitlive
permissions:
id-token: write
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
- name: install requirements
run: python -m pip install build twine
- name: build dists
run: python -m build
- name: check package metadata
run: twine check dist/*
- name: publish
run: twine upload -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} dist/*
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
21 changes: 8 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/psf/black
rev: 23.12.1
- id: ruff
- id: ruff-format
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.3
hooks:
- id: black
language_version: python3
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear==23.12.2]
- id: check-github-workflows
- id: check-readthedocs
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2014-2024 Steven Loria and contributors
Copyright Steven Loria and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

4 changes: 2 additions & 2 deletions RELEASING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Releasing
=========

* Bump version in ``doitlive/__version__.py``.
* Update ``CHANGELOG.rst``.
* Bump version in ``pyproject.toml``.
* Update ``CHANGELOG.rst`` with today's date.
* Commit: ``git add . && git commit -m "Bump version and update changelog"``
* Tag: ``git tag x.y.z``
* Push (this will trigger a release to PyPI): ``git push --tags origin dev``
Expand Down
14 changes: 7 additions & 7 deletions docs/_themes/flask_theme_support.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# flasky extensions. flasky pygments style based on tango style
from pygments.style import Style
from pygments.token import (
Keyword,
Name,
Comment,
String,
Error,
Generic,
Keyword,
Literal,
Name,
Number,
Operator,
Generic,
Whitespace,
Punctuation,
Other,
Literal,
Punctuation,
String,
Whitespace,
)


Expand Down
11 changes: 4 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import sys
import importlib.metadata
import os
import datetime as dt

sys.path.insert(0, os.path.abspath(".."))
import doitlive # noqa: E402
import sys

sys.path.append(os.path.abspath("_themes"))

Expand All @@ -20,9 +17,9 @@

# General information about the project.
project = "doitlive"
copyright = f"2014-{dt.datetime.utcnow():%Y}"
copyright = "Steven Loria and contributors"

version = release = doitlive.__version__
version = release = importlib.metadata.version("doitlive")

exclude_patterns = ["_build"]
pygments_style = "flask_theme_support.FlaskyStyle"
Expand Down
1 change: 0 additions & 1 deletion doitlive/__version__.py

This file was deleted.

63 changes: 60 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
[tool.black]
line-length = 88
target-version = ['py38', 'py39', 'py310', 'py311', 'py312']
[project]
name = "doitlive"
version = "5.0.0"
description = "Because sometimes you need to do it live."
readme = "README.rst"
license = { file = "LICENSE" }
authors = [{ name = "Steven Loria", email = "[email protected]" }]
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Environment :: Console",
]
keywords = ["doitlive", "cli", "live", "coding", "presentations", "shell"]
requires-python = ">=3.8"
dependencies = [
"click>=8.0,<9",
"click-completion>=0.3.1",
"click-didyoumean>=0.0.3",
]

[project.urls]
Issues = "https://github.com/sloria/doitlive/issues"
Source = "https://github.com/sloria/doitlive/"

[project.optional-dependencies]
tests = ["pytest", "IPython>=8"]
docs = ["sphinx==7.2.6", "sphinx-issues==4.0.0"]
dev = ["doitlive[tests]", "tox", "pre-commit~=3.6"]

[build-system]
requires = ["flit_core<4"]
build-backend = "flit_core.buildapi"

[tool.flit.sdist]
include = ["tests/", "CONTRIBUTING.md", "tox.ini"]
exclude = ["docs/_build/"]

[tool.ruff]
src = ["src"]
fix = true
show-fixes = true
show-source = true

[tool.ruff.lint]
ignore = ["E203", "E266", "E501", "E731"]
select = [
"B", # flake8-bugbear
"E", # pycodestyle error
"F", # pyflakes
"I", # isort
"UP", # pyupgrade
"W", # pycodestyle warning
]
11 changes: 0 additions & 11 deletions setup.cfg

This file was deleted.

85 changes: 0 additions & 85 deletions setup.py

This file was deleted.

12 changes: 4 additions & 8 deletions doitlive/__init__.py → src/doitlive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@
A tool for "live" presentations in the terminal.
"""
from .cli import SessionState
from .python_consoles import PythonRecorderConsole, PythonPlayerConsole
from .styling import THEMES, Style, TermString, TTY, echo, echo_prompt, format_prompt
from .keyboard import wait_for, magictype, magicrun, ESC, BACKSPACE, CTRLC, RETURNS
from .exceptions import ConfigurationError, DoItLiveError, SessionError
from .keyboard import BACKSPACE, CTRLC, ESC, RETURNS, magicrun, magictype, wait_for
from .python_consoles import PythonPlayerConsole, PythonRecorderConsole
from .styling import THEMES, TTY, Style, TermString, echo, echo_prompt, format_prompt
from .version_control import (
get_current_git_branch,
get_current_hg_branch,
get_current_vcs_branch,
)
from .exceptions import DoItLiveError, ConfigurationError, SessionError
from .__version__ import __version__

__author__ = "Steven Loria"
__license__ = "MIT"
__version__ = __version__
__all__ = [
"SessionState",
"PythonRecorderConsole",
Expand Down
Loading

0 comments on commit ff3c796

Please sign in to comment.