Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiebergman committed Aug 16, 2022
1 parent b922853 commit 598a089
Show file tree
Hide file tree
Showing 37 changed files with 208 additions and 1,069 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ permissions:
contents: write

env:
name: <<name>>
name: mf-prior-bench

jobs:
build-and-deploy:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ on:

env:

package-name: <<package-name>>
package-name: mfp_bench
test-dir: tests
extra-requires: "[dev]" # "" for no extra_requires

Expand Down Expand Up @@ -84,8 +84,7 @@ jobs:
exit 1
fi
<<requires::packaging
# Testing with conda
# Testing with conda
conda-tests:
name: conda-${{ matrix.python-version }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -159,4 +158,3 @@ jobs:
- name: Tests
run: |
pytest ${{ env.pytest-args }} ${{ env.test-dir }}
endrequires::packaging>>
File renamed without changes.
38 changes: 38 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# If you see me, please update my `rev` field using the provided links
# Click the repo and update to latest tags.
# If things break on update, raise an issue
repos:
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort imports mfp_bench
files: mfp_bench

- id: isort
name: isort imports tests
files: tests

- repo: https://github.com/ambv/black
rev: 22.1.0
hooks:
- id: black
name: black formatter mfp_bench
files: mfp_bench

- id: black
name: black formatter tests
files: tests

- id: black
name: black formatter examples
files: examples

- repo: https://github.com/pycqa/pydocstyle
rev: 6.1.1
hooks:
- id: pydocstyle
files: mfp_bench
additional_dependencies: ["toml"] # Needed to parse pyproject.toml


File renamed without changes.
8 changes: 3 additions & 5 deletions _templates/MANIFEST.in → MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
# https://packaging.python.org/en/latest/guides/using-manifest-in/

# Include individual files
<<requires::license include LICENSE.txt endrequires::license>>
include LICENSE.txt
include requirements.txt
<<requires::mypy include <<package-name>>/py.typed # This file is to export types endrequires::mypy>>

<<requires::testing prune tests endrequires::testing>>
<<requires::docs prune examples endrequires::docs>>
prune tests
prune examples
120 changes: 120 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# These have been configured to only really run short tasks. Longer form tasks
# are usually completed in github actions.

NAME := mf-prior-bench
PACKAGE_NAME := mfp_bench

DIR := "${CURDIR}"
SOURCE_DIR := ${PACKAGE_NAME}
DIST := dist
DOCDIR := docs
INDEX_HTML := "file://${DIR}/docs/build/html/index.html"
EXAMPLES_DIR := examples
TESTS_DIR := tests

.PHONY: help install-dev check format pre-commit clean docs clean-doc examples clean-build build publish test

help:
@echo "Makefile ${NAME}"
@echo "* install-dev to install all dev requirements and install pre-commit"
@echo "* clean to clean any doc or build files"
@echo "* check to check the source code for issues"
@echo "* format to format the code with black and isort"
@echo "* pre-commit to run the pre-commit check"
@echo "* build to build a dist"
@echo "* docs to generate and view the html files, checks links"
@echo "* examples to run and generate the examples"
@echo "* publish to help publish the current branch to pypi"
@echo "* test to run the tests"

PYTHON ?= python
PYTEST ?= python -m pytest
PIP ?= python -m pip
MAKE ?= make
BLACK ?= black
ISORT ?= isort
PYDOCSTYLE ?= pydocstyle
PRECOMMIT ?= pre-commit
install-dev:
$(PIP) install -e ".[dev]"
pre-commit install

check-black:
$(BLACK) ${SOURCE_DIR} --check || :
$(BLACK) ${EXAMPLES_DIR} --check || :
$(BLACK) ${TESTS_DIR} --check || :

check-isort:
$(ISORT) ${SOURCE_DIR} --check || :
$(ISORT) ${TESTS_DIR} --check || :

check-pydocstyle:
$(PYDOCSTYLE) ${SOURCE_DIR} || :

check: check-black check-isort check-pydocstyle

pre-commit:
$(PRECOMMIT) run --all-files

format-black:
$(BLACK) ${SOURCE_DIR}
$(BLACK) ${TESTS_DIR}
$(BLACK) ${EXAMPLES_DIR}

format-isort:
$(ISORT) ${SOURCE_DIR}
$(ISORT) ${TESTS_DIR}

format: format-black format-isort

test:
$(PYTEST) ${TESTS_DIR}

clean-doc:
$(MAKE) -C ${DOCDIR} clean

docs:
$(MAKE) -C ${DOCDIR} docs
@echo
@echo "View docs at:"
@echo ${INDEX_HTML}

examples:
$(MAKE) -C ${DOCDIR} examples
@echo
@echo "View docs at:"
@echo ${INDEX_HTML}

clean-build:
$(PYTHON) setup.py clean
rm -rf ${DIST}

# Build a distribution in ./dist
build:
$(PYTHON) setup.py sdist

# Publish to testpypi
# Will echo the commands to actually publish to be run to publish to actual PyPi
# This is done to prevent accidental publishing but provide the same conveniences
publish: clean build
read -p "Did you update the version number?"

$(PIP) install twine
$(PYTHON) -m twine upload --repository testpypi ${DIST}/*
@echo
@echo "Test with the following:"
@echo "* Create a new virtual environment to install the uplaoded distribution into"
@echo "* Run the following:"
@echo
@echo " pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ ${NAME}"
@echo
@echo "* Run this to make sure it can import correctly, plus whatever else you'd like to test:"
@echo
@echo " python -c 'import ${PACKAGE_NAME}'"
@echo
@echo "Once you have decided it works, publish to actual pypi with"
@echo
@echo " python -m twine upload dist/*"

# Clean up any builds in ./dist as well as doc, if present
clean: clean-build clean-doc
Loading

0 comments on commit 598a089

Please sign in to comment.