Skip to content

Commit

Permalink
Switch to pyproject.toml and Hatch build (mkdocs#2988)
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypin authored Oct 6, 2022
1 parent 12ee265 commit 30cdac4
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 118 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 119
extend-ignore = E203
16 changes: 8 additions & 8 deletions .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel babel
python -m pip install -U hatch babel
- name: Compile localization message files
run: |
pybabel compile --statistics --directory mkdocs/themes/mkdocs/locales
pybabel compile --statistics --directory mkdocs/themes/readthedocs/locales
- name: Build
run: |
python setup.py bdist_wheel sdist --formats gztar
hatch build
- name: Publish
if: success()
uses: pypa/gh-action-pypi-publish@v1.4.1
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
run: |
hatch publish
env:
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.PYPI_PASSWORD }}
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion docs/about/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ updated by running the `extract_messages` command. For example, to update the
`pot` file of the `mkdocs` theme, run the following command:

```bash
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
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
```

The updated `pot` file should be included in a PR with the updated template.
Expand Down
92 changes: 92 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "mkdocs"
description = "Project documentation with Markdown."
readme = "README.md"
license = "BSD-2-Clause"
authors = [
{name = "Tom Christie", email = "[email protected]"},
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Documentation",
"Topic :: Text Processing",
]
dynamic = ["version"]
requires-python = ">=3.7"
dependencies = [
"click >=7.0",
"Jinja2 >=2.11.1",
"Markdown >=3.2.1, <3.4",
"PyYAML >=5.1",
"watchdog >=2.0",
"ghp-import >=1.0",
"pyyaml_env_tag >=0.1",
"importlib_metadata >=4.3; python_version < '3.10'",
"typing_extensions >=3.10; python_version < '3.8'",
"packaging >=20.5",
"mergedeep >=1.3.4",
"colorama >=0.4; platform_system == 'Windows'",
]
[project.optional-dependencies]
i18n = [
"babel >=2.9.0",
]

[project.urls]
Documentation = "https://www.mkdocs.org/"
Source = "https://github.com/mkdocs/mkdocs"
Issues = "https://github.com/mkdocs/mkdocs/issues"
History = "https://www.mkdocs.org/about/release-notes/"

[project.scripts]
mkdocs = "mkdocs.__main__:cli"

[project.entry-points."mkdocs.themes"]
mkdocs = "mkdocs.themes.mkdocs"
readthedocs = "mkdocs.themes.readthedocs"

[project.entry-points."mkdocs.plugins"]
search = "mkdocs.contrib.search:SearchPlugin"

[tool.hatch.version]
path = "mkdocs/__init__.py"

[tool.hatch.build]
artifacts = ["/mkdocs/**/*.mo"]
[tool.hatch.build.targets.sdist]
include = ["/mkdocs"]
[tool.hatch.build.targets.wheel]
exclude = ["/mkdocs/tests/integration", "*.po", "*.pot", "babel.cfg"]

[tool.black]
line-length = 100
target-version = ["py37"]
skip-string-normalization = true

[tool.isort]
profile = "black"
line_length = 100

[tool.mypy]
ignore_missing_imports = true
warn_unreachable = true
no_implicit_optional = true
show_error_codes = true
16 changes: 0 additions & 16 deletions setup.cfg

This file was deleted.

92 changes: 5 additions & 87 deletions setup.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,95 +1,13 @@
#!/usr/bin/env python
"""Installation using setup.py is no longer supported.
Use `python -m pip install .` instead."""

from setuptools import setup
import re
import os
import sys

from setuptools import setup

with open('README.md') as f:
long_description = f.read()


def get_version(package):
"""Return package version as listed in `__version__` in `init.py`."""
with open(os.path.join(package, '__init__.py')) as f:
init_py = f.read()
return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)


def get_packages(package):
"""Return root package and all sub-packages."""
return [dirpath
for dirpath, dirnames, filenames in os.walk(package)
if os.path.exists(os.path.join(dirpath, '__init__.py'))]

sys.exit(__doc__)

# Fake reference so GitHub still considers it a real package for statistics purposes.
setup(
name="mkdocs",
version=get_version("mkdocs"),
url='https://www.mkdocs.org',
project_urls={
'Source': 'https://github.com/mkdocs/mkdocs',
},
license='BSD',
description='Project documentation with Markdown.',
long_description=long_description,
long_description_content_type='text/markdown',
author='Tom Christie',
author_email='[email protected]', # SEE NOTE BELOW (*)
packages=get_packages("mkdocs"),
include_package_data=True,
package_data={'mkdocs': ['py.typed']},
install_requires=[
'click>=7.0',
'Jinja2>=2.11.1',
'Markdown>=3.2.1,<3.4',
'PyYAML>=5.1',
'watchdog>=2.0',
'ghp-import>=1.0',
'pyyaml_env_tag>=0.1',
'importlib_metadata>=4.3; python_version < "3.10"',
'typing_extensions>=3.10; python_version < "3.8"',
'packaging>=20.5',
'mergedeep>=1.3.4',
'colorama>=0.4; platform_system == "Windows"',
],
extras_require={"i18n": ['babel>=2.9.0']},
python_requires='>=3.7',
entry_points={
'console_scripts': [
'mkdocs = mkdocs.__main__:cli',
],
'mkdocs.themes': [
'mkdocs = mkdocs.themes.mkdocs',
'readthedocs = mkdocs.themes.readthedocs',
],
'mkdocs.plugins': [
'search = mkdocs.contrib.search:SearchPlugin',
],
},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3 :: Only',
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
'Topic :: Documentation',
'Topic :: Text Processing',
],
zip_safe=False,
)

# (*) Please direct queries to the discussion group:
# https://groups.google.com/forum/#!forum/mkdocs
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[tox]
isolated_build = true
envlist =
py{37,38,39,310,py3}-{unittests,min-req,integration,integration-no-babel},
black, isort, flake8, markdown-lint, linkchecker, jshint, csslint, nobabel, codespell
Expand All @@ -19,7 +20,7 @@ commands=
[testenv:black]
deps=black
skip_install=true
commands={envbindir}/black -l100 -tpy37 --skip-string-normalization mkdocs
commands={envbindir}/black mkdocs

[testenv:isort]
deps=isort
Expand Down

0 comments on commit 30cdac4

Please sign in to comment.