Skip to content

Commit

Permalink
Merge branch 'release/v0.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
wpk committed Sep 20, 2023
2 parents 7241807 + a3d57fc commit 86a5fad
Show file tree
Hide file tree
Showing 43 changed files with 2,850 additions and 766 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/wpk-nist-gov/cookiecutter-pypackage.git",
"commit": "33236949f71e1d4dad788b8e98fa07716799825e",
"commit": "c58ff2e325176899b92f4fbd56584aa0ca478919",
"checkout": "feature/nox",
"context": {
"cookiecutter": {
Expand Down
90 changes: 50 additions & 40 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
# pre-commit install
# pre-commit run --all-files
# See https://pre-commit.com for more information
Expand All @@ -7,7 +6,7 @@ default_install_hook_types:
- pre-commit
- commit-msg
repos:
#* Top level
# * Top level
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
Expand All @@ -19,79 +18,67 @@ repos:
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
#* Formatting
# * sync dependencies
# Put this first, because messes up formatting
- repo: https://github.com/mxr/sync-pre-commit-deps
rev: v0.0.1
hooks:
- id: sync-pre-commit-deps

# * Prettier
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.3"
hooks:
- id: prettier
alias: markdownlint
stages: [commit]
additional_dependencies:
- prettier-plugin-toml
exclude: ^environment/lock/.*[.]yaml
#** markdown
exclude: ^environment/lock/.*[.]yml

# * Markdown
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.9.2
hooks:
- id: markdownlint-cli2
alias: markdownlint
args: ["--style prettier"]
#* Linting

# * Linting
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: "v0.0.287"
rev: "v0.0.289"
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 23.9.0
rev: 23.9.1
hooks:
# - id: black-jupyter
# Move to just black. use nbqa for notebook formatting
# NOTE: nbQA for notebook formatting
- id: black
- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
hooks:
- id: blacken-docs
additional_dependencies:
- black==23.9.0
- black==23.9.1
# exclude: ^README.md
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.0
hooks:
- id: nbqa-ruff
additional_dependencies: [ruff]
additional_dependencies: [ruff==0.0.289]
- id: nbqa-black
additional_dependencies: [black]
additional_dependencies: [black==23.9.1]

#* Commit message
# * Commit message
- repo: https://github.com/commitizen-tools/commitizen
rev: 3.8.1
rev: 3.9.0
hooks:
- id: commitizen
stages: [commit-msg]

#* Manual Linting
- repo: local
hooks:
- id: mypy
name: mypy
entry: tox
args: ["-e", "lint-mypy"]
language: system
pass_filenames: false
# additional_dependencies: [tox]
types: [python]
require_serial: true
stages: [manual]
- id: pyright
name: pyright
entry: pyright
args: []
language: system
pass_filenames: true
# additional_dependencies: [tox]
types: [python]
require_serial: true
stages: [manual]
# isort, pyupgrade, flake8 defer to ruff
# * Manual Linting ------------------------------------------------------------
# * isort, pyupgrade, flake8 defer to ruff
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
Expand Down Expand Up @@ -124,7 +111,7 @@ repos:
- id: nbqa-isort
additional_dependencies: [isort]
stages: [manual]
#** spelling
# ** spelling
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
hooks:
Expand All @@ -133,3 +120,26 @@ repos:
additional_dependencies: [tomli]
args: [-I, docs/spelling_wordlist.txt]
stages: [manual]

# - repo: local
# hooks:
# - id: mypy
# name: mypy
# entry: tox
# args: ["-e", "lint-mypy"]
# language: system
# pass_filenames: false
# # additional_dependencies: [tox]
# types: [python]
# require_serial: true
# stages: [manual]
# - id: pyright
# name: pyright
# entry: pyright
# args: []
# language: system
# pass_filenames: true
# # additional_dependencies: [tox]
# types: [python]
# require_serial: true
# stages: [manual]
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@ See the fragment files in

<!-- scriv-insert-here -->

## v0.6.0 — 2023-09-19

### Added

- Added `project` subcommand. This uses a configuration in `pyproject.toml` to
build multiple enivonments in one go.
- Added `--deps` and `--reqs` flags to include extra conda and pip requirements.
- Added `--overwrite` to check if output file exists.
- Now (correctly) using rich_click.
- Added tests for all new cases, and some edge cases.

## v0.5.1 — 2023-09-09

### Added

- Added `--sort/--no-sort` flag to cli. Default is to sort dependecies. This
- Added `--sort/--no-sort` flag to cli. Default is to sort dependencies. This
fixes issues with changing order in `pyproject.toml` leading to different yaml
files.

Expand Down
55 changes: 47 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ the search path, and the development environment will include the extras `dev`
and `nox` from the `project.optional-dependencies` section of the
`pyproject.toml` file in the development environment.
You can alos create this file using either of the following commands:
You can also create this file using either of the following commands:
```bash
nox -s config -- --python-paths "~/.conda/envs/test-3.*/bin" --dev-extras dev nox...
Expand All @@ -211,6 +211,28 @@ done
Also, set the variable `nox.python.paths` (see [](#setup-user-configuration)).
### See nox sessions/options
To see all nox session, run:
```bash
nox --list
```
We use [noxopt] to pass command line options to the different sessions. Use the
following to get help on these options:
```bash
nox -- --help
```
Note that these options should be passed _after_ `--`. For example, to build and
open the documentation, run:
```bash
nox -s docs -- -d build open
```
### Creating environment.yaml/requirement.txt files
The project is setup to create `environemt.yaml` and `requirement.txt` files
Expand Down Expand Up @@ -367,25 +389,36 @@ pipx run --spec git+https://github.com/wpk-nist-gov/nox-bootstrap.git \
nox -s bootstrap -- \
--python-paths "~/.conda/envs/test-3.*/bin" \
--dev-extras dev nox
```
This will, in isolation, install nox, and run the `bootstrap` session.
conda activate .nox/{project-name}/envs/dev
```
The above commands create a development environment located at
`.nox/{project-name}/envs/dev`.
where options `--python-paths` and `--dev-extras` are user specific. This will,
in isolation, install nox, and run the `bootstrap` session.
Note that nox environments are under `.nox/{project-name}/envs` instead of under
`.nox`. This fixes some issues with things like [nb_conda_kernels], as well as
other third party tools that expect conda environment to be located in a
directory like `.../miniforge/envs/env-name`.
If you go this route, you may want to use something like
[zsh-autoenv](https://github.com/Tarrasch/zsh-autoenv) (if using zsh shell) or
[autoenv](https://github.com/hyperupcall/autoenv) (if using bash) to auto
activate the development environment when in the parent directory.
### Conda create development environment
If instead you'd like to just install directly with conda, you can use:

```bash
conda env create [-n {env-name}] -f environment/py{version}-dev-base.yaml
conda activate {environment-name or -p path/to/environment}
conda env create [-n {env-name}] -f environment/py{version}-dev-complete.yaml
conda activate {env-name}
pip install -e . --no-deps
```

This installs all optional dependencies except those need to build the docs. For
that, please use nox.

### Development tools

[pipx]: https://github.com/pypa/pipx
Expand All @@ -406,16 +439,20 @@ conda activate {environment-name or -p path/to/environment}
[nb_conda_kernels]: https://github.com/Anaconda-Platform/nb_conda_kernels
[pyproject2conda]: https://github.com/usnistgov/pyproject2conda
[nbqa]: https://github.com/nbQA-dev/nbQA
[pyright]: https://github.com/microsoft/pyright

We recommend installing the following tools with [pipx] or [condax]. If you'd
like to install them in the development environment instead, include the
"extras" `tools` in the `nox.extras.dev` section of `config/userconfig.toml`
file:
file, or run:
```bash
nox -s config -- --dev-extras dev nox tools
```
Alternatively, you can just create a conda environment using the commands in
[](#conda-create-development-environment).
Additional tools are:
- [pre-commit]
Expand All @@ -426,6 +463,7 @@ Additional tools are:
- [pyproject2conda] (optional)
- [cog] (optional)
- [nbqa] (optional)
- [pyright] (recommended)
These are setup using the following:
Expand All @@ -438,6 +476,7 @@ pipx install scriv
condax/pipx install commitizen
condax/pipx install cogapp
condax/pipx install nbqa
condax/pipx install pyright
```
If you'd like to install a central [nox] to be used with this project, use one
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,4 @@ pytest-nbval: ## run pytest --nbval
.PHONY: cog-readme
cog-readme: ## apply cog to README.md
cog -rP README.md
pre-commit run markdownlint --files README.md
Loading

0 comments on commit 86a5fad

Please sign in to comment.