1
0
Fork 0
forked from github/pelican

migrate configuration to PEP621 compatible config

- adapt documentation
- add wheel tests to check wheel contents.
- adapt pipeline to use pdm
- adapt autopub config
- add scripts as shortcuts to invoke tasks
This commit is contained in:
Lioman 2023-10-28 17:43:16 +02:00
commit 8b6d215934
13 changed files with 113 additions and 1495 deletions

View file

@ -51,23 +51,18 @@ jobs:
lint: lint:
name: Lint name: Lint
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install Poetry - uses: pdm-project/setup-pdm@v3
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v4
with: with:
python-version: "3.9" python-version: 3.9
cache: "poetry" cache: true
cache-dependency-path: "pyproject.toml" cache-dependency-path: ./pyproject.toml
- name: Install dependencies - name: Install dependencies
run: | run: |
poetry env use "3.9" pdm install
poetry install --no-interaction --no-root
- name: Run linters - name: Run linters
run: poetry run invoke lint --diff run: pdm lint --diff
docs: docs:
name: Build docs name: Build docs

3
.gitignore vendored
View file

@ -15,4 +15,5 @@ htmlcov
venv venv
samples/output samples/output
*.pem *.pem
poetry.lock *.lock
.pdm-python

View file

@ -1 +0,0 @@
/Users/eliaskirchgaessner/Development/FOSS/pelican/.venv/bin/python

View file

