Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation Problem - Alpine Linux Container (used for GH Actions) #42

Open
seven62 opened this issue May 21, 2021 · 6 comments
Open

Comments

@seven62
Copy link

seven62 commented May 21, 2021

Hello, thanks for all the work on this nice plugin! I want to be clear that I have no issues using this plugin on my local macOS environment when installed from git, this is specifically when building a container that is used to build content via Actions.

Context

I understand this may be a fringe case, and I'm still working out learning all things containerization. I hope this issue can be helpful for others.

Bare Metal Install (macOS):

  • I wasn't able to get this plugin to work correctly when running: pip install mkpdfs-mkdocs
  • My issue was resolved when installing via git: pip install -e git+https://github.com/jwaschkau/mkpdfs-mkdocs-plugin.git#egg=mkpdfs-mkdocs

With that in mind, I moved my efforts towards getting this plugin added to the official mkdocs-material docker image workflow.

MkDocs Configuration

The plugins section of mkdocs.yml is:

plugins:
  - search
  - mkpdfs

Attempt 1 - Standard install

I added all of the Weasyprint dependency packages to the install list:

Dockerfile:

...
...
# Perform build and cleanup artifacts and caches
RUN \
  apk upgrade --update-cache -a && \
  apk add --no-cache \
    git \
    git-fast-import \
    openssh \
    jpeg-dev \
    zlib-dev \
    libffi-dev \
    cairo-dev \
    pango-dev \
    gdk-pixbuf-dev \
  && apk add --no-cache --virtual .build gcc musl-dev \
  && pip install --no-cache-dir . \
  && apk del .build gcc musl-dev \
  && \
...

requirements.txt:

mkdocs>=1.1
Pygments>=2.4
markdown>=3.2
pymdown-extensions>=7.0
mkdocs-material-extensions>=1.0
mkdocs-minify-plugin>=0.3
mkdocs-redirects>=1.0
WeasyPrint
mkpdfs-mkdocs

Error

I got the same set of errors as when I bare-metal installed with the standard pip command on my macOS box:

docker run --rm -i -v ${PWD}:/docs mkdocs-material-insiders:pdftesting build:

/usr/local/lib/python3.9/site-packages/weasyprint/fonts.py:228: UserWarning: FontConfig: No fonts configured. Expect ugly output.
  warnings.warn(
/usr/local/lib/python3.9/site-packages/mkpdfs_mkdocs/preprocessor/links/transform.py:15: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif num_hashtags is 1:
/usr/local/lib/python3.9/site-packages/mkpdfs_mkdocs/preprocessor/links/transform.py:23: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif num_hashtags is 0:
/usr/local/lib/python3.9/site-packages/mkpdfs_mkdocs/preprocessor/links/util.py:52: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if i is 0:
Traceback (most recent call last):
  File "/usr/local/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/__main__.py", line 152, in build_command
    build.build(config.load_config(**kwargs), dirty=not clean)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/config/base.py", line 197, in load_config
    errors, warnings = cfg.validate()
  File "/usr/local/lib/python3.9/site-packages/mkdocs/config/base.py", line 107, in validate
    run_failed, run_warnings = self._validate()
  File "/usr/local/lib/python3.9/site-packages/mkdocs/config/base.py", line 62, in _validate
    self[key] = config_option.validate(value)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/config/config_options.py", line 131, in validate
    return self.run_validation(value)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/config/config_options.py", line 609, in run_validation
    plgins[item] = self.load_plugin(item, cfg)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/config/config_options.py", line 617, in load_plugin
    Plugin = self.installed_plugins[name].load()
  File "/usr/local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2450, in load
    return self.resolve()
  File "/usr/local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2456, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python3.9/site-packages/mkpdfs_mkdocs/__init__.py", line 1, in <module>
    from .mkpdfs import Mkpdfs
  File "/usr/local/lib/python3.9/site-packages/mkpdfs_mkdocs/mkpdfs.py", line 17, in <module>
    class Mkpdfs(BasePlugin):
  File "/usr/local/lib/python3.9/site-packages/mkpdfs_mkdocs/mkpdfs.py", line 20, in Mkpdfs
    ('design', config_options.Type(utils.string_types, default=None)),
AttributeError: module 'mkdocs.utils' has no attribute 'string_types'

Attempt 2 - Install with Git

The next attempt I replaced the the standard mkpdfs-mkdocs package name in requirements.txt with the pip git command into the Dockerfile

Dockerfile:

...
...
# Perform build and cleanup artifacts and caches
RUN \
  apk upgrade --update-cache -a && \
  apk add --no-cache \
    git \
    git-fast-import \
    openssh \
    jpeg-dev \
    zlib-dev \
    libffi-dev \
    cairo-dev \
    pango-dev \
    gdk-pixbuf-dev \
  && apk add --no-cache --virtual .build gcc musl-dev \
  && pip install --no-cache-dir . \
  && pip install -e git+https://github.com/jwaschkau/mkpdfs-mkdocs-plugin.git#egg=mkpdfs-mkdocs \
  && apk del .build gcc musl-dev \
  && \
...

requirements.txt:

mkdocs>=1.1
Pygments>=2.4
markdown>=3.2
pymdown-extensions>=7.0
mkdocs-material-extensions>=1.0
mkdocs-minify-plugin>=0.3
mkdocs-redirects>=1.0
WeasyPrint

Errors

  1. The docker image build process completes with no errors
  2. Running the build command errors notifying that the needed plugin isn't available

docker run --rm -i -v ${PWD}:/docs mkdocs-material-insiders:pdftesting build:

ERROR   -  Config value: 'plugins'. Error: The "mkpdfs" plugin is not installed 
Aborted with 1 Configuration Errors!

I appreciate any info, and happy to work with the community on any testing!

@comwes
Copy link
Owner

comwes commented May 24, 2021

Hi @seven62

Thanks for reporting this.

The issue you are facing when using installation of the package from the pip repo is related to #16 for which the fix is planned to be part of the next release version 1.1.0.

As I had a bit time to merge and add improvement and new features. I think I'll release earlier than planned, and hopefully it will fix issues that many of you are facing.

Regarding git installation on docker, I'll have to test before giving any diagnostic. But for now I don't have time to do so.
KR.

@seven62
Copy link
Author

seven62 commented May 25, 2021

Thanks for the update @comwes, I look forward to helping with any testing!

@tmeuze
Copy link

tmeuze commented Jun 7, 2021

Following, as I am experiencing the same error. Please let me know if you need any testing done.

@comwes
Copy link
Owner

comwes commented Jul 5, 2021

@tmeuze If you have a bit of time, can you test and let me know if you find out any issue that I've missed?
I have merged the code fixing all issues in the master and I'm planning to release something the upcoming weekend.

@tmeuze
Copy link

tmeuze commented Jul 13, 2021

Hi @comwes , sorry for the late reply. This appears to be functional for me with no error. Via pip install git+https://github.com/comwes/mkpdfs-mkdocs-plugin on GH Actions, Ubuntu 20.04.

Thank you for all your work!

@comwes
Copy link
Owner

comwes commented Jul 14, 2021

Hi @tmeuze
Thank you for the testing and the feedback. I will prepare the release notes for the upcoming version.
I still have to work on one last issue this weekend and hopefully I'll have time to get everything ready before end of July. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants