Skip to content

Commit 3a73707

Browse files
author
Laurent Franceschetti
committed
Migrate to pyproject.toml
- change update_pypi.sh accordingly
1 parent 99733be commit 3a73707

File tree

5 files changed

+174
-87
lines changed

5 files changed

+174
-87
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
# Changelog: mkdocs-macros
1+
# Changelog: Mkdocs-Dacros
22

3-
All notable changes to this project will be documented in this file.
3+
All notable changes to this project are documented in this file.
44

55
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).
66

7+
## 1.3.7, 2024-10-17
8+
* Added: complete test framework, using pytest and Mkdocs-Test (#244)
9+
A number of automated test cases are implemented.
10+
* Changed: move from setup.py to pyproject.toml (#250)
11+
712
## 1.2.0, 2024-09-15
813
* Added: three hooks `register_variables/macros/filters` to facilitate
914
cooperation with other MkDocs plugins.

_setup.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# --------------------------------------------
2+
# Setup file for the package
3+
#
4+
# Laurent Franceschetti (c) 2018-2020
5+
# THIS IS THE OLD VERSION, kept for reference purposes
6+
# --------------------------------------------
7+
8+
import os
9+
from setuptools import setup, find_packages
10+
11+
12+
# --------------------
13+
# Initialization
14+
# --------------------
15+
16+
VERSION_NUMBER = '1.3.7'
17+
18+
# required if you want to run document/test
19+
# pip install 'mkdocs-macros-plugin[test]'
20+
TEST_REQUIRE = ['mkdocs-macros-test', 'mkdocs-material>=6.2',
21+
'mkdocs-include-markdown-plugin', 'mkdocs-test']
22+
23+
# --------------------
24+
# Setup
25+
# --------------------
26+
27+
28+
def read_file(fname):
29+
"Read a local file"
30+
return open(os.path.join(os.path.dirname(__file__), fname), encoding="utf-8").read()
31+
32+
33+
setup(
34+
name='mkdocs-macros-plugin',
35+
version=VERSION_NUMBER,
36+
description="Unleash the power of MkDocs with macros and variables",
37+
long_description=read_file('README.md'),
38+
long_description_content_type='text/markdown',
39+
keywords='mkdocs python markdown macros',
40+
url='https://github.com/fralau/mkdocs_macros_plugin',
41+
author='Laurent Franceschbetti',
42+
author_email='info@settlenext.com',
43+
license='MIT',
44+
python_requires='>=3.8',
45+
install_requires=[
46+
'mkdocs>=0.17',
47+
'jinja2',
48+
'termcolor',
49+
'pyyaml',
50+
'hjson',
51+
'pathspec',
52+
'python-dateutil',
53+
'packaging',
54+
'super-collections'
55+
],
56+
extras_require={
57+
'test': TEST_REQUIRE,
58+
},
59+
classifiers=[
60+
'Development Status :: 5 - Production/Stable',
61+
'Intended Audience :: Developers',
62+
'Intended Audience :: Information Technology',
63+
'License :: OSI Approved :: MIT License',
64+
'Programming Language :: Python',
65+
'Programming Language :: Python :: 3 :: Only',
66+
'Programming Language :: Python :: 3.5',
67+
],
68+
include_package_data=True,
69+
packages=find_packages(exclude=['*.tests']),
70+
entry_points={
71+
'mkdocs.plugins': [
72+
'macros = mkdocs_macros.plugin:MacrosPlugin',
73+
]
74+
}
75+
)

pyproject.toml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[project]
2+
name = "mkdocs-macros-plugin"
3+
4+
# This version number is the REFERENCE for the rest of the project,
5+
# particularly for update_pypi.sh
6+
version = "1.3.6"
7+
8+
description = "Unleash the power of MkDocs with macros and variables"
9+
readme = "README.md"
10+
license = { text = "MIT" }
11+
requires-python = ">=3.8"
12+
authors = [
13+
{ name = "Laurent Franceschetti", email = "info@settlenext.com" },
14+
]
15+
keywords = [
16+
"macros",
17+
"markdown",
18+
"mkdocs",
19+
"python",
20+
]
21+
classifiers = [
22+
"Development Status :: 5 - Production/Stable",
23+
"Intended Audience :: Developers",
24+
"Intended Audience :: Information Technology",
25+
"License :: OSI Approved :: MIT License",
26+
"Programming Language :: Python",
27+
"Programming Language :: Python :: 3 :: Only",
28+
"Programming Language :: Python :: 3.5",
29+
]
30+
dependencies = [
31+
"hjson",
32+
"jinja2",
33+
"mkdocs>=0.17",
34+
"packaging",
35+
"pathspec",
36+
"python-dateutil",
37+
"pyyaml",
38+
"super-collections",
39+
"termcolor",
40+
]
41+
42+
[tool.setuptools]
43+
packages = { find = { exclude = ["*.tests"] } }
44+
45+
[project.optional-dependencies]
46+
test = [
47+
"mkdocs-include-markdown-plugin",
48+
"mkdocs-macros-test",
49+
"mkdocs-material>=6.2",
50+
"mkdocs-test",
51+
]
52+
53+
[project.entry-points."mkdocs.plugins"]
54+
macros = "mkdocs_macros.plugin:MacrosPlugin"
55+
56+
[project.urls]
57+
Homepage = "https://github.com/fralau/mkdocs_macros_plugin"
58+

setup.py

Lines changed: 7 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,11 @@
1-
# --------------------------------------------
2-
# Setup file for the package
3-
#
4-
# Laurent Franceschetti (c) 2018-2020
5-
# --------------------------------------------
6-
7-
import os
8-
from setuptools import setup, find_packages
9-
10-
11-
# --------------------
12-
# Initialization
13-
# --------------------
14-
15-
VERSION_NUMBER = '1.3.6'
16-
17-
# required if you want to run document/test
18-
# pip install 'mkdocs-macros-plugin[test]'
19-
TEST_REQUIRE = ['mkdocs-macros-test', 'mkdocs-material>=6.2',
20-
'mkdocs-include-markdown-plugin', 'mkdocs-test']
21-
22-
# --------------------
23-
# Setup
24-
# --------------------
25-
26-
27-
def read_file(fname):
28-
"Read a local file"
29-
return open(os.path.join(os.path.dirname(__file__), fname), encoding="utf-8").read()
1+
"""
2+
Installation using setup.py is no longer supported.
3+
Use `python -m pip install .` instead.
4+
"""
305

6+
from setuptools import setup
317

8+
# Fake reference so GitHub still considers it a real package for statistics purposes.
329
setup(
3310
name='mkdocs-macros-plugin',
34-
version=VERSION_NUMBER,
35-
description="Unleash the power of MkDocs with macros and variables",
36-
long_description=read_file('README.md'),
37-
long_description_content_type='text/markdown',
38-
keywords='mkdocs python markdown macros',
39-
url='https://github.com/fralau/mkdocs_macros_plugin',
40-
author='Laurent Franceschbetti',
41-
author_email='info@settlenext.com',
42-
license='MIT',
43-
python_requires='>=3.8',
44-
install_requires=[
45-
'mkdocs>=0.17',
46-
'jinja2',
47-
'termcolor',
48-
'pyyaml',
49-
'hjson',
50-
'pathspec',
51-
'python-dateutil',
52-
'packaging',
53-
'super-collections'
54-
],
55-
extras_require={
56-
'test': TEST_REQUIRE,
57-
},
58-
classifiers=[
59-
'Development Status :: 5 - Production/Stable',
60-
'Intended Audience :: Developers',
61-
'Intended Audience :: Information Technology',
62-
'License :: OSI Approved :: MIT License',
63-
'Programming Language :: Python',
64-
'Programming Language :: Python :: 3 :: Only',
65-
'Programming Language :: Python :: 3.5',
66-
],
67-
include_package_data=True,
68-
packages=find_packages(exclude=['*.tests']),
69-
entry_points={
70-
'mkdocs.plugins': [
71-
'macros = mkdocs_macros.plugin:MacrosPlugin',
72-
]
73-
}
74-
)
11+
)

update_pypi.sh

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,46 @@
11
# -------------------------------------------------------------
22
# update the package on pypi
3+
# 2024-10-12
34
#
45
# Tip: if you don't want to retype pypi's username every time
56
# define it as an environment variable (TWINE_USERNAME)
7+
#
68
# -------------------------------------------------------------
79
function warn {
810
GREEN='\033[0;32m'
911
NORMAL='\033[0m'
1012
echo -e "${GREEN}$1${NORMAL}"
1113
}
1214

13-
setup="python3 setup.py"
14-
package_name=$($setup --name)
15-
package_version=v$($setup --version) # add a 'v' in front (git convention)
15+
function get_value {
16+
# get the value from the config file (requires the Python toml package)
17+
toml get --toml-path pyproject.toml $1
18+
}
19+
20+
# Clean the subdirs, for safety and to guarantee integrity
21+
# ./cleanup.sh
1622

17-
warn "UPDATE PACKAGE $package_name ($package_version) ON PYPI:"
18-
warn "Cleaning up..."
19-
rm -rf dist
20-
rm -rf build
21-
warn "Recreating wheels..."
22-
$setup sdist bdist_wheel 1>/dev/null
23-
# update version (just in case):
24-
package_version=v$($setup --version) # add a 'v' in front (git convention)
25-
warn "---"
26-
warn "Upload to Pypi..."
27-
if twine upload --repository-url https://upload.pypi.org/legacy/ dist/* ; then
23+
# Check for changes in the files compared to the repository
24+
if ! git diff --quiet; then
25+
warn "Won't do it: there are changes in the repository. Please commit first!"
26+
exit 1
27+
fi
28+
29+
# get the project inform
30+
package_name=$(get_value project.name)
31+
package_version=v$(get_value project.version) # add a 'v' in front (git convention)
32+
33+
# update Pypi
34+
warn "Rebuilding $package_name..."
35+
rm -rf build dist *.egg-info # necessary to guarantee integrity
36+
python3 -m build
37+
if twine upload dist/* ; then
38+
git push # just in case
2839
warn "... create tag $package_version, and push to remote git repo..."
2940
git tag $package_version
3041
git push --tags
3142
warn "Done ($package_version)!"
3243
else
3344
warn "Failed ($package_version)!"
34-
fi
45+
exit 1
46+
fi

0 commit comments

Comments
 (0)