jimporter / mike

Manage multiple versions of your MkDocs-powered documentation via Git
BSD 3-Clause "New" or "Revised" License
511 stars 45 forks source link

feat: executable with `python -m mike` #201

Closed kiyoon closed 5 months ago

kiyoon commented 5 months ago

Problem

In setup-python actions https://github.com/actions/setup-python, you can cache the requirements and it will restore the python packages in the next run.
However, it won't restore the commands stored in the bin folder. Thus I can't execute mike with the cached installation afterwards.

Solution

I want to make mike executable with python -m mike, just like python -m mkdocs.

Example GitHub Actions

name: Deploy docs

on:
  push:
    branches:
      - main

jobs:
  mkdocs:
    runs-on: ubuntu-latest
    environment: mkdocs

    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v5
        id: setup-python
        with:
          python-version-file: pyproject.toml
          cache: 'pip'
          cache-dependency-path: |
            requirements_docs.txt
      - name: Install dependencies
        if: steps.setup-python.outputs.cache-hit != 'true'
        run: |
          python -m pip install --upgrade pip
          pip3 install -r requirements_docs.txt
      - name: Run mkdocs
        run: |
          python -m mike deploy latest
kiyoon commented 5 months ago

Hi, I actually figured out that caching dependencies doesn't actually install them so I still had to install them.
I fixed it by removing the line if: steps.setup-python.outputs.cache-hit != 'true'.
It didn't give many benefits in speed doing this though.

I'm sorry for the confusion on my side.