Skip to content

Commit

Permalink
Migrate setup.py to pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent Franceschetti committed Nov 2, 2024
1 parent 18b0c2e commit a68f4b1
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 84 deletions.
25 changes: 15 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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/).
58 changes: 58 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"


65 changes: 7 additions & 58 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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'
]
}
)
)
44 changes: 28 additions & 16 deletions update_pypi.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,46 @@
# -------------------------------------------------------------
# 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'
NORMAL='\033[0m'
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
exit 1
fi

0 comments on commit a68f4b1

Please sign in to comment.