From a68f4b1d09600b9f0b307300d1290a5fcda29a33 Mon Sep 17 00:00:00 2001 From: Laurent Franceschetti Date: Sat, 2 Nov 2024 07:07:58 +0100 Subject: [PATCH] Migrate setup.py to pyproject.toml --- CHANGELOG.md | 25 +++++++++++-------- pyproject.toml | 58 ++++++++++++++++++++++++++++++++++++++++++++ setup.py | 65 ++++++-------------------------------------------- update_pypi.sh | 44 +++++++++++++++++++++------------- 4 files changed, 108 insertions(+), 84 deletions(-) create mode 100644 pyproject.toml diff --git a/CHANGELOG.md b/CHANGELOG.md index fa11bb4..3192396 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,39 +1,44 @@ -# Changelog: mkdocs-macros +# Changelog: Mkdocs-Mermaid2 All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 1.2.1, 2024-11-02 + +* Added: a test framework with MkDocs-Test and pytest +* Changed: migrated from `setup.py` to `pyproject.toml` + ## 1.1.2, 2024-09-05 -Changed: If the `javascript` parameter starts with http(s) and no Internet +* Changed: If the `javascript` parameter starts with http(s) and no Internet access is available, a WARNING is now issued (mkdocs no longer fails with an exception). ## 1.1.1, 2023-09-26 -Fixed: Bug with local javascript library +* Fixed: Bug with local javascript library ## 1.1.0, 2023-09-01 -Added: Parameter `javascript` in config file for optionally specifying the +* Added: Parameter `javascript` in config file for optionally specifying the URL or path of the Mermaid javascript library. -Changed: Parameter `extra_javascript` in config file is DEPRECATED, +* Changed: Parameter `extra_javascript` in config file is DEPRECATED, for optionally specifying the URL or path of the Mermaid javascript library -Changed: Updated documentation. +* Changed: Updated documentation. ## 1.0.8, 2023-08-09 -Fixed: Arguments of config file not taken into consideration, +* Fixed: Arguments of config file not taken into consideration, for mermaid.js version > 10 (#82) ## 1.0.5, 2023-07-29 -Added: A new [doc website is available on Read The Docs](https://mkdocs-mermaid2.readthedocs.io/en/latest/). +* Added: A new [doc website is available on Read The Docs](https://mkdocs-mermaid2.readthedocs.io/en/latest/). ## 1.0.1, 2023-07 -Added: Now the plugin works with versions of the library > 10 and lower (#75) -Added: Added: A new [doc website is available on Read The Docs](https://mkdocs-mermaid2.readthedocs.io/en/latest/). +* Added: Now the plugin works with versions of the library > 10 and lower (#75) +* Added: Added: A new [doc website is available on Read The Docs](https://mkdocs-mermaid2.readthedocs.io/en/latest/). diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..dafc6b4 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,58 @@ +[project] +name = "mkdocs-mermaid2-plugin" + +# This version number is the REFERENCE for the rest of the project, +# particularly for update_pypi.sh +version = "1.2.1" + +description = "A MkDocs plugin for including mermaid graphs in markdown sources" +readme = "README.md" +license = { text = "MIT" } +requires-python = ">=3.8" +authors = [ + { name = "Laurent Franceschetti"}, +] +keywords = [ + "markdown", + "mermaid", + "mkdocs", + "python", +] +classifiers = [ + "Development Status :: 5 - Stable", + "Intended Audience :: Developers", + "Intended Audience :: Information Technology", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", +] +dependencies = [ + "beautifulsoup4>=4.6.3", + "jsbeautifier", + "mkdocs>=1.0.4", + "pymdown-extensions >= 8.0", + "requests", + "setuptools>=18.5", +] + +[tool.setuptools] +packages = { find = { exclude = ["*.tests"] } } + +[project.optional-dependencies] +test = [ + "mkdocs-macros-test", + "mkdocs-material", + "packaging", + "requests-html", +] + +[project.entry-points."mkdocs.plugins"] +mermaid2 = "mermaid2.plugin:MarkdownMermaidPlugin" + +[project.urls] +Homepage = "https://github.com/fralau/mkdocs-mermaid2-plugin" + + diff --git a/setup.py b/setup.py index bd00cb5..17c7db1 100755 --- a/setup.py +++ b/setup.py @@ -1,62 +1,11 @@ -from setuptools import setup, find_packages +""" +Installation using setup.py is no longer supported. +Use `python -m pip install .` instead. +""" +from setuptools import setup -VERSION = '1.2.0' - -# required if you want to run tests -# pip install 'mkdocs-mermaid2-plugin[test]' -TEST_REQUIRE = ['mkdocs-material', 'mkdocs-macros-test', 'requests-html', - 'packaging'] - - -def readme(): - """print long description""" - with open('README.md') as f: - return f.read() - - -LONG_DESCRIPTION = ( - "An Mkdocs plugin that renders Mermaid graphs in the markdown file. " - "To install, please follow instructions in the README file." -) - +# Fake reference so GitHub still considers it a real package for statistics purposes. setup( name='mkdocs-mermaid2-plugin', - version=VERSION, - description='A MkDocs plugin for including mermaid graphs in markdown sources', - long_description=LONG_DESCRIPTION, - keywords='mkdocs python markdown mermaid', - url='https://github.com/fralau/mkdocs-mermaid2-plugin', - author='Fralau', - author_email='fralau@bluewin.ch', - license='MIT', - python_requires='>=3.6', - install_requires=[ - 'setuptools>=18.5', - 'beautifulsoup4>=4.6.3', - 'mkdocs>=1.0.4', - 'jsbeautifier', - 'requests', - 'pymdown-extensions >= 8.0' - ], - extras_require={ - 'test': TEST_REQUIRE, - }, - classifiers=[ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'Intended Audience :: Information Technology', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8' - ], - packages=find_packages(exclude=['*.tests']), - entry_points={ - 'mkdocs.plugins': [ - 'mermaid2 = mermaid2.plugin:MarkdownMermaidPlugin' - ] - } -) +) \ No newline at end of file diff --git a/update_pypi.sh b/update_pypi.sh index 05b07b0..275a21a 100755 --- a/update_pypi.sh +++ b/update_pypi.sh @@ -1,8 +1,10 @@ # ------------------------------------------------------------- # update the package on pypi +# 2024-10-12 # # Tip: if you don't want to retype pypi's username every time -# define it as an environement variable (TWINE_USERNAME) +# define it as an environment variable (TWINE_USERNAME) +# # ------------------------------------------------------------- function warn { GREEN='\033[0;32m' @@ -10,25 +12,35 @@ function warn { echo -e "${GREEN}$1${NORMAL}" } -setup="python3 setup.py" -package_name=$($setup --name) -package_version=v$($setup --version) # add a 'v' in front (git convention) +function get_value { + # get the value from the config file (requires the Python toml package) + toml get --toml-path pyproject.toml $1 +} + +# Clean the subdirs, for safety and to guarantee integrity +# ./cleanup.sh + +# Check for changes in the files compared to the repository +if ! git diff --quiet; then + warn "Won't do it: there are changes in the repository. Please commit first!" + exit 1 +fi + +# get the project inform +package_name=$(get_value project.name) +package_version=v$(get_value project.version) # add a 'v' in front (git convention) -warn "UPDATE PACKAGE $package_name ($package_version) ON PYPI:" -warn "Cleaning up..." -rm -rf dist -rm -rf build -warn "Recreating wheels..." -$setup sdist bdist_wheel 1>/dev/null -# update version (just in case): -package_version=v$($setup --version) # add a 'v' in front (git convention) -warn "---" -warn "Upload to Pypi..." -if twine upload --repository-url https://upload.pypi.org/legacy/ dist/* ; then +# update Pypi +warn "Rebuilding $package_name..." +rm -rf build dist *.egg-info # necessary to guarantee integrity +python3 -m build +if twine upload dist/* ; then + git push # just in case warn "... create tag $package_version, and push to remote git repo..." git tag $package_version git push --tags warn "Done ($package_version)!" else warn "Failed ($package_version)!" -fi \ No newline at end of file + exit 1 +fi \ No newline at end of file