From d622397906f26f5ef9d3184be3c30f2c0b981170 Mon Sep 17 00:00:00 2001 From: Timo Furrer Date: Mon, 9 Oct 2023 09:16:51 +0200 Subject: [PATCH 1/2] Use pyproject instead of setup.py --- pyproject.toml | 39 +++++++++++++++++++++++ setup.py | 85 -------------------------------------------------- 2 files changed, 39 insertions(+), 85 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..632a561 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,39 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[project] +name = "pandoc-plantuml-filter" +authors = [ + {name = "Timo Furrer", email = "tuxtimo@gmail.com"}, +] +description = "Pandoc filter for PlantUML code blocks" +readme = "README.md" +requires-python = ">=3.8" +keywords = ["plantuml", "pandoc-filter", "pandoc"] +license = {text = "MIT"} +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Software Development :: Libraries :: Python Modules", +] +dependencies = [ + "pandocfilters", +] +dynamic = ["version"] + +[project.scripts] +pandoc-plantuml = "pandoc_plantuml_filter:main" + +[tool.setuptools_scm] diff --git a/setup.py b/setup.py deleted file mode 100644 index 1f1dc5e..0000000 --- a/setup.py +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -import sys -from shutil import rmtree - -from setuptools import setup, Command - - -here = os.path.abspath(os.path.dirname(__file__)) - -if sys.argv[-1] == "publish": - os.system("python setup.py sdist bdist_wheel upload") - sys.exit() - - -required = ["pandocfilters"] - - -class UploadCommand(Command): - """Support setup.py upload.""" - - description = "Build and publish the package." - user_options = [] - - @staticmethod - def status(s): - """Prints things in bold.""" - print("\033[1m{0}\033[0m".format(s)) - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - try: - self.status("Removing previous builds…") - rmtree(os.path.join(here, "dist")) - except OSError: - pass - - self.status("Building Source and Wheel (universal) distribution…") - os.system("{0} setup.py sdist bdist_wheel --universal".format(sys.executable)) - - self.status("Uploading the package to PyPi via Twine…") - os.system("twine upload dist/*") - - sys.exit() - - -setup( - name="pandoc-plantuml-filter", - version="0.1.2", - description="Pandoc filter for PlantUML code blocks", - long_description="Pandoc filter for PlantUML code blocks", - author="Timo Furrer", - author_email="tuxtimo@gmail.com", - url="https://github.com/timofurrer/pandoc-plantuml-filter", - install_requires=required, - py_modules=["pandoc_plantuml_filter"], - entry_points={"console_scripts": ["pandoc-plantuml = pandoc_plantuml_filter:main"]}, - license="MIT", - classifiers=( - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Natural Language :: English", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: Implementation", - "Programming Language :: Python :: Implementation :: CPython", - "Topic :: Software Development :: Libraries :: Python Modules", - ), - cmdclass={ - "upload": UploadCommand, - }, -) From 5495e79a9aa4be10279235b163c142c1d95e0a2b Mon Sep 17 00:00:00 2001 From: Timo Furrer Date: Mon, 9 Oct 2023 09:22:27 +0200 Subject: [PATCH 2/2] Add deploy workflow --- .github/workflows/deploy.yml | 29 +++++++++++++++++++++++++++++ .github/workflows/main.yml | 16 +++++++++------- .gitignore | 1 + 3 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..7b811cb --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,29 @@ +name: Upload Python Package + +on: + release: + types: [published] + +jobs: + deploy: + + runs-on: ubuntu-latest + + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install build + - name: Build package + run: python -m build + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b71b164..e6a1227 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,9 +15,9 @@ jobs: run: | python -m pip install --upgrade black flake8 - name: black format check - run: black --check --line-length 120 pandoc_plantuml_filter.py tests setup.py + run: python -m black --check --line-length 120 pandoc_plantuml_filter.py tests - name: flake8 format check - run: flake8 --max-line-length 120 pandoc_plantuml_filter.py tests setup.py + run: python -m flake8 --max-line-length 120 pandoc_plantuml_filter.py tests test: strategy: fail-fast: false @@ -32,13 +32,15 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Setup build and test environment - run: python -m pip install --upgrade pip setuptools wheel pytest pytest-mock - - name: Setup package - run: python -m pip install . + run: python -m pip install --upgrade pip build pytest pytest-mock + - name: Build package + run: python -m build + - name: Install package + run: python -m pip install --pre dist/pandoc_plantuml_filter-*.whl - name: run unit tests - run: pytest tests/test_unit.py + run: python -m pytest tests/test_unit.py - name: install dependencies for integration tests run: sudo apt update && sudo apt install -y pandoc plantuml - name: run integration tests - run: pytest tests/test_integration.py + run: python -m pytest tests/test_integration.py diff --git a/.gitignore b/.gitignore index 232ee03..e7545c3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ missfont.log pandoc_plantuml_filter.egg-info/ plantuml-images/ sample.pdf +dist/