Skip to content

Commit

Permalink
Merge branch 'release' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtmckee committed Apr 13, 2021
2 parents 88618a9 + ae27e21 commit 2143579
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 228 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,27 @@ 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
==================

Expand Down
43 changes: 30 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -151,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.

**pelican_precompress** has 100% test coverage, but there may still be bugs.
Please report any issues that you encounter.

Further reading: `tox`_, `venv`_, `pytest`_, `pyfakefs`_, `coverage`_
Further reading: `poetry`_, `tox`_, `venv`_, `pytest`_, `pyfakefs`_, `coverage`_


.. Links
Expand All @@ -183,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/
Expand Down
87 changes: 0 additions & 87 deletions dodo.py

This file was deleted.

82 changes: 82 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
[tool.poetry]
name = "pelican_precompress"
version = "2.0.0"
description = "Pre-compress your Pelican site using gzip, zopfli, and brotli!"
authors = ["Kurt McKee <[email protected]>"]
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"

[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",
]
16 changes: 0 additions & 16 deletions requirements-dev.txt

This file was deleted.

44 changes: 0 additions & 44 deletions setup.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,10 @@
from typing import Dict, Iterable, Optional, Set, Union
import zlib

__version__ = '1.1.2'
import pelican

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
log = logging.getLogger(__name__)

# brotli support is optional.
try:
Expand Down
Loading

0 comments on commit 2143579

Please sign in to comment.