Skip to content

Commit

Permalink
Replace poetry by PEP-621 compliant pyproject.toml (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmarquis authored May 29, 2024
1 parent 24cecea commit 01edc76
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 692 deletions.
35 changes: 19 additions & 16 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,35 @@ on:
workflow_dispatch:
workflow_call:

env:
PYTHON_VERSION: '3.11'

jobs:
lint-and-test:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v3
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install dependencies
run: poetry install
- name: Lint markdown
run: poetry run mdwrap --fmt --check --ignore-extend tests .
python-version: ${{ matrix.PYTHON_VERSION }}
cache: 'pip'
- name: Install Python dependencies
run: |
python -m pip install -U pip
python -m pip install -r requirements-freeze.txt
- name: Lint with flake8
run: poetry run flake8
run: python -m flake8
- name: Lint with black
run: poetry run black --check .
run: python -m black --check .
- name: Lint with isort
run: poetry run isort --check .
run: python -m isort --check .
- name: Test with pytest
run: poetry run pytest
run: python -m pytest
- name: Build the package
run: poetry build
run: python -m build
20 changes: 11 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
tags:
- '*.*.*'

env:
PYTHON_VERSION: '3.11'

jobs:
lint-and-test:
name: Call Lint and Test
Expand All @@ -16,20 +19,19 @@ jobs:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v3
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'poetry'
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
- name: Build the package
run: poetry build
run: python -m build
- name: Check Version
id: check-version
run: |
[[ "$(poetry version --short)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo prerelease=true >> $GITHUB_OUTPUT
[[ "$(grep 'version =' pyproject.toml | sed 's/version = "\(.*\)"/\1/')" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo prerelease=true >> $GITHUB_OUTPUT
- name: Create Release
uses: ncipollo/release-action@v1
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ tests/integration/**/output.*

# OS Specific
.DS_Store

# Environments
.venv
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -9,7 +9,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
Expand All @@ -21,11 +21,11 @@ repos:
"flake8-implicit-str-concat",
]
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/csia-pme/mdwrap
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
32 changes: 14 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
- [Overview](#overview)
- [Pre-commit Hook](#pre-commit-hook)
- [Installation](#installation)
- [With pip](#with-pip)
- [With Poetry](#with-poetry)
- [Usage](#usage)
- [Arguments](#arguments)
- [Limitations](#limitations)
Expand Down Expand Up @@ -56,18 +54,11 @@ repos:
## Installation
### With pip
```bash
pip install git+https://github.com/csia-pme/[email protected]
```

### With Poetry

```bash
poetry add git+https://github.com/csia-pme/[email protected]
```

## Usage

```bash
Expand Down Expand Up @@ -119,33 +110,39 @@ blocks.

### Development

Firstly, install the pre-commit hooks:
Create and enable a virtual environment:

```bash
pre-commit install
python -m venv .venv
source .venv/bin/activate
```

Then, install the development dependencies:
Install the development dependencies:

```bash
poetry install
pip install .
```

Install the pre-commit hooks:

```bash
pre-commit install
```

### Testing

To run the tests:

```bash
poetry run pytest
pytest
```

### Linting

To lint the code:

```bash
poetry run flake8
poetry run black --check .
pre-commit run -a
```

### Releasing
Expand All @@ -156,7 +153,7 @@ poetry run black --check .

```bash
# Bump the version in pyproject.toml
poetry version <version>
sed -i 's/version = ".*"/version = "0.x.y"/' pyproject.toml
# Create a new tag
git tag <version> main
# Push the tag
Expand All @@ -172,7 +169,6 @@ git push origin <version>
This project is built with the following tools:

- [`pre-commit`](https://pre-commit.com/)
- [`poetry`](https://python-poetry.org/)
- [`pytest`](https://docs.pytest.org/)
- [`flake8`](https://flake8.pycqa.org/en/latest/)
- [`black`](https://black.readthedocs.io/en/stable/)
Expand Down
2 changes: 1 addition & 1 deletion mdwrap/utils/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def make_wide(formatter, w=80, h=36):
try:
# https://stackoverflow.com/a/5464440
# beware: "Only the name of this class is considered a public API."
kwargs = {'width': w, 'max_help_position': h}
kwargs = {"width": w, "max_help_position": h}
formatter(None, **kwargs)
return lambda prog: formatter(prog, **kwargs)
except TypeError:
Expand Down
Loading

0 comments on commit 01edc76

Please sign in to comment.