Skip to content

Commit

Permalink
⚡ Move over to using rye instead of pipenv
Browse files Browse the repository at this point in the history
Lots of moving files around, new Makefile, new pyproject.toml, etc. Also
some mild reformatting of the code due to switching from black to ruff.
  • Loading branch information
davep committed Nov 23, 2024
1 parent 316ac26 commit db6bc6d
Show file tree
Hide file tree
Showing 34 changed files with 241 additions and 914 deletions.
19 changes: 8 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 5.12.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.4
hooks:
- id: isort
name: isort (python)
language_version: '3.11'
args: ["--profile", "black", "--filter-files"]
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
language_version: python3.11
# Run the linter.
- id: ruff
args: [ --fix, --select, I ]
# Run the formatter.
- id: ruff-format
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.4
107 changes: 37 additions & 70 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,104 +1,71 @@
###############################################################################
# Common make values.
lib := quizzical
run := pipenv run
app := quizzical
src := src/
run := rye run
test := rye test
python := $(run) python
lint := $(run) pylint
lint := rye lint -- --select I
fmt := rye fmt
mypy := $(run) mypy
twine := $(run) twine
build := $(python) -m build
black := $(run) black

##############################################################################
# Run the app.
# Local "interactive testing" of the code.
.PHONY: run
run:
$(python) -m $(lib)

.PHONY: debug
debug:
TEXTUAL=devtools make

.PHONY: console
console:
$(run) textual console
run: # Run the code in a testing context
$(python) -m $(app)

##############################################################################
# Setup/update packages the system requires.
.PHONY: setup
setup: # Install all dependencies
pipenv sync --dev
setup: # Set up the repository for development
rye sync
$(run) pre-commit install

.PHONY: resetup
resetup: # Recreate the virtual environment from scratch
rm -rf $(shell pipenv --venv)
pipenv sync --dev

.PHONY: depsoutdated
depsoutdated: # Show a list of outdated dependencies
pipenv update --outdated

.PHONY: depsupdate
depsupdate: # Update all dependencies
pipenv update --dev

.PHONY: depsshow
depsshow: # Show the dependency graph
pipenv graph
rm -rf .venv
make setup

##############################################################################
# Checking/testing/linting/etc.
.PHONY: lint
lint: # Run Pylint over the library
$(lint) $(lib)
lint: # Check the code for linting issues
$(lint) $(src)

.PHONY: codestyle
codestyle: # Is the code formatted correctly?
$(fmt) --check $(src)

.PHONY: typecheck
typecheck: # Perform static type checks with mypy
$(mypy) --scripts-are-modules $(lib)
$(mypy) --scripts-are-modules $(src)

.PHONY: stricttypecheck
stricttypecheck: # Perform a strict static type checks with mypy
$(mypy) --scripts-are-modules --strict $(lib)

.PHONY: checkall
checkall: lint stricttypecheck # Check all the things
$(mypy) --scripts-are-modules --strict $(src)

##############################################################################
# Package/publish.
.PHONY: package
package: # Package the library
$(build) -w

.PHONY: spackage
spackage: # Create a source package for the library
$(build) -s

.PHONY: packagecheck
packagecheck: package spackage # Check the packaging.
$(twine) check dist/*

.PHONY: testdist
testdist: packagecheck # Perform a test distribution
$(twine) upload --skip-existing --repository testpypi dist/*
.PHONY: test
test: # Run the unit tests
$(test) -v

.PHONY: dist
dist: packagecheck # Upload to pypi
$(twine) upload --skip-existing dist/*
.PHONY: checkall
checkall: codestyle lint stricttypecheck test # Check all the things

##############################################################################
# Utility.
.PHONY: ugly
ugly: # Reformat the code with black.
$(black) $(lib)

.PHONY: repl
repl: # Start a Python REPL
repl: # Start a Python REPL in the venv.
$(python)

.PHONY: clean
clean: # Clean the build directories
rm -rf build dist $(lib).egg-info
.PHONY: delint
delint: # Fix linting issues.
$(lint) --fix $(src)

.PHONY: pep8ify
pep8ify: # Reformat the code to be as PEP8 as possible.
$(fmt) $(src)

.PHONY: tidy
tidy: delint pep8ify # Tidy up the code, fixing lint and format issues.

.PHONY: help
help: # Display this help
Expand Down
22 changes: 0 additions & 22 deletions Pipfile

This file was deleted.

Loading

0 comments on commit db6bc6d

Please sign in to comment.