Skip to content

Commit

Permalink
feat: moved to nox instead of tox
Browse files Browse the repository at this point in the history
  • Loading branch information
wpk committed Jun 13, 2023
1 parent c5e67a9 commit 08ad3d0
Show file tree
Hide file tree
Showing 32 changed files with 1,941 additions and 336 deletions.
4 changes: 2 additions & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"template": "https://github.com/wpk-nist-gov/cookiecutter-pypackage.git",
"commit": "a0209ae199aa6f953364fc929e50d41d58082173",
"checkout": "feature/markdown",
"commit": "5ab45f3f6f1c3027d1c7b9e3e85a3d02217d4450",
"checkout": "feature/nox",
"context": {
"cookiecutter": {
"full_name": "William P. Krekelberg",
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
Expand Down Expand Up @@ -106,6 +107,8 @@ ENV/
pyrightconfig.json
.autoenv.zsh
.autoenv_leave.zsh
.noxconfig.toml
cruft.patch
/docs/**/generated/
/monkeytype.sqlite3
/dist-conda/
Expand Down
77 changes: 76 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ development.
make mamba-dev
```
This will create a conda environment 'module-utilities-env' in the default
This will create a conda environment 'module_utilities-env' in the default
location.
To install (an editable version) of the current package:
Expand Down Expand Up @@ -401,3 +401,78 @@ variables. So, we use grayskull to build the majority of the recipe, and append
the file `.recipe-append.yaml`. For some edge cases (install name different from
package name, etc), you'll need to manually edit this file to create the final
recipe.

## Using [nox] instead of [tox]

The repo is setup to use either [tox] or [nox]. One downside of using [tox] with
this particular workflow is the need for multiple scripts/makefiles, while with
[nox], most everything is self contained in the file `noxfile.py`. But both
tools are fantastic. To use nox, you'll need to bootstrap a development
environment. This can be done either by creating a seperate virtual env/conda
env or using condax/pipx. If using pipx, install the following:
```bash
pipx install nox
pipx inject nox ruamel.yaml
pipx inject nox noxopt
```
Note that if using condax, you'll need to do some extra work to install
[noxopt], as it is only available via pip. You can do it with the following:

```bash
condax install nox
condax inject nox ruamel.yaml
conda activate ~/.condax/nox
pip install noxopt
```

Alternatively, you can create an environment to bootstrap:

```bash
conda env create -n nox-bootstrap environment/nox-extras.yaml
conda activate nox-bootstrap
```

To create the merged environment files, run:

```bash
nox -s conda-merge -- [--conda-merge-force]
```

To create conda-lock files, run (experimental):

```bash
nox -s conda-lock -- [--conda-lock-force]
```

To run tests, use:

```bash
nox -s test
```

To run type checkers (mypy, etc) run:

```bash
nox -s typing -- [--typing-cmd mypy ]
```

To make docs, run:

```bash
nox -s docs -- [--docs-cmd clean html ...]
```

[nox]: https://github.com/wntrblm/nox
[noxopt]: https://github.com/rmorshea/noxopt

## Serving the documentation

To view to documentation with js headers/footers, you'll need to serve them:
```bash
python -m http.server -d docs/_build/html
```
Then open the address `localhost:8000` in a webbrowser.
32 changes: 16 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ enviornment/docs.yaml: ## docs environment yaml file


# special for linters
environment/lint.yaml: environment.yaml $(addsuffix .yaml, $(addprefix environment/, test-extras lint-extras)) ## mypy environment
environment/typing.yaml: environment.yaml $(addsuffix .yaml, $(addprefix environment/, test-extras typing-extras)) ## mypy environment
echo $^
conda-merge $^ > $@
$(PRETTIER) $@

ENVIRONMENTS += environment/lint.yaml
ENVIRONMENTS += environment/typing.yaml

.PHONY: environment-files-clean
environment-files-clean: ## clean all created environment/{dev,docs,test}.yaml
Expand Down Expand Up @@ -197,7 +197,7 @@ TOX=CONDA_EXE=mamba SETUPTOOLS_SCM_PRETEND_VERSION=$(version) tox $(tox_args)

.PHONY: tox-ipykernel-display-name
tox-ipykernel-display-name: ## Update display-name for any tox env with ipykernel
bash ./scripts/tox-ipykernel-display-name.sh module-utilities
bash ./scripts/tox-ipykernel-display-name.sh module_utilities

## dev env
.PHONY: dev-env
Expand Down Expand Up @@ -241,19 +241,19 @@ docs-linkcheck: ## check links
docs-build docs-release docs-command docs-clean docs-livehtml docs-linkcheck: environment/docs.yaml

## linting
.PHONY: lint-mypy lint-pyright lint-pytype lint-all lint-command
lint-mypy: ## run mypy mypy_args=...
$(TOX) -e lint -- mypy
lint-pyright: ## run pyright pyright_args=...
$(TOX) -e lint -- pyright
lint-pytype: ## run pytype pytype_args=...
$(TOX) -e lint -- pytype
lint-all:
$(TOX) -e lint -- all
lint-command:
$(TOX) -e lint -- command

lint-mypy lint-pyright lint-pytype lint-all lint-command: environment/lint.yaml
.PHONY: typing-mypy typing-pyright typing-pytype typing-all typing-command
typing-mypy: ## run mypy mypy_args=...
$(TOX) -e typing -- mypy
typing-pyright: ## run pyright pyright_args=...
$(TOX) -e typing -- pyright
typing-pytype: ## run pytype pytype_args=...
$(TOX) -e typing -- pytype
typing-all:
$(TOX) -e typing -- all
typing-command:
$(TOX) -e typing -- command

typing-mypy typing-pyright typing-pytype typing-all typing-command: environment/typing.yaml

## distribution
.PHONY: dist-pypi-build dist-pypi-testrelease dist-pypi-release dist-pypi-command
Expand Down
4 changes: 2 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
To install module-utilities, run this command in your terminal:

```bash
pip install module_utilities
pip install module-utilities
```

or

```bash
conda install -c conda-forge module_utilities
conda install -c conda-forge module-utilities
```

This is the preferred method to install module-utilities, as it will always
Expand Down
2 changes: 0 additions & 2 deletions environment.yaml → environment/base.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
name: module-utilities-env
channels:
- conda-forge
dependencies:
- python>=3.8
- typing-extensions
# cli
55 changes: 0 additions & 55 deletions environment/dev-extras.yaml

This file was deleted.

18 changes: 11 additions & 7 deletions environment/dev.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
channels:
- conda-forge
dependencies:
- ipykernel
- ipython
- pip
- python>=3.8
- typing-extensions
- pytest
- python-xdist
- pytest-cov
- pytest-xdist
- python>=3.8
- pytest-sugar
- mypy
- ipython
- ipykernel
- setuptools-scm
- typing-extensions
- nox
- ruamel.yaml
- pip
- pip:
- pytest-accept
name: module-utilities-env
- noxopt
3 changes: 3 additions & 0 deletions environment/dist-conda.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
channels:
- conda-forge
dependencies:
- python>=3.8
- anaconda-client
- grayskull
- conda-build
Expand Down
5 changes: 3 additions & 2 deletions environment/dist-pypi.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
channels:
- conda-forge
dependencies:
- setuptools>=61.2
- setuptools-scm>=7.0
- python>=3.8
- twine
- build
28 changes: 0 additions & 28 deletions environment/docs-extras.yaml

This file was deleted.

25 changes: 11 additions & 14 deletions environment/docs.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
channels:
- conda-forge
dependencies:
- ipython
- pip
- python>=3.8
- setuptools-scm
- typing-extensions
- pip:
- autodocsumm
- ghp-import
- myst-nb
- pyenchant
- sphinx
- sphinx-autobuild
- sphinx-book-theme
- sphinx-copybutton
- sphinxcontrib-spelling
name: module-utilities-env
- setuptools-scm
- ipython
- pyenchant
- ghp-import
- sphinx
- sphinx-copybutton
- sphinxcontrib-spelling
- sphinx-autobuild
- myst-nb
- sphinx-book-theme
- autodocsumm
5 changes: 0 additions & 5 deletions environment/lint-extras.yaml

This file was deleted.

5 changes: 5 additions & 0 deletions environment/lock/py310.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
channels:
- conda-forge
dependencies:
- python=3.10
- pip
5 changes: 5 additions & 0 deletions environment/lock/py311.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
channels:
- conda-forge
dependencies:
- python=3.11
- pip
5 changes: 5 additions & 0 deletions environment/lock/py38.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
channels:
- conda-forge
dependencies:
- python=3.8
- pip
5 changes: 5 additions & 0 deletions environment/lock/py39.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
channels:
- conda-forge
dependencies:
- python=3.9
- pip
2 changes: 0 additions & 2 deletions environment/test-extras.yaml

This file was deleted.

Loading

0 comments on commit 08ad3d0

Please sign in to comment.