Skip to content

Commit 30cdac4

Browse files
authored
Switch to pyproject.toml and Hatch build (mkdocs#2988)
1 parent 12ee265 commit 30cdac4

File tree

8 files changed

+111
-118
lines changed

8 files changed

+111
-118
lines changed

.flake8

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length = 119
3+
extend-ignore = E203

.github/workflows/deploy-release.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ jobs:
1414
- name: Setup Python
1515
uses: actions/setup-python@v2
1616
with:
17-
python-version: 3.7
17+
python-version: 3.9
1818
- name: Install dependencies
1919
run: |
20-
python -m pip install --upgrade pip setuptools wheel babel
20+
python -m pip install -U hatch babel
2121
- name: Compile localization message files
2222
run: |
2323
pybabel compile --statistics --directory mkdocs/themes/mkdocs/locales
2424
pybabel compile --statistics --directory mkdocs/themes/readthedocs/locales
2525
- name: Build
2626
run: |
27-
python setup.py bdist_wheel sdist --formats gztar
27+
hatch build
2828
- name: Publish
29-
if: success()
30-
uses: pypa/gh-action-pypi-publish@v1.4.1
31-
with:
32-
user: __token__
33-
password: ${{ secrets.PYPI_PASSWORD }}
29+
run: |
30+
hatch publish
31+
env:
32+
HATCH_INDEX_USER: __token__
33+
HATCH_INDEX_AUTH: ${{ secrets.PYPI_PASSWORD }}

MANIFEST.in

-5
This file was deleted.

docs/about/contributing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ updated by running the `extract_messages` command. For example, to update the
9090
`pot` file of the `mkdocs` theme, run the following command:
9191

9292
```bash
93-
pybabel extract --project=MkDocs --copyright-holder=MkDocs --msgid-bugs-address='https://github.com/mkdocs/mkdocs/issues' --no-wrap --version="$(grep -Eo "\\b[123][^']+" mkdocs/__init__.py)" --mapping-file mkdocs/themes/babel.cfg --output-file mkdocs/themes/mkdocs/messages.pot mkdocs/themes/mkdocs
93+
pybabel extract --project=MkDocs --copyright-holder=MkDocs --msgid-bugs-address='https://github.com/mkdocs/mkdocs/issues' --no-wrap --version="$(hatch version)" --mapping-file mkdocs/themes/babel.cfg --output-file mkdocs/themes/mkdocs/messages.pot mkdocs/themes/mkdocs
9494
```
9595

9696
The updated `pot` file should be included in a PR with the updated template.

pyproject.toml

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "mkdocs"
7+
description = "Project documentation with Markdown."
8+
readme = "README.md"
9+
license = "BSD-2-Clause"
10+
authors = [
11+
{name = "Tom Christie", email = "[email protected]"},
12+
]
13+
classifiers = [
14+
"Development Status :: 5 - Production/Stable",
15+
"Environment :: Console",
16+
"Environment :: Web Environment",
17+
"Intended Audience :: Developers",
18+
"License :: OSI Approved :: BSD License",
19+
"Operating System :: OS Independent",
20+
"Programming Language :: Python",
21+
"Programming Language :: Python :: 3",
22+
"Programming Language :: Python :: 3.7",
23+
"Programming Language :: Python :: 3.8",
24+
"Programming Language :: Python :: 3.9",
25+
"Programming Language :: Python :: 3.10",
26+
"Programming Language :: Python :: 3 :: Only",
27+
"Programming Language :: Python :: Implementation :: CPython",
28+
"Programming Language :: Python :: Implementation :: PyPy",
29+
"Topic :: Documentation",
30+
"Topic :: Text Processing",
31+
]
32+
dynamic = ["version"]
33+
requires-python = ">=3.7"
34+
dependencies = [
35+
"click >=7.0",
36+
"Jinja2 >=2.11.1",
37+
"Markdown >=3.2.1, <3.4",
38+
"PyYAML >=5.1",
39+
"watchdog >=2.0",
40+
"ghp-import >=1.0",
41+
"pyyaml_env_tag >=0.1",
42+
"importlib_metadata >=4.3; python_version < '3.10'",
43+
"typing_extensions >=3.10; python_version < '3.8'",
44+
"packaging >=20.5",
45+
"mergedeep >=1.3.4",
46+
"colorama >=0.4; platform_system == 'Windows'",
47+
]
48+
[project.optional-dependencies]
49+
i18n = [
50+
"babel >=2.9.0",
51+
]
52+
53+
[project.urls]
54+
Documentation = "https://www.mkdocs.org/"
55+
Source = "https://github.com/mkdocs/mkdocs"
56+
Issues = "https://github.com/mkdocs/mkdocs/issues"
57+
History = "https://www.mkdocs.org/about/release-notes/"
58+
59+
[project.scripts]
60+
mkdocs = "mkdocs.__main__:cli"
61+
62+
[project.entry-points."mkdocs.themes"]
63+
mkdocs = "mkdocs.themes.mkdocs"
64+
readthedocs = "mkdocs.themes.readthedocs"
65+
66+
[project.entry-points."mkdocs.plugins"]
67+
search = "mkdocs.contrib.search:SearchPlugin"
68+
69+
[tool.hatch.version]
70+
path = "mkdocs/__init__.py"
71+
72+
[tool.hatch.build]
73+
artifacts = ["/mkdocs/**/*.mo"]
74+
[tool.hatch.build.targets.sdist]
75+
include = ["/mkdocs"]
76+
[tool.hatch.build.targets.wheel]
77+
exclude = ["/mkdocs/tests/integration", "*.po", "*.pot", "babel.cfg"]
78+
79+
[tool.black]
80+
line-length = 100
81+
target-version = ["py37"]
82+
skip-string-normalization = true
83+
84+
[tool.isort]
85+
profile = "black"
86+
line_length = 100
87+
88+
[tool.mypy]
89+
ignore_missing_imports = true
90+
warn_unreachable = true
91+
no_implicit_optional = true
92+
show_error_codes = true

setup.cfg

-16
This file was deleted.

setup.py

100755100644
+5-87
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,13 @@
1-
#!/usr/bin/env python
1+
"""Installation using setup.py is no longer supported.
2+
Use `python -m pip install .` instead."""
23

3-
from setuptools import setup
4-
import re
5-
import os
64
import sys
75

6+
from setuptools import setup
87

9-
with open('README.md') as f:
10-
long_description = f.read()
11-
12-
13-
def get_version(package):
14-
"""Return package version as listed in `__version__` in `init.py`."""
15-
with open(os.path.join(package, '__init__.py')) as f:
16-
init_py = f.read()
17-
return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
18-
19-
20-
def get_packages(package):
21-
"""Return root package and all sub-packages."""
22-
return [dirpath
23-
for dirpath, dirnames, filenames in os.walk(package)
24-
if os.path.exists(os.path.join(dirpath, '__init__.py'))]
25-
8+
sys.exit(__doc__)
269

10+
# Fake reference so GitHub still considers it a real package for statistics purposes.
2711
setup(
2812
name="mkdocs",
29-
version=get_version("mkdocs"),
30-
url='https://www.mkdocs.org',
31-
project_urls={
32-
'Source': 'https://github.com/mkdocs/mkdocs',
33-
},
34-
license='BSD',
35-
description='Project documentation with Markdown.',
36-
long_description=long_description,
37-
long_description_content_type='text/markdown',
38-
author='Tom Christie',
39-
author_email='[email protected]', # SEE NOTE BELOW (*)
40-
packages=get_packages("mkdocs"),
41-
include_package_data=True,
42-
package_data={'mkdocs': ['py.typed']},
43-
install_requires=[
44-
'click>=7.0',
45-
'Jinja2>=2.11.1',
46-
'Markdown>=3.2.1,<3.4',
47-
'PyYAML>=5.1',
48-
'watchdog>=2.0',
49-
'ghp-import>=1.0',
50-
'pyyaml_env_tag>=0.1',
51-
'importlib_metadata>=4.3; python_version < "3.10"',
52-
'typing_extensions>=3.10; python_version < "3.8"',
53-
'packaging>=20.5',
54-
'mergedeep>=1.3.4',
55-
'colorama>=0.4; platform_system == "Windows"',
56-
],
57-
extras_require={"i18n": ['babel>=2.9.0']},
58-
python_requires='>=3.7',
59-
entry_points={
60-
'console_scripts': [
61-
'mkdocs = mkdocs.__main__:cli',
62-
],
63-
'mkdocs.themes': [
64-
'mkdocs = mkdocs.themes.mkdocs',
65-
'readthedocs = mkdocs.themes.readthedocs',
66-
],
67-
'mkdocs.plugins': [
68-
'search = mkdocs.contrib.search:SearchPlugin',
69-
],
70-
},
71-
classifiers=[
72-
'Development Status :: 5 - Production/Stable',
73-
'Environment :: Console',
74-
'Environment :: Web Environment',
75-
'Intended Audience :: Developers',
76-
'License :: OSI Approved :: BSD License',
77-
'Operating System :: OS Independent',
78-
'Programming Language :: Python',
79-
'Programming Language :: Python :: 3',
80-
'Programming Language :: Python :: 3.6',
81-
'Programming Language :: Python :: 3.7',
82-
'Programming Language :: Python :: 3.8',
83-
'Programming Language :: Python :: 3.9',
84-
'Programming Language :: Python :: 3.10',
85-
'Programming Language :: Python :: 3 :: Only',
86-
"Programming Language :: Python :: Implementation :: CPython",
87-
"Programming Language :: Python :: Implementation :: PyPy",
88-
'Topic :: Documentation',
89-
'Topic :: Text Processing',
90-
],
91-
zip_safe=False,
9213
)
93-
94-
# (*) Please direct queries to the discussion group:
95-
# https://groups.google.com/forum/#!forum/mkdocs

tox.ini

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[tox]
2+
isolated_build = true
23
envlist =
34
py{37,38,39,310,py3}-{unittests,min-req,integration,integration-no-babel},
45
black, isort, flake8, markdown-lint, linkchecker, jshint, csslint, nobabel, codespell
@@ -19,7 +20,7 @@ commands=
1920
[testenv:black]
2021
deps=black
2122
skip_install=true
22-
commands={envbindir}/black -l100 -tpy37 --skip-string-normalization mkdocs
23+
commands={envbindir}/black mkdocs
2324

2425
[testenv:isort]
2526
deps=isort

0 commit comments

Comments
 (0)