2 packages the each require different packages with a module with the same name

For my website I’m using the static site generator Render Engine. Render Engine’s base parser requires the python-frontmatter package and imports a module named frontmatter from it. I am working on extending that base parser with a Cooklang parser that uses cooklang-py that requires the frontmatter package and imports a module named frontmatter for it. Is there a way for me to handle the resolution here so that both packages can import the modules they need from the packages they require?

2 Likes

In the fork of Render Engine’s base parser, I’d add a build script that vendored in python-frontmatter for each release. It could simply use an empty directory in the source tree with an __init__.py, and pip install python-frontmatter --target= to target the copy of that dir in the build directory’s tree. Then change all the imports in Render Engine to relative imports (from .python_frontmatter import frontmatter).

I ended up just modifying to cooklang parser to use the same frontmatter package as Render Engine’s base parser. I was hoping there was a non-hacky way to handle this.