diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000000..564a578cf1 --- /dev/null +++ b/.flake8 @@ -0,0 +1,3 @@ +[flake8] +max-line-length = 119 +extend-ignore = E203 diff --git a/.github/workflows/deploy-release.yml b/.github/workflows/deploy-release.yml index b8ea99519f..053986ddee 100644 --- a/.github/workflows/deploy-release.yml +++ b/.github/workflows/deploy-release.yml @@ -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 }} diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 032a060c09..0000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,5 +0,0 @@ -include README.md -include LICENSE -recursive-include mkdocs *.ico *.js *.css *.png *.html *.eot *.svg *.ttf *.woff *.woff2 *.xml *.mustache *mkdocs_theme.yml *.mo -recursive-exclude * __pycache__ -recursive-exclude * *.py[co] diff --git a/docs/about/contributing.md b/docs/about/contributing.md index 3f09efed85..8d21e43476 100644 --- a/docs/about/contributing.md +++ b/docs/about/contributing.md @@ -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. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..f80be6c62e --- /dev/null +++ b/pyproject.toml @@ -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 = "tom@tomchristie.com"}, +] +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 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 5aa7537760..0000000000 --- a/setup.cfg +++ /dev/null @@ -1,16 +0,0 @@ -[metadata] -license_files = LICENSE - -[flake8] -max-line-length = 119 -extend-ignore = E203 - -[isort] -profile = black -line_length = 100 - -[mypy] -ignore_missing_imports = true -warn_unreachable = true -no_implicit_optional = true -show_error_codes = true diff --git a/setup.py b/setup.py old mode 100755 new mode 100644 index b5ef3f05ea..4d5ce0a930 --- a/setup.py +++ b/setup.py @@ -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='tom@tomchristie.com', # 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 diff --git a/tox.ini b/tox.ini index bac7c3fbc8..1b181c349d 100644 --- a/tox.ini +++ b/tox.ini @@ -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 @@ -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