Skip to content

Commit

Permalink
Migrate to pyproject.toml
Browse files Browse the repository at this point in the history
  - change update_pypi.sh accordingly
  • Loading branch information
Laurent Franceschetti committed Oct 17, 2024
1 parent 99733be commit 3a73707
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 87 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Changelog: mkdocs-macros
# Changelog: Mkdocs-Dacros

All notable changes to this project will be documented in this file.
All notable changes to this project are 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.3.7, 2024-10-17
* Added: complete test framework, using pytest and Mkdocs-Test (#244)
A number of automated test cases are implemented.
* Changed: move from setup.py to pyproject.toml (#250)

## 1.2.0, 2024-09-15
* Added: three hooks `register_variables/macros/filters` to facilitate
cooperation with other MkDocs plugins.
Expand Down
75 changes: 75 additions & 0 deletions _setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# --------------------------------------------
# Setup file for the package
#
# Laurent Franceschetti (c) 2018-2020
# THIS IS THE OLD VERSION, kept for reference purposes
# --------------------------------------------

import os
from setuptools import setup, find_packages


# --------------------
# Initialization
# --------------------

VERSION_NUMBER = '1.3.7'

# required if you want to run document/test
# pip install 'mkdocs-macros-plugin[test]'
TEST_REQUIRE = ['mkdocs-macros-test', 'mkdocs-material>=6.2',
'mkdocs-include-markdown-plugin', 'mkdocs-test']

# --------------------
# Setup
# --------------------


def read_file(fname):
"Read a local file"
return open(os.path.join(os.path.dirname(__file__), fname), encoding="utf-8").read()


setup(
name='mkdocs-macros-plugin',
version=VERSION_NUMBER,
description="Unleash the power of MkDocs with macros and variables",
long_description=read_file('README.md'),
long_description_content_type='text/markdown',
keywords='mkdocs python markdown macros',
url='https://github.com/fralau/mkdocs_macros_plugin',
author='Laurent Franceschbetti',
author_email='[email protected]',
license='MIT',
python_requires='>=3.8',
install_requires=[
'mkdocs>=0.17',
'jinja2',
'termcolor',
'pyyaml',
'hjson',
'pathspec',
'python-dateutil',
'packaging',
'super-collections'
],
extras_require={
'test': TEST_REQUIRE,
},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.5',
],
include_package_data=True,
packages=find_packages(exclude=['*.tests']),
entry_points={
'mkdocs.plugins': [
'macros = mkdocs_macros.plugin:MacrosPlugin',
]
}
)
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-macros-plugin"

# This version number is the REFERENCE for the rest of the project,
# particularly for update_pypi.sh
version = "1.3.6"

description = "Unleash the power of MkDocs with macros and variables"
readme = "README.md"
license = { text = "MIT" }
requires-python = ">=3.8"
authors = [
{ name = "Laurent Franceschetti", email = "[email protected]" },
]
keywords = [
"macros",
"markdown",
"mkdocs",
"python",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.5",
]
dependencies = [
"hjson",
"jinja2",
"mkdocs>=0.17",
"packaging",
"pathspec",
"python-dateutil",
"pyyaml",
"super-collections",
"termcolor",
]

[tool.setuptools]
packages = { find = { exclude = ["*.tests"] } }

[project.optional-dependencies]
test = [
"mkdocs-include-markdown-plugin",
"mkdocs-macros-test",
"mkdocs-material>=6.2",
"mkdocs-test",
]

[project.entry-points."mkdocs.plugins"]
macros = "mkdocs_macros.plugin:MacrosPlugin"

[project.urls]
Homepage = "https://github.com/fralau/mkdocs_macros_plugin"

77 changes: 7 additions & 70 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,74 +1,11 @@
# --------------------------------------------
# Setup file for the package
#
# Laurent Franceschetti (c) 2018-2020
# --------------------------------------------

import os
from setuptools import setup, find_packages


# --------------------
# Initialization
# --------------------

VERSION_NUMBER = '1.3.6'

# required if you want to run document/test
# pip install 'mkdocs-macros-plugin[test]'
TEST_REQUIRE = ['mkdocs-macros-test', 'mkdocs-material>=6.2',
'mkdocs-include-markdown-plugin', 'mkdocs-test']

# --------------------
# Setup
# --------------------


def read_file(fname):
"Read a local file"
return open(os.path.join(os.path.dirname(__file__), fname), encoding="utf-8").read()
"""
Installation using setup.py is no longer supported.
Use `python -m pip install .` instead.
"""

from setuptools import setup

# Fake reference so GitHub still considers it a real package for statistics purposes.
setup(
name='mkdocs-macros-plugin',
version=VERSION_NUMBER,
description="Unleash the power of MkDocs with macros and variables",
long_description=read_file('README.md'),
long_description_content_type='text/markdown',
keywords='mkdocs python markdown macros',
url='https://github.com/fralau/mkdocs_macros_plugin',
author='Laurent Franceschbetti',
author_email='[email protected]',
license='MIT',
python_requires='>=3.8',
install_requires=[
'mkdocs>=0.17',
'jinja2',
'termcolor',
'pyyaml',
'hjson',
'pathspec',
'python-dateutil',
'packaging',
'super-collections'
],
extras_require={
'test': TEST_REQUIRE,
},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.5',
],
include_package_data=True,
packages=find_packages(exclude=['*.tests']),
entry_points={
'mkdocs.plugins': [
'macros = mkdocs_macros.plugin:MacrosPlugin',
]
}
)
)
42 changes: 27 additions & 15 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 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

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
# 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)

# 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 3a73707

Please sign in to comment.