From 2444b355e19e14f7dd4848b3fff9082ae18e5b77 Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Sun, 11 Apr 2021 17:57:58 -0500 Subject: [PATCH 1/4] Migrate to the namespace-based plugin style introduced in Pelican 4.5 --- CHANGES.rst | 2 + README.rst | 18 ++++++-- setup.py | 15 ++++-- .../pelican/plugins/precompress/__init__.py | 9 +--- test_pelican_precompress.py | 46 +++++++++---------- tox.ini | 34 ++++++++++---- 6 files changed, 78 insertions(+), 46 deletions(-) rename pelican_precompress.py => src/pelican/plugins/precompress/__init__.py (97%) diff --git a/CHANGES.rst b/CHANGES.rst index acc27cd..381ab17 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,8 @@ Changelog Unreleased changes ================== +* Migrate to the namespace plugin architecture introduced in Pelican 4.5. + 1.1.2 - 2021-02-11 diff --git a/README.rst b/README.rst index 389d65d..290cbb0 100644 --- a/README.rst +++ b/README.rst @@ -48,17 +48,27 @@ Further reading: `zopfli`_, `brotli`_ 2. Configure Pelican -------------------- -You'll need to import the plugin and add it to the list of active plugins. +If you're using Pelican 4.5 or higher then you might not need to configure anything. +pelican_precompress supports Pelican's namespace plugin architecture +and will be automatically detected and loaded when Pelican runs. + +However, if you're maintaining a list of plugins for Pelican to use (even in Pelican 4.5) +then you'll need to add it to the list of active plugins. + Feel free to copy and paste the code below into your Pelican configuration file. Just uncomment and edit the configuration lines to your liking...or leave them alone because the defaults are awesome! .. code-block:: python3 - import pelican_precompress - - PLUGINS = [pelican_precompress] + # Pelican 4.5 introduced automatic plugin discovery and loading. + # You only need to add pelican_precompress to your PLUGINS list + # if your configuration file already has a PLUGINS list! + # + # PLUGINS = ['pelican.plugins.precompress'] + # These options can be customized as desired. + # # PRECOMPRESS_GZIP = True or False # PRECOMPRESS_ZOPFLI = True or False # PRECOMPRESS_BROTLI = True or False diff --git a/setup.py b/setup.py index 8c81edd..0599c5c 100644 --- a/setup.py +++ b/setup.py @@ -4,9 +4,15 @@ import os import pathlib +import re import setuptools -import pelican_precompress + +def get_version(): + path = pathlib.Path(__file__).parent / 'src/pelican/plugins/precompress/__init__.py' + version_blob = path.read_text() + return re.search("""__version__ = ['"](.+?)['"]""", version_blob).group(1) + with pathlib.Path('README.rst').open('r') as file: long_description = file.read() @@ -15,9 +21,9 @@ if os.getenv('PRECOMPRESS_NAME_SUFFIX'): name = f'pelican_precompress_{os.getenv("PRECOMPRESS_NAME_SUFFIX")}' -version = pelican_precompress.__version__ +version = get_version() if os.getenv('PRECOMPRESS_VERSION_SUFFIX'): - version = f'{pelican_precompress.__version__}b{os.getenv("PRECOMPRESS_VERSION_SUFFIX")}' + version = f'{version}b{os.getenv("PRECOMPRESS_VERSION_SUFFIX")}' setuptools.setup( name=name, @@ -28,7 +34,8 @@ long_description=long_description, long_description_content_type='text/x-rst', url='https://github.com/kurtmckee/pelican_precompress', - py_modules=['pelican_precompress'], + packages=['pelican.plugins.precompress'], + package_dir={'pelican': 'src/pelican'}, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Framework :: Pelican :: Plugins', diff --git a/pelican_precompress.py b/src/pelican/plugins/precompress/__init__.py similarity index 97% rename from pelican_precompress.py rename to src/pelican/plugins/precompress/__init__.py index 19b88c9..2377a7c 100644 --- a/pelican_precompress.py +++ b/src/pelican/plugins/precompress/__init__.py @@ -10,17 +10,12 @@ from typing import Dict, Iterable, Optional, Set, Union import zlib +import pelican + __version__ = '1.1.2' log = logging.getLogger(__name__) -# pelican doesn't have to be installed to run tests. -try: - import pelican -except ModuleNotFoundError: - log.debug('pelican is not installed.') - pelican = None - # brotli support is optional. try: import brotli diff --git a/test_pelican_precompress.py b/test_pelican_precompress.py index 596ab85..f989856 100644 --- a/test_pelican_precompress.py +++ b/test_pelican_precompress.py @@ -9,7 +9,7 @@ import pytest -import pelican_precompress as pp +import pelican.plugins.precompress as pp @pytest.mark.parametrize( @@ -26,7 +26,7 @@ def test_get_settings_compression_support(installed_modules, expected_settings): instance.settings = {'OUTPUT_PATH': ''} patches = [ - patch(f'pelican_precompress.{module}', module in installed_modules) + patch(f'pelican.plugins.precompress.{module}', module in installed_modules) for module in {'brotli', 'zopfli'} ] [patch_.start() for patch_ in patches] @@ -52,9 +52,9 @@ def test_get_settings_compression_validation(): log = Mock() patches = [ - patch('pelican_precompress.brotli', None), - patch('pelican_precompress.zopfli', None), - patch('pelican_precompress.log', log) + patch('pelican.plugins.precompress.brotli', None), + patch('pelican.plugins.precompress.zopfli', None), + patch('pelican.plugins.precompress.log', log) ] [patch_.start() for patch_ in patches] @@ -89,7 +89,7 @@ def test_get_settings_extensions_validation(extensions): log = Mock() patches = [ - patch('pelican_precompress.log', log) + patch('pelican.plugins.precompress.log', log) ] [patch_.start() for patch_ in patches] @@ -135,7 +135,7 @@ def test_compress_with_gzip_exception(): def test_register(): - with patch('pelican_precompress.pelican', Mock()) as pelican: + with patch('pelican.plugins.precompress.pelican', Mock()) as pelican: pp.register() pelican.signals.finalized.connect.assert_called_once_with(pp.compress_files) @@ -165,7 +165,7 @@ def apply_async_mock(fn, args, *extra_args, **kwargs): multiprocessing_mock.apply_async = apply_async_mock -@patch('pelican_precompress.multiprocessing', multiprocessing_mock) +@patch('pelican.plugins.precompress.multiprocessing', multiprocessing_mock) def test_compress_files_do_nothing(fs): """If all compressors are disabled, no compressed files should be written.""" fs.create_file('/test.txt') @@ -181,7 +181,7 @@ def test_compress_files_do_nothing(fs): assert not pathlib.Path('/test.txt.gz').exists() -@patch('pelican_precompress.multiprocessing', multiprocessing_mock) +@patch('pelican.plugins.precompress.multiprocessing', multiprocessing_mock) def test_compress_files_never_overwrite(fs): with open('/test.txt', 'wb') as file: file.write(b'a' * 100) @@ -193,14 +193,14 @@ def test_compress_files_never_overwrite(fs): 'PRECOMPRESS_GZIP': True, 'PRECOMPRESS_ZOPFLI': False, } - with patch('pelican_precompress.log', Mock()) as log: + with patch('pelican.plugins.precompress.log', Mock()) as log: pp.compress_files(instance) log.info.assert_called_once() assert pathlib.Path('/test.txt.gz').exists() assert pathlib.Path('/test.txt.gz').stat().st_size == 0 -@patch('pelican_precompress.multiprocessing', multiprocessing_mock) +@patch('pelican.plugins.precompress.multiprocessing', multiprocessing_mock) def test_compress_files_skip_existing_matching_files(fs): with open('/test.txt', 'wb') as file: file.write(b'abc' * 1000) @@ -216,7 +216,7 @@ def test_compress_files_skip_existing_matching_files(fs): 'PRECOMPRESS_ZOPFLI': False, 'PRECOMPRESS_OVERWRITE': True, } - with patch('pelican_precompress.log', Mock()) as log: + with patch('pelican.plugins.precompress.log', Mock()) as log: pp.compress_files(instance) log.info.assert_called_once() with destination.open('rb') as file: @@ -224,7 +224,7 @@ def test_compress_files_skip_existing_matching_files(fs): assert destination.stat().st_size == destination_size -@patch('pelican_precompress.multiprocessing', multiprocessing_mock) +@patch('pelican.plugins.precompress.multiprocessing', multiprocessing_mock) def test_compress_files_overwrite_br(fs): brotli = pytest.importorskip('brotli') with open('/test.txt', 'wb') as file: @@ -239,14 +239,14 @@ def test_compress_files_overwrite_br(fs): 'PRECOMPRESS_GZIP': False, 'PRECOMPRESS_ZOPFLI': False, } - with patch('pelican_precompress.log', Mock()) as log: + with patch('pelican.plugins.precompress.log', Mock()) as log: pp.compress_files(instance) log.warning.assert_called_once() with pathlib.Path('/test.txt.br').open('rb') as file: assert brotli.decompress(file.read()) == b'a' * 100 -@patch('pelican_precompress.multiprocessing', multiprocessing_mock) +@patch('pelican.plugins.precompress.multiprocessing', multiprocessing_mock) def test_compress_files_overwrite_gz(fs): with open('/test.txt', 'wb') as file: file.write(b'a' * 100) @@ -260,14 +260,14 @@ def test_compress_files_overwrite_gz(fs): 'PRECOMPRESS_GZIP': True, 'PRECOMPRESS_ZOPFLI': False, } - with patch('pelican_precompress.log', Mock()) as log: + with patch('pelican.plugins.precompress.log', Mock()) as log: pp.compress_files(instance) log.warning.assert_called_once() with pathlib.Path('/test.txt.gz').open('rb') as file: assert gzip.decompress(file.read()) == b'a' * 100 -@patch('pelican_precompress.multiprocessing', multiprocessing_mock) +@patch('pelican.plugins.precompress.multiprocessing', multiprocessing_mock) def test_compress_files_file_size_increase(fs): with open('/test.txt', 'wb') as file: file.write(b'a' * 2) @@ -279,13 +279,13 @@ def test_compress_files_file_size_increase(fs): 'PRECOMPRESS_ZOPFLI': False, 'PRECOMPRESS_MIN_SIZE': 1, } - with patch('pelican_precompress.log', Mock()) as log: + with patch('pelican.plugins.precompress.log', Mock()) as log: pp.compress_files(instance) log.info.assert_called_once() assert not pathlib.Path('/test.txt.gz').exists() -@patch('pelican_precompress.multiprocessing', multiprocessing_mock) +@patch('pelican.plugins.precompress.multiprocessing', multiprocessing_mock) def test_compress_files_continue_on_small_files(fs): """Verify that small files do not cause an early exit. @@ -304,13 +304,13 @@ def test_compress_files_continue_on_small_files(fs): 'PRECOMPRESS_ZOPFLI': False, 'PRECOMPRESS_MIN_SIZE': 100, } - with patch('pelican_precompress.log', Mock()) as log: + with patch('pelican.plugins.precompress.log', Mock()) as log: pp.compress_files(instance) log.info.assert_called_once() assert pathlib.Path('/999-must-compress.txt.gz').exists() -@patch('pelican_precompress.multiprocessing', multiprocessing_mock) +@patch('pelican.plugins.precompress.multiprocessing', multiprocessing_mock) def test_compress_files_overwrite_erase_existing_file(fs): """Ensure existing files are erased if the file size would increase.""" with open('/test.txt', 'wb') as file: @@ -326,13 +326,13 @@ def test_compress_files_overwrite_erase_existing_file(fs): 'PRECOMPRESS_OVERWRITE': True, 'PRECOMPRESS_MIN_SIZE': 1, } - with patch('pelican_precompress.log', Mock()) as log: + with patch('pelican.plugins.precompress.log', Mock()) as log: pp.compress_files(instance) log.info.assert_called_once() assert not pathlib.Path('/test.txt.gz').exists() -@patch('pelican_precompress.multiprocessing', multiprocessing_mock) +@patch('pelican.plugins.precompress.multiprocessing', multiprocessing_mock) def test_compress_files_success_all_algorithms(fs): pytest.importorskip('brotli') pytest.importorskip('zopfli') diff --git a/tox.ini b/tox.ini index a9c1417..5e53614 100644 --- a/tox.ini +++ b/tox.ini @@ -4,9 +4,8 @@ [tox] -envlist = py{36, 37, 38, 39}-{brotli, }-{zopfli, }, coverage +envlist = clean, py{36, 37, 38, 39}-{brotli, }-{zopfli, }, report skip_missing_interpreters = True -skipsdist = True [testenv] @@ -16,14 +15,27 @@ deps = pyfakefs brotli: brotli zopfli: zopfli -setenv = COVERAGE_FILE={toxworkdir}/.coverage.envname.{envname} -commands = {envpython} -m pytest --color=yes --cov=pelican_precompress --cov=test_pelican_precompress --cov-report= test_pelican_precompress.py +setenv = + COVERAGE_FILE={toxworkdir}/.coverage.envname.{envname} +commands = {envpython} -m pytest --color=yes --cov=pelican.plugins.precompress --cov=test_pelican_precompress --cov-report=term test_pelican_precompress.py -[testenv:coverage] -deps = coverage +[testenv:clean] skip_install = True -setenv = COVERAGE_FILE={toxworkdir}/.coverage +deps = + coverage +setenv = + COVERAGE_FILE={toxworkdir}/.coverage +commands = + {envpython} -m coverage erase + + +[testenv:report] +skip_install = True +deps = + coverage +setenv = + COVERAGE_FILE={toxworkdir}/.coverage commands = {envpython} -m coverage combine {envpython} -m coverage report @@ -32,6 +44,12 @@ commands = [coverage:run] include = - pelican_precompress + pelican.plugins.precompress test_pelican_precompress branch = True + + +[coverage:paths] +source = + src + */site-packages From 79eade4a49c6f71b534c9ba67d14557032dce96c Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Mon, 12 Apr 2021 21:56:19 -0500 Subject: [PATCH 2/4] Migrate to Poetry --- .gitignore | 2 + CHANGES.rst | 1 + README.rst | 25 +++--- pyproject.toml | 84 +++++++++++++++++++++ requirements-dev.txt | 16 ---- setup.py | 51 ------------- src/pelican/plugins/precompress/__init__.py | 1 - tox.ini | 55 -------------- 8 files changed, 103 insertions(+), 132 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements-dev.txt delete mode 100644 setup.py delete mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 2bd3c52..3595f1f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ # doit database .doit.db +# Poetry lock file +poetry.lock # Python .gitignore, with .idea/ added. # https://github.com/github/gitignore/blob/master/Python.gitignore diff --git a/CHANGES.rst b/CHANGES.rst index 381ab17..c8d7a2b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,6 +9,7 @@ Unreleased changes ================== * Migrate to the namespace plugin architecture introduced in Pelican 4.5. +* Migrate to Poetry to manage the dependencies and build process. diff --git a/README.rst b/README.rst index 290cbb0..19bb211 100644 --- a/README.rst +++ b/README.rst @@ -161,26 +161,32 @@ You set them in your Pelican configuration file. To try compressing every file regardless of size, set this to ``0``. -Testing -======= +Development +=========== -**pelican_precompress** has 100% test coverage. If you'd like to test the -code yourself, clone the git repository and run these commands: +If you'd like to develop and/or test the code yourself, +clone the git repository and run these commands to set +up a Python virtual environment, install dependencies, +and run the test suite: .. code-block:: shell - $ python3 -m venv venv + $ python -m venv venv $ source venv/bin/activate - (venv) $ python -m pip install tox + (venv) $ python -m pip install poetry + (venv) $ poetry update (venv) $ tox The test suite uses tox to setup multiple environments with varying dependencies using multiple Python interpreters; pytest allows the test suite to have parametrized tests; pyfakefs creates a fake -filesystem that the tests can run against; and coverage keeps track -of which lines of code (and which branches) have been run. +filesystem that the tests safely create and erase files in; +and coverage keeps track of which lines of code have been run. -Further reading: `tox`_, `venv`_, `pytest`_, `pyfakefs`_, `coverage`_ +**pelican_precompress** has 100% test coverage, but there may still be bugs. +Please report any issues that you encounter. + +Further reading: `poetry`_, `tox`_, `venv`_, `pytest`_, `pyfakefs`_, `coverage`_ .. Links @@ -193,6 +199,7 @@ Further reading: `tox`_, `venv`_, `pytest`_, `pyfakefs`_, `coverage`_ .. _gzip_static: https://nginx.org/en/docs/http/ngx_http_gzip_static_module.html#gzip_static .. _gzip_vary: https://nginx.org/en/docs/http/ngx_http_gzip_module.html#gzip_vary .. _nginx brotli module: https://github.com/google/ngx_brotli +.. _poetry: https://python-poetry.org/ .. _tox: https://tox.readthedocs.io/en/latest/ .. _pytest: https://docs.pytest.org/en/latest/ .. _pyfakefs: https://jmcgeheeiv.github.io/pyfakefs/release/ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..69ed9f8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,84 @@ +[tool.poetry] +name = "pelican_precompress" +version = "1.1.2" +description = "Pre-compress your Pelican site using gzip, zopfli, and brotli!" +authors = ["Kurt McKee "] +license = "MIT" +packages = [ + { include = "pelican", from = "src" } +] +readme = "README.rst" +repository = "https://github.com/kurtmckee/pelican_precompress/" +keywords = ["pelican", "plugin", "gzip", "brotli", "zopfli"] +classifiers = [ + "Framework :: Pelican :: Plugins", + "Development Status :: 5 - Production/Stable", +] + +[tool.poetry.dependencies] +python = "^3.6" + +[tool.poetry.dev-dependencies] +tox = "^3.23.0" +doit = "^0.33.1" +docutils = "^0.17" + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" + + +[tool.tox] +legacy_tox_ini = """ + +[tox] +envlist = clean, py{36, 37, 38, 39}-{brotli, }-{zopfli, }, report +skip_missing_interpreters = True +isolated_build = True + + +[testenv] +deps = + pytest + pytest-cov + pyfakefs + brotli: brotli + zopfli: zopfli +setenv = + COVERAGE_FILE={toxworkdir}/.coverage.envname.{envname} +commands = {envpython} -m pytest --color=yes --cov=pelican.plugins.precompress --cov=test_pelican_precompress --cov-report=term test_pelican_precompress.py + + +[testenv:clean] +skip_install = True +deps = + coverage[toml] +setenv = + COVERAGE_FILE={toxworkdir}/.coverage +commands = + {envpython} -m coverage erase + + +[testenv:report] +skip_install = True +deps = + coverage[toml] +setenv = + COVERAGE_FILE={toxworkdir}/.coverage +commands = + {envpython} -m coverage combine + {envpython} -m coverage report + {envpython} -m coverage html + +""" + + +[tool.coverage.run] +branch = true + + +[tool.coverage.paths] +source = [ + "src", + "*/site-packages", +] diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 5879a26..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of the pelican-precompress plugin. -# Copyright 2019-2021 Kurt McKee -# Released under the MIT license. -# -# Setup instructions: -# -# $ python -m venv venv -# $ source venv/bin/activate -# (venv) $ pip install -r requirements-dev.txt --upgrade -# - -docutils -doit -tox -twine -wheel diff --git a/setup.py b/setup.py deleted file mode 100644 index 0599c5c..0000000 --- a/setup.py +++ /dev/null @@ -1,51 +0,0 @@ -# This file is part of the pelican-precompress plugin. -# Copyright 2019-2021 Kurt McKee -# Released under the MIT license. - -import os -import pathlib -import re -import setuptools - - -def get_version(): - path = pathlib.Path(__file__).parent / 'src/pelican/plugins/precompress/__init__.py' - version_blob = path.read_text() - return re.search("""__version__ = ['"](.+?)['"]""", version_blob).group(1) - - -with pathlib.Path('README.rst').open('r') as file: - long_description = file.read() - -name = 'pelican_precompress' -if os.getenv('PRECOMPRESS_NAME_SUFFIX'): - name = f'pelican_precompress_{os.getenv("PRECOMPRESS_NAME_SUFFIX")}' - -version = get_version() -if os.getenv('PRECOMPRESS_VERSION_SUFFIX'): - version = f'{version}b{os.getenv("PRECOMPRESS_VERSION_SUFFIX")}' - -setuptools.setup( - name=name, - version=version, - author='Kurt McKee', - author_email='contactme@kurtmckee.org', - description='Pre-compress your Pelican site using gzip, zopfli, and brotli!', - long_description=long_description, - long_description_content_type='text/x-rst', - url='https://github.com/kurtmckee/pelican_precompress', - packages=['pelican.plugins.precompress'], - package_dir={'pelican': 'src/pelican'}, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Framework :: Pelican :: Plugins', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Topic :: Internet :: WWW/HTTP :: Site Management', - ], - python_requires='~=3.6', -) diff --git a/src/pelican/plugins/precompress/__init__.py b/src/pelican/plugins/precompress/__init__.py index 2377a7c..d5ed8c3 100644 --- a/src/pelican/plugins/precompress/__init__.py +++ b/src/pelican/plugins/precompress/__init__.py @@ -12,7 +12,6 @@ import pelican -__version__ = '1.1.2' log = logging.getLogger(__name__) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 5e53614..0000000 --- a/tox.ini +++ /dev/null @@ -1,55 +0,0 @@ -# This file is part of the pelican-precompress plugin. -# Copyright 2019-2021 Kurt McKee -# Released under the MIT license. - - -[tox] -envlist = clean, py{36, 37, 38, 39}-{brotli, }-{zopfli, }, report -skip_missing_interpreters = True - - -[testenv] -deps = - pytest - pytest-cov - pyfakefs - brotli: brotli - zopfli: zopfli -setenv = - COVERAGE_FILE={toxworkdir}/.coverage.envname.{envname} -commands = {envpython} -m pytest --color=yes --cov=pelican.plugins.precompress --cov=test_pelican_precompress --cov-report=term test_pelican_precompress.py - - -[testenv:clean] -skip_install = True -deps = - coverage -setenv = - COVERAGE_FILE={toxworkdir}/.coverage -commands = - {envpython} -m coverage erase - - -[testenv:report] -skip_install = True -deps = - coverage -setenv = - COVERAGE_FILE={toxworkdir}/.coverage -commands = - {envpython} -m coverage combine - {envpython} -m coverage report - {envpython} -m coverage html - - -[coverage:run] -include = - pelican.plugins.precompress - test_pelican_precompress -branch = True - - -[coverage:paths] -source = - src - */site-packages From 17247c2224ded1d39cfd9503d4d92d7273cbd5a9 Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Tue, 13 Apr 2021 07:33:50 -0500 Subject: [PATCH 3/4] Remove doit and docutils as a dev dependency --- dodo.py | 87 -------------------------------------------------- pyproject.toml | 2 -- 2 files changed, 89 deletions(-) delete mode 100644 dodo.py diff --git a/dodo.py b/dodo.py deleted file mode 100644 index e6f119f..0000000 --- a/dodo.py +++ /dev/null @@ -1,87 +0,0 @@ -# This file is part of the pelican-precompress plugin. -# Copyright 2019-2021 Kurt McKee -# Released under the MIT license. - -# The tasks defined in this file automates the entire -# development-to-release process. - -import random -import subprocess - -DOIT_CONFIG = {'default_tasks': ['build', 'test']} - - -def task_build(): - """Build the documentation. - - The documentation will be converted to HTML files to help double-check - syntax and formatting on PyPI and on GitHub. Note that the HTML files - will not be included in the distribution files. - """ - - return { - 'actions': [ - 'rst2html.py CHANGES.rst CHANGES.html', - 'rst2html.py README.rst README.html', - ], - 'verbosity': 2, - 'file_dep': ['CHANGES.rst', 'README.rst'], - 'targets': ['CHANGES.html', 'README.html'], - } - - -def task_test(): - """Run the unit tests.""" - - return { - 'actions': ['PY_COLORS=1 tox'], - 'verbosity': 2, - 'file_dep': [ - 'setup.py', - 'pelican_precompress.py', - 'test_pelican_precompress.py', - ], - } - - -def task_test_release(): - """Upload to test.pypi.org.""" - - name_suffix = ''.join(chr(i) for i in random.sample(range(0x61, 0x61+26), 10)) - version_suffix = str(random.choice(range(1, 1000))) - - return { - 'actions': [ - 'rm dist/*', - f'PRECOMPRESS_NAME_SUFFIX={name_suffix} PRECOMPRESS_VERSION_SUFFIX={version_suffix} python setup.py sdist bdist_wheel', - f'twine upload --repository testpypi dist/*{name_suffix}*', - f'xdg-open https://test.pypi.org/project/pelican_precompress_{name_suffix}', - ], - 'verbosity': 2, - } - - -def validate_in_git_master_branch(): - """Validate that the repository is in the git master branch.""" - - branch = subprocess.check_output('git rev-parse --abbrev-ref HEAD', shell=True) - return branch.decode('utf8', errors='ignore').strip() == 'master' - - -def task_release(): - """Upload to pypi.org. - - This step must *always* be taken while in the git master branch. - This is an enforced requirement. - """ - - return { - 'actions': [ - validate_in_git_master_branch, - 'rm dist/*', - f'python setup.py sdist bdist_wheel', - f'twine upload dist/*', - f'xdg-open https://pypi.org/project/pelican_precompress', - ], - 'verbosity': 2, - } diff --git a/pyproject.toml b/pyproject.toml index 69ed9f8..a655953 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,8 +20,6 @@ python = "^3.6" [tool.poetry.dev-dependencies] tox = "^3.23.0" -doit = "^0.33.1" -docutils = "^0.17" [build-system] requires = ["poetry-core>=1.0.0"] From ae27e21aa8fb644c1e95de42485c6bbd66e0c691 Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Tue, 13 Apr 2021 07:51:48 -0500 Subject: [PATCH 4/4] Bump version --- CHANGES.rst | 18 ++++++++++++++++++ pyproject.toml | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index c8d7a2b..be115f7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,9 +8,27 @@ Changelog Unreleased changes ================== + + + +2.0.0 - 2021-04-13 +================== + * Migrate to the namespace plugin architecture introduced in Pelican 4.5. * Migrate to Poetry to manage the dependencies and build process. +**Breaking change** + +Pelican 4.5 introduced a namespace plugin architecture +which allows automatic plugin detection and loading. + +pelican_precompress 2.0.0 supports this new architecture, +but this change requires existing users to modify the +``PLUGINS`` list in the Pelican configuration file. + +pelican_precompress can be referenced and enabled with the name +``'pelican.plugins.precompress'`` in the ``PLUGINS`` list. + 1.1.2 - 2021-02-11 diff --git a/pyproject.toml b/pyproject.toml index a655953..0117e7d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pelican_precompress" -version = "1.1.2" +version = "2.0.0" description = "Pre-compress your Pelican site using gzip, zopfli, and brotli!" authors = ["Kurt McKee "] license = "MIT"