Skip to content

Commit

Permalink
chore: added pre-commit hooks to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wpk-nist-gov committed Jan 29, 2025
1 parent 3aeed57 commit 8a9ac89
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 11 deletions.
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ repos:
- id: commitizen
stages: [commit-msg]

# * pyproject2conda
- repo: .
rev: 20fa620bcb6427e160c0843104b7a20071430eec
hooks:
- id: pyproject2conda-project
alias: requirements

# * uv
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
Expand All @@ -105,6 +98,13 @@ repos:
- id: uv-lock
alias: lock

# * pyproject2conda
- repo: .
rev: 20fa620bcb6427e160c0843104b7a20071430eec
hooks:
- id: pyproject2conda-project
alias: requirements

# * all lock files
- repo: local
hooks:
Expand Down
43 changes: 39 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
[conda-link]: https://anaconda.org/conda-forge/pyproject2conda
[license-badge]: https://img.shields.io/pypi/l/cmomy?color=informational
[license-link]: https://github.com/usnistgov/pyproject2conda/blob/main/LICENSE
[pre-commit]: https://pre-commit.com/

<!-- other links -->

Expand All @@ -44,15 +45,45 @@ use poetry, I'd highly recommend [poetry2conda].

## Features

- Simple comment based syntax to add information to dependencies when creating
`environment.yaml`
- Automatic creation of `environment.yaml`and `requirements.txt` files from
`pyproject.toml`.
- Simple remapping of `pypi` package name to `conda` package name when creating
`environment.yaml` files.
- [pre-commit] hooks to automatically keep dependency files up to data.

## Status

This package is actively used by the author, but is still very much a work in
progress. Please feel free to create a pull request for wanted features and
suggestions!

## Pre-commit hooks

`pyproject2conda` works with [pre-commit]. Hooks are available for the
`project`, `yaml`, and `requirements` subcommands described below:

```yaml
- repo: https://github.com/usnistgov/pyproject2conda
rev: { version } # replace with current version
hooks:
- id: pyproject2conda-project
- id: pyproject2conda-yaml
- id: pyproject2conda-requirements
```
For `yaml` and `requirements`, you can override the default behavior (of
creating environment/requirement files from the `dependency-group` `dev`) by
passing in `args`. For example, you could use the following to create an
environment file with the extra `dev-complete`

```yaml
- repo: https://github.com/usnistgov/pyproject2conda
rev: { version } # replace with current version
hooks:
- id: pyproject2conda-yaml
args: ["-e", "dev-complete", "-o", "environment-dev.yaml"]
```

## Quick start

<!-- start-installation -->
Expand Down Expand Up @@ -287,9 +318,11 @@ dependencies:
<!-- [[[end]]] -->

Passing `--python="default"` will extract the python version from
`.python-version` file. Passign `--python` value `"lowest"` or `"highest"` will
`.python-version` file. Passing `--python` value `"lowest"` or `"highest"` will
extract the lowest or highest python version, respectively, from the
`project.classifiers` table of the `pyproject.toml` file.
`project.classifiers` table of the `pyproject.toml` file. Using the option
`python="all"` in `pyproject.toml` will include all python versions in the
`project.classifiers` table.

### Adding extra conda dependencies and pip requirements

Expand Down Expand Up @@ -507,6 +540,8 @@ dependencies:

<!-- [[[end]]] -->

You can customize the command in the header with the `--custom-command` option.

### Usage within python

`pyproject2conda` can also be used within python:
Expand Down

0 comments on commit 8a9ac89

Please sign in to comment.