Skip to content

Commit

Permalink
maintain: set PEP621 metadata. move to src-layout
Browse files Browse the repository at this point in the history
  • Loading branch information
hukkin committed Dec 2, 2024
1 parent 86217c6 commit c6b8702
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 200 deletions.
13 changes: 13 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[bumpversion]
commit = True
tag = True
tag_name = v{new_version}
current_version = 1.0.0

[bumpversion:file:pyproject.toml]
search = version = "{current_version}" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT
replace = version = "{new_version}" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT

[bumpversion:file:src/mdformat_tables/__init__.py]
search = __version__ = "{current_version}"
replace = __version__ = "{new_version}"
9 changes: 9 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[flake8]
max-line-length = 88
max-complexity = 10
extend-ignore =
# E203: Whitespace before ':' (violates PEP8 and black style)
E203,
# A005: A module is shadowing a Python builtin module
A005,
extend-exclude = */site-packages/*
87 changes: 87 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CI

on:
push:
branches: [ master ]
tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ]
pull_request:
branches: [ master ]

jobs:

pre-commit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Run pre-commit
run: |
pipx run pre-commit run --all-files
tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Installation
run: |
pip install -r tests/requirements.txt .
- name: Run pytest
run: |
pytest --cov --cov-fail-under=100
pre-commit-hook:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Installation
run: |
pip install pre-commit
pip install .
- name: run pre-commit with plugin
run: |
pre-commit run --config .pre-commit-test.yaml --all-files --verbose --show-diff-on-failure
publish:
name: Publish to PyPi
needs: [pre-commit, tests, pre-commit-hook]
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install build and publish tools
run: |
pip install build twine
- name: Build and check
run: |
rm -rf dist/ && python -m build
twine check --strict dist/*
- name: Publish
run: |
twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_KEY }}
98 changes: 0 additions & 98 deletions .github/workflows/tests.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,8 @@ dmypy.json
# Pyre type checker
.pyre/

# IntelliJ
.idea/

# VS Code
.vscode/
54 changes: 2 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# mdformat-tables

[![Build Status][ci-badge]][ci-link]
[![codecov.io][cov-badge]][cov-link]
[![PyPI version][pypi-badge]][pypi-link]

An [mdformat](https://github.com/hukkin/mdformat) plugin for rendering tables.
Expand All @@ -26,56 +25,7 @@ to:

For further examples, see tests/fixtures.md in the repository.

## Development

This package utilises [flit](https://flit.readthedocs.io) as the build engine, and [tox](https://tox.readthedocs.io) for test automation.

To install these development dependencies:

```bash
pip install flit tox
```

To run the tests:

```bash
tox
```

To run the code formatting and style checks:

```bash
tox -e py311-pre-commit
```

or directly

```bash
pip install pre-commit
pre-commit run --all
```

To run the pre-commit hook test:

```bash
tox -e py311-hook
```

## Publish to PyPi

Either use flit directly:

```bash
flit publish
```

or trigger the GitHub Action job, by creating a release with a tag equal to the version, e.g. `v0.0.1`.

Note, this requires generating an API key on PyPi and adding it to the repository `Settings/Secrets`, under the name `PYPI_KEY`.

[ci-badge]: https://github.com/hukkin/mdformat-tables/actions/workflows/tests.yml/badge.svg?branch=master
[ci-link]: https://github.com/hukkin/mdformat/actions?query=workflow%3ACI+branch%3Amaster+event%3Apush
[cov-badge]: https://codecov.io/gh/hukkin/mdformat-tables/branch/master/graph/badge.svg
[cov-link]: https://codecov.io/gh/hukkin/mdformat-tables
[ci-badge]: https://github.com/hukkin/mdformat-tables/actions/workflows/tests.yaml/badge.svg?branch=master
[ci-link]: https://github.com/hukkin/mdformat-tables/actions?query=workflow%3ACI+branch%3Amaster+event%3Apush
[pypi-badge]: https://img.shields.io/pypi/v/mdformat-tables.svg
[pypi-link]: https://pypi.org/project/mdformat-tables
88 changes: 61 additions & 27 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
[build-system]
requires = ["flit_core >=2,<4"]
requires = ["flit_core>=3.2.0,<4"]
build-backend = "flit_core.buildapi"

[tool.flit.metadata]
module = "mdformat_tables"
author = "Chris Sewell"
author-email = "[email protected]"
maintainer = "Taneli Hukkinen"
maintainer-email = "[email protected]"
description-file = "README.md"
home-page = "https://github.com/hukkin/mdformat-tables"
[project]
name = "mdformat-tables"
version = "1.0.0" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT
authors = [
{ name = "Chris Sewell", email = "[email protected]"},
]
maintainers = [
{ name = "Taneli Hukkinen", email = "[email protected]"},
]
description = "Mdformat plugin for rendering tables"
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.9"
dependencies = [
'mdformat >=0.7.19,<0.8.0',
'wcwidth >=0.2.13',
]
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Documentation",
"Topic :: Text Processing :: Markup",
]
keywords = "mdformat,markdown,markdown-it"

requires-python=">=3.9"
requires=["mdformat>=0.7.19,<0.8.0", "wcwidth>=0.2.13"]
keywords = ["mdformat", "markdown", "formatter", "gfm"]

[tool.flit.metadata.requires-extra]
test = [
"pytest~=6.0",
"coverage",
"pytest-cov",
]
[project.urls]
"Homepage" = "https://github.com/hukkin/mdformat-tables"

[tool.flit.entrypoints."mdformat.parser_extension"]
tables = "mdformat_tables"
[project.entry-points."mdformat.parser_extension"]
"tables" = "mdformat_tables"

[tool.flit.sdist]
include = []
exclude = [".github/", "tests/"]

[tool.isort]
# Force imports to be sorted by module, independent of import type
Expand All @@ -46,3 +44,39 @@ known_first_party = ["mdformat_tables", "tests"]

# Settings for Black compatibility
profile = "black"


[tool.pytest.ini_options]
addopts = "--strict-markers --strict-config"
xfail_strict = true


[tool.tox]
requires = ["tox>=4.21.1"]
# Only run pytest envs when no args given to tox
env_list = ["3.9", "3.10", "3.11", "3.12", "3.13"]

[tool.tox.env_run_base]
description = "run tests under {base_python}"
deps = [
"-r tests/requirements.txt",
]
commands = [
["pytest", { replace = "posargs", default = ["--cov", "--cov-fail-under", "100"], extend = true }],
]

[tool.tox.env."pre-commit"]
description = "run linters"
skip_install = true
deps = ["pre-commit"]
commands = [
["pre-commit", "run", { replace = "posargs", default = ["--all-files"], extend = true }],
]

[tool.tox.env."hook"]
description = "test unreleased changes via pre-commit hook"
skip_install = true
deps = ["pre-commit"]
commands = [
["pre-commit", "run", "--config", ".pre-commit-test.yaml", { replace = "posargs", default = ["--all-files", "--verbose", "--show-diff-on-failure"], extend = true }],
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"""An mdformat plugin for rendering tables."""

__version__ = "1.0.0"

from .plugin import ( # noqa: F401
Expand Down
File renamed without changes.
Loading

0 comments on commit c6b8702

Please sign in to comment.