Skip to content

Commit

Permalink
Merge pull request #3220 from lioman/centralize-python-information
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmayer committed Oct 29, 2023
2 parents 165d57e + 8a0f335 commit 73599f4
Show file tree
Hide file tree
Showing 14 changed files with 176 additions and 215 deletions.
17 changes: 6 additions & 11 deletions .github/workflows/main.yml
Expand Up @@ -51,23 +51,18 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Install Poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v4
- uses: pdm-project/setup-pdm@v3
with:
python-version: "3.9"
cache: "poetry"
cache-dependency-path: "pyproject.toml"
python-version: 3.9
cache: true
cache-dependency-path: ./pyproject.toml
- name: Install dependencies
run: |
poetry env use "3.9"
poetry install --no-interaction --no-root
pdm install --no-default --dev
- name: Run linters
run: poetry run invoke lint --diff
run: pdm lint --diff

docs:
name: Build docs
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -15,4 +15,5 @@ htmlcov
venv
samples/output
*.pem
poetry.lock
*.lock
.pdm-python
6 changes: 0 additions & 6 deletions MANIFEST.in

This file was deleted.

84 changes: 51 additions & 33 deletions docs/conf.py
Expand Up @@ -2,48 +2,58 @@
import os
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))


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 ----------------------------------------------------
templates_path = ['_templates']
templates_path = ["_templates"]
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.ifconfig",
"sphinx.ext.extlinks",
"sphinxext.opengraph",
]
source_suffix = '.rst'
master_doc = 'index'
project = 'Pelican'
source_suffix = ".rst"
master_doc = "index"
project = project_data.get("name").upper()
year = datetime.datetime.now().date().year
copyright = f'2010–{year}'
exclude_patterns = ['_build']
release = __version__
version = '.'.join(release.split('.')[:1])
last_stable = __version__
rst_prolog = '''
.. |last_stable| replace:: :pelican-doc:`{}`
'''.format(last_stable)

extlinks = {
'pelican-doc': ('https://docs.getpelican.com/en/latest/%s.html', '%s')
}
copyright = f"2010–{year}"
exclude_patterns = ["_build"]
release = project_data.get("version")
version = ".".join(release.split(".")[:1])
last_stable = project_data.get("version")
rst_prolog = f"""
.. |last_stable| replace:: :pelican-doc:`{last_stable}`
.. |min_python| replace:: {project_data.get('requires-python').split(",")[0]}
"""

extlinks = {"pelican-doc": ("https://docs.getpelican.com/en/latest/%s.html", "%s")}

# -- Options for HTML output --------------------------------------------------

html_theme = 'furo'
html_title = f'<strong>{project}</strong> <i>{release}</i>'
html_static_path = ['_static']
html_theme = "furo"
html_title = f"<strong>{project}</strong> <i>{release}</i>"
html_static_path = ["_static"]
html_theme_options = {
'light_logo': 'pelican-logo.svg',
'dark_logo': 'pelican-logo.svg',
'navigation_with_keys': True,
"light_logo": "pelican-logo.svg",
"dark_logo": "pelican-logo.svg",
"navigation_with_keys": True,
}

# Output file base name for HTML help builder.
htmlhelp_basename = 'Pelicandoc'
htmlhelp_basename = "Pelicandoc"

html_use_smartypants = True

Expand All @@ -59,21 +69,29 @@

def setup(app):
# 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 -------------------------------------------------
latex_documents = [
('index', 'Pelican.tex', 'Pelican Documentation', 'Justin Mayer',
'manual'),
("index", "Pelican.tex", "Pelican Documentation", "Justin Mayer", "manual"),
]

# -- Options for manual page output -------------------------------------------
man_pages = [
('index', 'pelican', 'pelican documentation',
['Justin Mayer'], 1),
('pelican-themes', 'pelican-themes', 'A theme manager for Pelican',
['Mickaël Raybaud'], 1),
('themes', 'pelican-theming', 'How to create themes for Pelican',
['The Pelican contributors'], 1)
("index", "pelican", "pelican documentation", ["Justin Mayer"], 1),
(
"pelican-themes",
"pelican-themes",
"A theme manager for Pelican",
["Mickaël Raybaud"],
1,
),
(
"themes",
"pelican-theming",
"How to create themes for Pelican",
["The Pelican contributors"],
1,
),
]
12 changes: 6 additions & 6 deletions docs/contribute.rst
Expand Up @@ -15,16 +15,16 @@ Setting up the development environment
======================================

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
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::

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
at top-right. Then clone the source for your fork and add the upstream project
Expand All @@ -35,7 +35,7 @@ as a Git remote::
cd ~/projects/pelican
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::

mkdir ~/virtualenvs && cd ~/virtualenvs
Expand All @@ -51,7 +51,7 @@ Install the needed dependencies and set up the project::
Your local environment should now be ready to go!

.. _Pip: https://pip.pypa.io/
.. _Poetry: https://python-poetry.org/
.. _PDM: https://pdm.fming.dev/latest/
.. _Pelican repository: https://github.com/getpelican/pelican

Development
Expand Down
2 changes: 1 addition & 1 deletion docs/install.rst
@@ -1,7 +1,7 @@
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_::

Expand Down
2 changes: 1 addition & 1 deletion docs/quickstart.rst
Expand Up @@ -8,7 +8,7 @@ Installation
------------

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::

python -m pip install "pelican[markdown]"
Expand Down
7 changes: 7 additions & 0 deletions pelican/tests/build_test/conftest.py
@@ -0,0 +1,7 @@
def pytest_addoption(parser):
parser.addoption(
"--check-wheel",
action="store",
default=False,
help="Check wheel contents.",
)
28 changes: 28 additions & 0 deletions pelican/tests/build_test/test_wheel.py
@@ -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

0 comments on commit 73599f4

Please sign in to comment.