diff --git a/.github/workflows/regression-tests.yml b/.github/workflows/regression-tests.yml index 7b17a86c..74917ea3 100644 --- a/.github/workflows/regression-tests.yml +++ b/.github/workflows/regression-tests.yml @@ -27,9 +27,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install numpy scipy numpy_groupies pytest-cov coverage coveralls \ - sphinx_rtd_theme isort black pylint mypy - pip install . + python -m pip install coverage coveralls sphinx_rtd_theme + pip install ".[dev]" - name: Check auto-formatters run: | isort --check . diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..be20376a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,11 @@ +repos: + - repo: https://github.com/pycqa/isort + rev: 5.11.5 + hooks: + - id: isort + name: isort (python) + - repo: https://github.com/psf/black + rev: 23.3.0 + hooks: + - id: black + language_version: python diff --git a/CONTRIBUTOR_GUIDE.md b/CONTRIBUTOR_GUIDE.md index a7a123f2..f0c14f69 100644 --- a/CONTRIBUTOR_GUIDE.md +++ b/CONTRIBUTOR_GUIDE.md @@ -7,15 +7,15 @@ current or filing a new [issue](https://github.com/sandialabs/pyttb/issues). ## Working on PYTTB locally 1. clone your fork and enter the directory ``` - git clone git@github.com:/pyttb.git - cd pyttb + $ git clone git@github.com:/pyttb.git + $ cd pyttb ``` 1. setup your desired python environment as appropriate 1. install dependencies ``` - We use a mix of pyproject.toml, and setup.py currently. We are - still iterating on simplifying the setup procedure. + $ pip install -e ".[dev]" + $ make install_dev # shorthand for above ``` 1. Checkout a branch and make your changes @@ -25,9 +25,10 @@ current or filing a new [issue](https://github.com/sandialabs/pyttb/issues). 1. Formatters and linting 1. Run autoformatters from root of project (they will change your code) ```commandline - isort . - black . + $ isort . + $ black . ``` + 1. [We](./.pre-commit-config.yaml) optionally support [pre-commit hooks](https://pre-commit.com/) for this 1. Pylint and mypy coverage is work in progress (these only raise errors) ```commandline mypy pyttb/ diff --git a/Makefile b/Makefile index ff657774..6fe744d1 100644 --- a/Makefile +++ b/Makefile @@ -14,9 +14,24 @@ BUILDDIR = ./docs/build # Put it first so that "make" without argument is like "make help". help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + @echo "install: Install release build" + @echo "install_dev: Install dev build" + @echo "install_docs: Install docs build" + @echo "docs_help: Show additional docs commands" + +.PHONY: help install install_dev install_docs Makefile + +install: + python -m pip install -e . -.PHONY: help Makefile +install_dev: + python -m pip install -e ".[dev]" + +install_docs: + python -m pip install -e ".[doc]" + +docs_help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). diff --git a/pyproject.toml b/pyproject.toml index 11da1111..7dc4e04c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,22 @@ homepage = "https://github.com/sandialabs/pyttb" coverage = "https://coveralls.io/github/sandialabs/pyttb" documentation = "https://pyttb.readthedocs.io" +[project.optional-dependencies] +dev = [ + "black", + "isort", + "pylint", + "mypy", + "pytest", + "pytest-cov", +] +doc = [ + "sphinx_rtd_theme", +] + +[tool.setuptools] +packages=["pyttb"] + [build-system] requires = ["setuptools>=61.0", "numpy", "numpy_groupies", "scipy", "wheel"] build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py deleted file mode 100644 index 451f326a..00000000 --- a/setup.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2022 National Technology & Engineering Solutions of Sandia, -# LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the -# U.S. Government retains certain rights in this software. - -from setuptools import setup - -setup( - name="pyttb", - version="1.5.0", - packages=["pyttb"], - package_dir={"": "."}, - url="", - license="", - author="Daniel M. Dunlavy", - author_email="", - description="Python Tensor Toolbox", - install_requires=["numpy", "numpy_groupies", "scipy", "pytest", "sphinx_rtd_theme"], - extras_require={"testing": ["black", "isort", "pylint", "mypy"]}, -)