@ -2,48 +2,58 @@ import datetime
import os import os
import sys import sys
from pelican import __version__ if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib
sys.path.append(os.path.abspath(os.pardir)) sys.path.append(os.path.abspath(os.pardir))
with open("../pyproject.toml", "rb") as f:
project_data = tomllib.load(f).get("project")
if project_data is None:
raise KeyError("project data is not found")
# -- General configuration ---------------------------------------------------- # -- General configuration ----------------------------------------------------
templates_path = ['_templates'] templates_path = ["_templates"]
extensions = [ extensions = [
"sphinx.ext.autodoc", "sphinx.ext.autodoc",
"sphinx.ext.ifconfig", "sphinx.ext.ifconfig",
"sphinx.ext.extlinks", "sphinx.ext.extlinks",
"sphinxext.opengraph", "sphinxext.opengraph",
] ]
source_suffix = '.rst' source_suffix = ".rst"
master_doc = 'index' master_doc = "index"
project = 'Pelican' project = project_data.get("name").upper()
year = datetime.datetime.now().date().year year = datetime.datetime.now().date().year
copyright = f'2010{year}' copyright = f"2010{year}"
exclude_patterns = ['_build'] exclude_patterns = ["_build"]
release = __version__ release = project_data.get("version")
version = '.'.join(release.split('.')[:1]) version = ".".join(release.split(".")[:1])
last_stable = __version__ last_stable = project_data.get("version")
rst_prolog = ''' rst_prolog = f"""
.. |last_stable| replace:: :pelican-doc:`{}` .. |last_stable| replace:: :pelican-doc:`{last_stable}`
'''.format(last_stable) .. |min_python| replace:: {project_data.get('requires-python').split(",")[0]}
"""
extlinks = { extlinks = {"pelican-doc": ("https://docs.getpelican.com/en/latest/%s.html", "%s")}
'pelican-doc': ('https://docs.getpelican.com/en/latest/%s.html', '%s')
}
# -- Options for HTML output -------------------------------------------------- # -- Options for HTML output --------------------------------------------------
html_theme = 'furo' html_theme = "furo"
html_title = f'<strong>{project}</strong> <i>{release}</i>' html_title = f"<strong>{project}</strong> <i>{release}</i>"
html_static_path = ['_static'] html_static_path = ["_static"]
html_theme_options = { html_theme_options = {
'light_logo': 'pelican-logo.svg', "light_logo": "pelican-logo.svg",
'dark_logo': 'pelican-logo.svg', "dark_logo": "pelican-logo.svg",
'navigation_with_keys': True, "navigation_with_keys": True,
} }
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'Pelicandoc' htmlhelp_basename = "Pelicandoc"
html_use_smartypants = True html_use_smartypants = True
@ -59,21 +69,29 @@ html_show_sourcelink = False
def setup(app): def setup(app):
# overrides for wide tables in RTD theme # overrides for wide tables in RTD theme
app.add_css_file('theme_overrides.css') # path relative to _static app.add_css_file("theme_overrides.css") # path relative to _static
# -- Options for LaTeX output ------------------------------------------------- # -- Options for LaTeX output -------------------------------------------------
latex_documents = [ latex_documents = [
('index', 'Pelican.tex', 'Pelican Documentation', 'Justin Mayer', ("index", "Pelican.tex", "Pelican Documentation", "Justin Mayer", "manual"),
'manual'),
] ]
# -- Options for manual page output ------------------------------------------- # -- Options for manual page output -------------------------------------------
man_pages = [ man_pages = [
('index', 'pelican', 'pelican documentation', ("index", "pelican", "pelican documentation", ["Justin Mayer"], 1),
['Justin Mayer'], 1), (
('pelican-themes', 'pelican-themes', 'A theme manager for Pelican', "pelican-themes",
['Mickaël Raybaud'], 1), "pelican-themes",
('themes', 'pelican-theming', 'How to create themes for Pelican', "A theme manager for Pelican",
['The Pelican contributors'], 1) ["Mickaël Raybaud"],
1,
),
(
"themes",
"pelican-theming",
"How to create themes for Pelican",
["The Pelican contributors"],
1,
),
] ]

View file

@ -15,16 +15,16 @@ Setting up the development environment
====================================== ======================================
While there are many ways to set up one's development environment, the following While there are many ways to set up one's development environment, the following
instructions will utilize Pip_ and Poetry_. These tools facilitate managing instructions will utilize Pip_ and pdm_. These tools facilitate managing
virtual environments for separate Python projects that are isolated from one virtual environments for separate Python projects that are isolated from one
another, so you can use different packages (and package versions) for each. another, so you can use different packages (and package versions) for each.
Please note that Python 3.7+ is required for Pelican development. Please note that Python |min_python| is required for Pelican development.
*(Optional)* If you prefer to `install Poetry <https://python-poetry.org/docs/master/#installation>`_ once for use with multiple projects, *(Optional)* If you prefer to `install pdm <https://pdm.fming.dev/latest/#installation>`_ once for use with multiple projects,
you can install it via:: you can install it via::
curl -sSL https://install.python-poetry.org | python3 - curl -sSL https://pdm.fming.dev/install-pdm.py | python3 -
Point your web browser to the `Pelican repository`_ and tap the **Fork** button Point your web browser to the `Pelican repository`_ and tap the **Fork** button
at top-right. Then clone the source for your fork and add the upstream project at top-right. Then clone the source for your fork and add the upstream project
@ -35,7 +35,7 @@ as a Git remote::
cd ~/projects/pelican cd ~/projects/pelican
git remote add upstream https://github.com/getpelican/pelican.git git remote add upstream https://github.com/getpelican/pelican.git
While Poetry can dynamically create and manage virtual environments, we're going While pdm can dynamically create and manage virtual environments, we're going
to manually create and activate a virtual environment:: to manually create and activate a virtual environment::
mkdir ~/virtualenvs && cd ~/virtualenvs mkdir ~/virtualenvs && cd ~/virtualenvs
@ -51,7 +51,7 @@ Install the needed dependencies and set up the project::
Your local environment should now be ready to go! Your local environment should now be ready to go!
.. _Pip: https://pip.pypa.io/ .. _Pip: https://pip.pypa.io/
.. _Poetry: https://python-poetry.org/ .. _pdm: https://pdm.fming.dev/latest/
.. _Pelican repository: https://github.com/getpelican/pelican .. _Pelican repository: https://github.com/getpelican/pelican
Development Development

View file

@ -1,7 +1,7 @@
Installing Pelican Installing Pelican
################## ##################
Pelican currently runs best on 3.7+; earlier versions of Python are not supported. Pelican currently runs best on |min_python|; earlier versions of Python are not supported.
You can install Pelican via several different methods. The simplest is via Pip_:: You can install Pelican via several different methods. The simplest is via Pip_::

View file

@ -8,7 +8,7 @@ Installation
------------ ------------
Install Pelican (and optionally Markdown if you intend to use it) on Python Install Pelican (and optionally Markdown if you intend to use it) on Python
3.7+ by running the following command in your preferred terminal, prefixing |min_python| by running the following command in your preferred terminal, prefixing
with ``sudo`` if permissions warrant:: with ``sudo`` if permissions warrant::
python -m pip install "pelican[markdown]" python -m pip install "pelican[markdown]"

1431
pdm.lock generated

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
def pytest_addoption(parser):
parser.addoption(
"--check-wheel",
action="store",
default=False,
help="Check wheel contents.",
)

View file

@ -0,0 +1,28 @@
from pathlib import Path
import pytest
from zipfile import ZipFile
@pytest.mark.skipif(
"not config.getoption('--check-wheel')",
reason="Only run when --check-wheel is given",
)
def test_wheel_contents(pytestconfig):
"""
This test, should test the contents of the wheel to make sure,
that everything that is needed is included in the final build
"""
wheel_file = pytestconfig.getoption("--check-wheel")
assert wheel_file.endswith(".whl")
files_list = ZipFile(wheel_file).namelist()
## Check is theme files are copiedto wheel
simple_theme = Path("./pelican/themes/simple/templates")
for x in simple_theme.iterdir():
assert str(x) in files_list
## Check is tool templatesare copiedto wheel
tools = Path("./pelican/tools/templates")
for x in tools.iterdir():
assert str(x) in files_list
assert "pelican/tools/templates/tasks.py.jinja2" in files_list

View file

@ -37,7 +37,8 @@ dependencies = [
"python-dateutil>=2.8", "python-dateutil>=2.8",
"rich>=10.1", "rich>=10.1",
"unidecode>=1.1", "unidecode>=1.1",
"backports-zoneinfo<1.0.0,>=0.2.1; python_version<3.9", "backports-zoneinfo<1.0.0,>=0.2.1;python_version<'3.9'",
"watchfiles",
] ]
[project.optional-dependencies] [project.optional-dependencies]
@ -53,9 +54,9 @@ Documentation = "https://docs.getpelican.com"
[project.scripts] [project.scripts]
pelican = "pelican.__main__:main" pelican = "pelican.__main__:main"
pelican-import = "pelican.tools.pelican_import:main" pelican-import = "pelican.tools.pelican_import:main"
pelican-plugins = "pelican.plugins._utils:list_plugins"
pelican-quickstart = "pelican.tools.pelican_quickstart:main" pelican-quickstart = "pelican.tools.pelican_quickstart:main"
pelican-themes = "pelican.tools.pelican_themes:main" pelican-themes = "pelican.tools.pelican_themes:main"
pelican-plugins = "pelican.plugins._utils:list_plugins"
[tool.autopub] [tool.autopub]
project-name = "Pelican" project-name = "Pelican"
@ -64,14 +65,14 @@ git-email = "52496925+botpub@users.noreply.github.com"
changelog-file = "docs/changelog.rst" changelog-file = "docs/changelog.rst"
changelog-header = "###############" changelog-header = "###############"
version-header = "=" version-header = "="
version-strings = ["setup.py"]
build-system = "setuptools"
[tool.pdm] [tool.pdm]
[tool.pdm.scripts] [tool.pdm.scripts]
docbuild = "invoke docbuild" docbuild = "invoke docbuild"
docserve = "invoke docserve" docserve = "invoke docserve"
lint = "invoke lint"
test = "invoke tests"
[tool.pdm.dev-dependencies] [tool.pdm.dev-dependencies]
dev = [ dev = [
@ -95,11 +96,10 @@ dev = [
"invoke<3.0,>=2.0", "invoke<3.0,>=2.0",
"isort<6.0,>=5.2", "isort<6.0,>=5.2",
"black<20.0,>=19.10b0", "black<20.0,>=19.10b0",
"ruff>=0.1.3,<1.0.0",
"tomli;python_version<'3.11'",
] ]
[tool.pdm.build]
includes = []
[build-system] [build-system]
requires = ["pdm-backend"] requires = ["pdm-backend"]
build-backend = "pdm.backend" build-backend = "pdm.backend"

View file

@ -2,3 +2,4 @@ sphinx<6.0
sphinxext-opengraph sphinxext-opengraph
furo furo
livereload livereload
tomli;python_version<"3.11"

View file

@ -15,8 +15,8 @@ VENV_PATH = Path(ACTIVE_VENV) if ACTIVE_VENV else (VENV_HOME / PKG_NAME)
VENV = str(VENV_PATH.expanduser()) VENV = str(VENV_PATH.expanduser())
VENV_BIN = Path(VENV) / Path(BIN_DIR) VENV_BIN = Path(VENV) / Path(BIN_DIR)
TOOLS = ["poetry", "pre-commit", "psutil"] TOOLS = ["pdm", "pre-commit", "psutil"]
POETRY = which("poetry") or VENV_BIN / "poetry" PDM = which("pdm") or VENV_BIN / "pdm"
PRECOMMIT = which("pre-commit") or VENV_BIN / "pre-commit" PRECOMMIT = which("pre-commit") or VENV_BIN / "pre-commit"
@ -107,7 +107,7 @@ def precommit(c):
def setup(c): def setup(c):
c.run(f"{VENV_BIN}/python -m pip install -U pip", pty=PTY) c.run(f"{VENV_BIN}/python -m pip install -U pip", pty=PTY)
tools(c) tools(c)
c.run(f"{POETRY} install", pty=PTY) c.run(f"{PDM} install", pty=PTY)
precommit(c) precommit(c)