From c101ec41818641a569800827fb8c674aa15b7abc Mon Sep 17 00:00:00 2001 From: Andy Shapiro Date: Mon, 24 Jul 2023 22:22:19 -0400 Subject: [PATCH] move requirements to pyproject.toml (#4) * move requirements to pyproject.toml * update caching * edit mode * check cache * coverage report * pin linting versions --- .github/workflows/dev-enviro.yml | 13 +++---------- .github/workflows/test.yml | 25 ++++++------------------- .gitignore | 1 + HISTORY.md | 2 +- MANIFEST.in | 2 -- README.md | 8 +++----- make.bat | 2 +- pyproject.toml | 11 ++++++++++- requirements_dev.txt | 13 ------------- tests/test_work.py | 8 +++++++- 10 files changed, 32 insertions(+), 53 deletions(-) delete mode 100644 MANIFEST.in delete mode 100644 requirements_dev.txt diff --git a/.github/workflows/dev-enviro.yml b/.github/workflows/dev-enviro.yml index c650b59..a82e1a8 100644 --- a/.github/workflows/dev-enviro.yml +++ b/.github/workflows/dev-enviro.yml @@ -2,7 +2,6 @@ name: Test development environments on: workflow_dispatch: - pull_request: push: branches: - main @@ -21,17 +20,11 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - name: try to restore pip cache - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('setup.py', 'requirements_dev.txt') }} - restore-keys: | - ${{ runner.os }}-pip- + cache: 'pip' - name: Install dependencies run: | - python -m pip install -U pip wheel - python -m pip install -r requirements_dev.txt + python -m pip install -U pip + python -m pip install -e ".[dev]" - name: Check all Makefile commands run: | make clean diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9623c83..fa59f7c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,32 +20,19 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - name: Restore pip cache (Linux) - uses: actions/cache@v3 - if: startsWith(runner.os, 'Linux') - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg', 'requirements_dev.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - name: Restore pip cache (Windows) - uses: actions/cache@v3 - if: startsWith(runner.os, 'Windows') - with: - path: ~\AppData\Local\pip\Cache - key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg', 'requirements_dev.txt') }} - restore-keys: | - ${{ runner.os }}-pip- + cache: 'pip' - name: Install dependencies run: | - python -m pip install -U pip wheel - python -m pip install -r requirements_dev.txt + python -m pip install -U pip + python -m pip install -e ".[dev]" - name: Check linting run: | make lint - name: Test with pytest run: | - make test + coverage run -m pytest + echo "# Python coverage report" >> $GITHUB_STEP_SUMMARY + coverage report --format=markdown >> $GITHUB_STEP_SUMMARY - name: Build a wheel run: | make build diff --git a/.gitignore b/.gitignore index 352c7a8..f8bd039 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ .ipynb_checkpoints/ .mypy_cache/ .pytest_cache/ +.ruff_cache/ .tox/ .vscode/ build/ diff --git a/HISTORY.md b/HISTORY.md index 69eeb35..7cf3b19 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,5 @@ # History -## v0.0.1 (2022-07-15) +## v0.0.1 (2023-07-24) * Initial release diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index ca446cc..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-exclude * __pycache__ -recursive-exclude * *.py[co] diff --git a/README.md b/README.md index 263eed8..6a9ea78 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,7 @@ Make sure you have python 3.11 available and on your path. Then: # update pip python -m pip install -U pip -# if it's local file... -pip install path/to/pyscaffold-0.0.1-py3-none-any.whl -# if it's on github somewhere... +# if it's local file or a github link... pip install path/to/pyscaffold-0.0.1-py3-none-any.whl # if it's on pypi pip install pyscaffold @@ -35,7 +33,7 @@ pip install pyscaffold pyscaffold --help pyscaffold hello pyscaffold hello --name Andy -pyscaffold bottles -n 10 +pyscaffold bottles --num 20 ``` ## Developer setup @@ -51,7 +49,7 @@ source venv/bin/activate # or venv\Scripts\activate on windows. # install packages python -m pip install -U pip -pip install -r requirements_dev.txt +pip install -e ".[dev]" # test local install pyscaffold hello diff --git a/make.bat b/make.bat index ba3a3d3..7b30447 100644 --- a/make.bat +++ b/make.bat @@ -23,7 +23,7 @@ black . --check && ruff . goto :eof :format -black . && ruff . --fix +black . && ruff . --fix --show-fixes goto :eof :test diff --git a/pyproject.toml b/pyproject.toml index faba072..a54677c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["flit_core >=3.2,<4"] +requires = ["flit_core >=3.9,<4"] build-backend = "flit_core.buildapi" [project] @@ -20,6 +20,15 @@ dependencies = [ "typer", ] +[project.optional-dependencies] +dev = [ + "flit~=3.9.0", + "coverage~=7.2.7", + "pytest~=7.4.0", + "black==23.7.0", + "ruff==0.0.280", +] + [project.urls] Home = "https://github.com/shapiromatron/pyscaffold" Changes = "https://github.com/shapiromatron/pyscaffold/blob/main/HISTORY.md" diff --git a/requirements_dev.txt b/requirements_dev.txt deleted file mode 100644 index db95542..0000000 --- a/requirements_dev.txt +++ /dev/null @@ -1,13 +0,0 @@ -# build -flit==3.8.0 - -# tests -coverage==7.2.3 -pytest==7.3.0 - -# lint and formatting tools -black==23.3.0 -ruff==0.0.261 - -# install package in editable mode --e . diff --git a/tests/test_work.py b/tests/test_work.py index c7244e3..2f2a5b3 100644 --- a/tests/test_work.py +++ b/tests/test_work.py @@ -1,6 +1,12 @@ import pytest -from pyscaffold.work import super_add +from pyscaffold.work import bottles, super_add + + +def test_bottles(capsys): + bottles(1, "pepsi") + captured = capsys.readouterr() + assert "1 bottles of pepsi on the wall" in captured.out def test_super_add():