Skip to content

Commit dc7c0af

Browse files
authored
Merge pull request #131 from eyeseast/123-uv
Migrate to uv and pyproject.toml
2 parents 3622432 + 1e787d8 commit dc7c0af

11 files changed

Lines changed: 1071 additions & 124 deletions

File tree

.github/workflows/publish.yml

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,28 @@ jobs:
1212
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
1313
steps:
1414
- uses: actions/checkout@v6
15-
- name: Set up Python ${{ matrix.python-version }}
16-
uses: actions/setup-python@v6
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v6
1717
with:
18+
enable-cache: true
1819
python-version: ${{ matrix.python-version }}
19-
- uses: actions/cache@v5
20-
name: Configure pip caching
21-
with:
22-
path: ~/.cache/pip
23-
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
24-
restore-keys: |
25-
${{ runner.os }}-pip-
2620
- name: Install dependencies
27-
run: |
28-
pip install -e '.[test]'
21+
run: uv sync
2922
- name: Run tests
30-
run: pytest
23+
run: uv run pytest
3124
deploy:
3225
runs-on: ubuntu-latest
3326
needs: [test]
27+
permissions:
28+
id-token: write
3429
steps:
3530
- uses: actions/checkout@v6
36-
- name: Set up Python
37-
uses: actions/setup-python@v6
38-
with:
39-
python-version: "3.13"
40-
- uses: actions/cache@v5
41-
name: Configure pip caching
31+
- name: Install uv
32+
uses: astral-sh/setup-uv@v6
4233
with:
43-
path: ~/.cache/pip
44-
key: ${{ runner.os }}-publish-pip-${{ hashFiles('**/setup.py') }}
45-
restore-keys: |
46-
${{ runner.os }}-publish-pip-
47-
- name: Install dependencies
48-
run: |
49-
pip install --upgrade setuptools wheel twine
34+
enable-cache: true
35+
36+
- name: Build
37+
run: uv build
5038
- name: Publish
51-
env:
52-
TWINE_USERNAME: __token__
53-
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
54-
run: |
55-
python setup.py sdist bdist_wheel
56-
twine upload --verbose dist/*
39+
run: uv publish

.github/workflows/test.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,14 @@ jobs:
1414
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
1515
steps:
1616
- uses: actions/checkout@v6
17-
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v6
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v6
1919
with:
20+
enable-cache: true
2021
python-version: ${{ matrix.python-version }}
21-
- uses: actions/cache@v5
22-
name: Configure pip caching
23-
with:
24-
path: ~/.cache/pip
25-
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
26-
restore-keys: |
27-
${{ runner.os }}-pip-
2822
- name: Install dependencies
29-
run: |
30-
pip install -e '.[test]'
23+
run: uv sync
3124
- name: Run tests
32-
run: |
33-
pytest . --doctest-modules --doctest-glob "README.md"
25+
run: uv run pytest . --doctest-modules --doctest-glob "README.md"
3426
- name: Run type checking
35-
run: |
36-
mypy .
27+
run: uv run mypy .

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

MANIFEST.in

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Python Frontmatter
22

3-
[Jekyll](http://jekyllrb.com/)-style YAML front matter offers a useful way to add arbitrary, structured metadata to text documents, regardless of type.
3+
[Front matter](https://docs.github.com/en/contributing/writing-for-github-docs/using-yaml-frontmatter) offers a useful way to add arbitrary, structured metadata to text documents, regardless of type.
44

55
This is a small package to load and parse files (or just text) with YAML (or JSON, TOML or other) front matter.
66

@@ -11,7 +11,16 @@ This is a small package to load and parse files (or just text) with YAML (or JSO
1111

1212
## Install:
1313

14-
pip install python-frontmatter
14+
```shell
15+
# with pip
16+
pip install python-frontmatter
17+
18+
# or uv
19+
uv add python-frontmatter
20+
21+
# local development, with uv
22+
uv sync
23+
```
1524

1625
## Usage:
1726

docs/conf.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,18 @@
4949
master_doc = "index"
5050

5151
# General information about the project.
52-
project = u"Python Frontmatter"
53-
copyright = u"2021, Chris Amico"
54-
author = u"Chris Amico"
52+
project = "Python Frontmatter"
53+
copyright = "2021, Chris Amico"
54+
author = "Chris Amico"
5555

5656
# The version info for the project you're documenting, acts as replacement for
5757
# |version| and |release|, also used in various other places throughout the
5858
# built documents.
5959
#
6060
# The short X.Y version.
61-
version = u"1.0.0"
61+
version = "1.3.0"
6262
# The full version, including alpha/beta/rc tags.
63-
release = u"1.0.0"
63+
release = "1.3.0"
6464

6565
# The language for content autogenerated by Sphinx. Refer to documentation
6666
# for a list of supported languages.
@@ -260,8 +260,8 @@
260260
(
261261
master_doc,
262262
"Frontmatter.tex",
263-
u"Frontmatter Documentation",
264-
u"Chris Amico",
263+
"Frontmatter Documentation",
264+
"Chris Amico",
265265
"manual",
266266
)
267267
]
@@ -303,7 +303,7 @@
303303

304304
# One entry per manual page. List of tuples
305305
# (source start file, name, description, authors, manual section).
306-
man_pages = [(master_doc, "frontmatter", u"Frontmatter Documentation", [author], 1)]
306+
man_pages = [(master_doc, "frontmatter", "Frontmatter Documentation", [author], 1)]
307307

308308
# If true, show URL addresses after external links.
309309
#
@@ -319,7 +319,7 @@
319319
(
320320
master_doc,
321321
"Frontmatter",
322-
u"Frontmatter Documentation",
322+
"Frontmatter Documentation",
323323
author,
324324
"Frontmatter",
325325
"One line description of project.",

docs/index.rst

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,28 @@ Python Frontmatter
88

99
.. module:: frontmatter
1010

11-
`Jekyll <http://jekyllrb.com/>`__-style YAML front matter offers a
12-
useful way to add arbitrary, structured metadata to text documents,
13-
regardless of type.
11+
`Front matter <https://docs.github.com/en/contributing/writing-for-github-docs/using-yaml-frontmatter>`__
12+
offers a useful way to add arbitrary, structured metadata to text
13+
documents, regardless of type.
1414

15-
This is a package to load and parse files (or text strings) with YAML
16-
front matter.
15+
This is a small package to load and parse files (or just text) with YAML
16+
(or JSON, TOML or other) front matter.
1717

1818

1919
Install
2020
--------
2121

22-
::
22+
.. code-block:: shell
2323
24+
# with pip
2425
pip install python-frontmatter
2526
27+
# or uv
28+
uv add python-frontmatter
29+
30+
# local development, with uv
31+
uv sync
32+
2633
Usage
2734
------
2835

@@ -50,6 +57,16 @@ Or load from text:
5057
>>> with open('tests/yaml/hello-world.txt') as f:
5158
... post = frontmatter.loads(f.read())
5259

60+
If the file has a `Byte-Order Mark <https://en.wikipedia.org/wiki/Byte_order_mark>`__
61+
(BOM), strip it off first. An easy way to do this is by using the
62+
`utf-8-sig <https://docs.python.org/3/library/codecs.html?highlight=utf%208%20sig#module-encodings.utf_8_sig>`__
63+
encoding:
64+
65+
::
66+
67+
>>> with open('tests/yaml/hello-world.txt', encoding="utf-8-sig") as f:
68+
... post = frontmatter.load(f)
69+
5370
Access content:
5471

5572
::
@@ -116,6 +133,11 @@ Or write to a file (or file-like object):
116133
---
117134
Well, hello there, world.
118135

136+
For more examples, see files in the ``tests/`` directory. Each sample
137+
file has a corresponding ``.result.json`` file showing the expected
138+
parsed output. See also the ``examples/`` directory, which covers more
139+
ways to customize input and output.
140+
119141

120142
.. toctree::
121143
:maxdepth: 2

pyproject.toml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[project]
2+
name = "python-frontmatter"
3+
version = "1.3.0"
4+
description = "Parse and manage posts with YAML (or other) frontmatter"
5+
readme = "README.md"
6+
authors = [{ name = "Chris Amico", email = "eyeseast@gmail.com" }]
7+
requires-python = ">=3.10"
8+
dependencies = ["PyYAML"]
9+
license = "MIT"
10+
license-files = ["LICENSE"]
11+
keywords = ["frontmatter"]
12+
classifiers = [
13+
"Development Status :: 5 - Production/Stable",
14+
"Intended Audience :: Developers",
15+
"Natural Language :: English",
16+
"Programming Language :: Python :: 3",
17+
"Programming Language :: Python :: 3.10",
18+
"Programming Language :: Python :: 3.11",
19+
"Programming Language :: Python :: 3.12",
20+
"Programming Language :: Python :: 3.13",
21+
]
22+
[project.urls]
23+
repository = "https://github.com/eyeseast/python-frontmatter"
24+
issues = "https://github.com/eyeseast/python-frontmatter/issues"
25+
documentation = "http://python-frontmatter.rtfd.io"
26+
27+
[project.optional-dependencies]
28+
test = ["pytest", "toml", "pyaml", "mypy", "types-PyYAML", "types-toml"]
29+
docs = ["sphinx"]
30+
toml = ["toml"]
31+
32+
[dependency-groups]
33+
dev = [
34+
"pytest",
35+
"toml",
36+
"pyaml",
37+
"mypy",
38+
"types-PyYAML",
39+
"types-toml",
40+
"sphinx",
41+
]
42+
43+
44+
[build-system]
45+
requires = ["uv_build>=0.11.15,<0.12"]
46+
build-backend = "uv_build"
47+
48+
[tool.uv.build-backend]
49+
module-root = ""
50+
module-name = "frontmatter"

requirements.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)